rouster 0.64 → 0.67

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 008791a032a42eb032e726fc8f87a7ff0b8a6fcd
4
- data.tar.gz: 034c72fff747de93fb5fd4d3067d95af5dacf9c9
3
+ metadata.gz: 82f9824019bc7951750f51019efd7d5d7e174d33
4
+ data.tar.gz: babacb0d00e65d6ea702886286940e6bdf61f9d0
5
5
  SHA512:
6
- metadata.gz: 97db5c53999f5a51747cfc5047bbc237b92dbe17b605c23ac749ee5687518e621a4391aa43efbeebe723b9d575780f77ac2fff3aa7d8df7836277d3cb0239ab1
7
- data.tar.gz: 878f36117813b34e06d99b3ba9fd44ab5c5a25c14e76b6c9b316eb833148afb544a2fd00ab61052f733ac7d572fd7618f55e556e9a696a9860c6e2bfa138f2a0
6
+ metadata.gz: 8fbed7fb6d5e19c71ad2488c0a50b9aa387ab5474363f4dc1c318c9cae9dba9b1c632bb2f6202a8e3d909cc7b92d54d489ad19ef9417f06a92c7b8eaa2bed2e0
7
+ data.tar.gz: d5ad29bdf90c6ef7c9896720ce2a16eff88833dc9e1c71e708b131a7c8edc6824546998ba086ae31de76966106458992ce23198a7b709a3d8be8f3de3617b516
data/Gemfile CHANGED
@@ -11,6 +11,5 @@ group :development do
11
11
  gem 'test-unit', '~> 3.0.0'
12
12
  end
13
13
 
14
- group :aws do
15
- gem 'fog'
16
- end
14
+ gem 'fog', '= 1.24.0', :groups => [:aws, :openstack]
15
+
data/Rakefile CHANGED
@@ -24,8 +24,8 @@ end
24
24
 
25
25
  task :examples do
26
26
  Dir['examples/**/*.rb'].each do |example|
27
- sh "ruby #{example}"
28
- end
27
+ sh "ruby #{example}"
28
+ end
29
29
  end
30
30
 
31
31
  task :vdestroy do
@@ -39,32 +39,26 @@ end
39
39
  Rake::TestTask.new(:test => :vdestroy) do |t|
40
40
  t.libs << 'lib'
41
41
  t.test_files = FileList['test/**/test_*.rb']
42
- t.verbose = true
43
42
  end
44
43
 
45
44
  Rake::TestTask.new do |t|
46
45
  t.name = 'unit'
47
46
  t.libs << 'lib'
48
47
  t.test_files = FileList['test/unit/**/test_*.rb']
49
- t.verbose = true
50
48
  end
51
49
 
52
50
  Rake::TestTask.new(:functional => :vdestroy) do |t|
53
51
  t.libs << 'lib'
54
52
  t.test_files = FileList['test/functional/**/test_*.rb']
55
- t.verbose = true
56
53
  end
57
54
 
58
55
  Rake::TestTask.new(:deltas => :vdestroy) do |t|
59
56
  t.libs << 'lib'
60
57
  t.test_files = FileList['test/functional/deltas/test_*.rb']
61
- t.verbose = true
62
58
  end
63
59
 
64
60
  Rake::TestTask.new do |t|
65
61
  t.name = 'puppet'
66
62
  t.libs << 'lib'
67
63
  t.test_files = FileList['test/puppet/test*.rb']
68
- t.verbose = true
69
64
  end
70
-
@@ -10,16 +10,21 @@ boxes = {
10
10
  :box_url => 'http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box',
11
11
  },
12
12
 
13
- :ubuntu12 => {
14
- :box_name => 'ubuntu12',
15
- :box_url => 'http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210.box',
13
+ :ubuntu12 => {
14
+ :box_name => 'ubuntu12',
15
+ :box_url => 'http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210.box',
16
16
  },
17
17
 
18
- :ubuntu13 => {
18
+ :ubuntu13 => {
19
19
  :box_name => 'ubuntu13',
20
20
  :box_url => 'http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-1310-x64-virtualbox-puppet.box',
21
21
  },
22
22
 
23
+ :centos7 => {
24
+ :box_name => 'centos7b',
25
+ :box_url => 'https://atlas.hashicorp.com/centos/boxes/7/versions/1610.01/providers/virtualbox.box',
26
+ },
27
+
23
28
  }
24
29
 
25
30
  Vagrant::Config.run do |config|
@@ -28,7 +33,7 @@ Vagrant::Config.run do |config|
28
33
 
29
34
  worker.vm.box = hash[:box_name]
30
35
  worker.vm.box_url = hash[:box_url]
31
- worker.vm.host_name = hash[:box_name]
36
+ worker.vm.host_name = hash[:box_hostname] || hash[:box_name]
32
37
  worker.vm.network :hostonly, sprintf('10.0.1.%s', rand(253).to_i + 2)
33
38
  worker.ssh.forward_agent = true
34
39
 
@@ -4,110 +4,30 @@ require 'rouster'
4
4
  require 'rouster/puppet'
5
5
  require 'rouster/tests'
6
6
 
7
- app = Rouster.new(:name => 'app', :verbosity => 4, :sudo => true)
8
- ppm = Rouster.new(:name => 'ppm', :verbosity => 1, :sudo => true)
7
+ centos6 = Rouster.new(:name => 'app', :verbosity => 4, :sudo => true)
8
+ centos7 = Rouster.new(:name => 'centos7', :verbosity => 4, :sudo => true)
9
9
 
10
- # passthrough boxes do not need to specify a name
11
- # commented out currently because passthrough is not MVP
12
- #lpt = Rouster.new(:passthrough => 'local', :verbosity => 4)
13
- #rpt = Rouster.new(:passthrough => 'remote', :verbosity => 4, :sshkey => '~/.ssh/id_dsa')
14
-
15
- workers = [app]
10
+ workers = [centos6, centos7]
16
11
 
17
12
  workers.each do |w|
18
13
  p '%s config: ' % w.name
19
14
  p w
20
15
 
21
- p 'status: %s' % w.status()
22
- p 'upping the box'
23
- w.up()
24
-
25
- p sprintf('%s status: %s', w.name, w.status())
26
- p sprintf('%s available via ssh: %s', w.name, w.is_available_via_ssh?())
27
-
28
- p 'suspending the box'
29
- w.suspend()
30
-
31
- p sprintf('%s status: %s', w.name, w.status())
32
- p sprintf('%s available via ssh: %s', w.name, w.is_available_via_ssh?())
33
-
34
- p 'bringing the box back'
35
- w.up()
36
-
37
- p sprintf('%s status: %s', w.name, w.status())
38
- p sprintf('%s available via ssh: %s', w.name, w.is_available_via_ssh?())
39
-
40
- ## expected success
41
- p sprintf('is_dir?(/tmp): %s', w.is_dir?('/tmp'))
42
- p sprintf('is_exectuable?(/sbin/service: %s', w.is_executable?('/sbin/service'))
43
- p sprintf('is_file?(/etc/hosts): %s', w.is_file?('/etc/hosts'))
44
- p sprintf('is_group?(root): %s', w.is_group?('root'))
45
- p sprintf('is_in_file?(/etc/hosts, puppet): %s', w.is_in_file?('/etc/hosts', 'puppet'))
46
- p sprintf('is_in_path?(ping): %s', w.is_in_path?('ping'))
47
- p sprintf('is_package?(libpcap): %s', w.is_package?('libpcap'))
48
- p sprintf('is_port_open?(9999): %s', w.is_port_open?(9999))
49
- p sprintf('is_port_active?(22): %s', w.is_port_active?(22))
50
- p sprintf('is_process_running?(sshd): %s', w.is_process_running?('sshd'))
51
- p sprintf('is_readable?(/etc/hosts): %s', w.is_readable?('/etc/hosts'))
52
- p sprintf('is_service?(iptables): %s', w.is_service?('iptables'))
53
- p sprintf('is_service_running?(iptables): %s', w.is_service_running?('iptables'))
54
- p sprintf('is_user?(root): %s', w.is_user?('root'))
55
- p sprintf('is_writeable?(/etc/hosts): %s', w.is_writeable?('/etc/hosts'))
16
+ p 'uptime: %s' % w.run('uptime')
17
+ p 'os type: %s' % w.os_type
18
+ p 'os version: %s' % w.os_version(w.os_type)
56
19
 
57
- ## expected failure
58
- p sprintf('is_dir?(/dne): %s', w.is_dir?('/dne'))
59
- p sprintf('is_executable?(fizzybang): %s', w.is_executable?('fizzybang'))
60
- p sprintf('is_file?(/dne/fizzy): %s', w.is_file?('/dne/fizzy'))
61
- p sprintf('is_group?(three-amigos): %s', w.is_group?('three-amigos'))
62
- p sprintf('is_in_file?(/etc/hosts, this content is not there): %s', w.is_in_file?('/etc/hosts', 'this content is not there'))
63
- p sprintf('is_in_file?(/dne/fizzy, this file is not there): %s', w.is_in_file?('/dne/fizzy', 'this file is not there'))
64
- p sprintf('is_in_path?(fizzy): %s', w.is_in_path?('fizzy'))
65
- p sprintf('is_package?(fizzybang): %s', w.is_package?('fizzybang'))
66
- p sprintf('is_port_open?(123, udp): %s', w.is_port_open?(123, 'udp'))
67
- p sprintf('is_port_open?(22): %s', w.is_port_open?(22))
68
- p sprintf('is_process_running?(fizzy): %s', w.is_process_running?('fizzy'))
69
- p sprintf('is_readable?(/dne/fizzy): %s', w.is_readable?('/dne/fizzy'))
70
- p sprintf('is_service?(syslogd): %s', w.is_service?('syslogd'))
71
- p sprintf('is_service_running?(smartd): %s', w.is_service_running?('smartd'))
72
- p sprintf('is_user?(toor): %s', w.is_user?('toor'))
73
- #p sprintf('is_writable?(/etc/hosts): %s', w.is_writeable?('/etc/hosts')) # running as sudo, so everything is writeable -- can we test this with a file in a path that DNE?
74
-
75
- # put a file on the box and then bring it back
76
- w.put(__FILE__, '/tmp/foobar')
77
- w.get('/tmp/foobar', 'foobar_from_piab_host.tmp')
78
-
79
- # output should be the same
80
- p sprintf('%s uname -a via run: %s', w.name, w.run('uname -a'))
81
- p sprintf('%s uname -a via output: %s', w.name, w.get_output())
82
-
83
- begin
84
- p sprintf('%s fizzy: %s', w.name, w.run('fizzy'))
85
- rescue => e
86
- p e
87
- end
88
-
89
- begin
90
- p sprintf('%s ls /dne/ %s', w.name, w.run('ls /dne/'))
91
- rescue => e
92
- p e
93
- end
94
-
95
- p sprintf('%s ls /dne/ expected exit code 2: %s', w.name, w.run('ls /dne/', 2))
96
-
97
- # tear the box down
98
- p 'destroying the box'
99
- w.destroy()
20
+ p 'status: %s' % w.status()
100
21
 
101
- p sprintf('%s status: %s', w.name, w.status())
102
- p sprintf('%s available via ssh: %s', w.name, w.is_available_via_ssh?())
22
+ p 'services:'
23
+ p w.get_services()
103
24
 
104
- # bring it back again
105
- p 'upping the box again'
106
- w.up()
25
+ p 'rebooting...'
26
+ w.restart(120)
107
27
 
108
- p sprintf('%s status: %s', w.name, w.status())
109
- p sprintf('%s available via ssh: %s', w.name, w.is_available_via_ssh?())
28
+ p 'status: %s' % w.status()
29
+ p 'uptime: %s' % w.run('uptime')
110
30
 
111
31
  end
112
32
 
113
- exit
33
+ exit
@@ -12,7 +12,7 @@ require 'rouster/vagrant'
12
12
  class Rouster
13
13
 
14
14
  # sporadically updated version number
15
- VERSION = 0.64
15
+ VERSION = 0.67
16
16
 
17
17
  # custom exceptions -- what else do we want them to include/do?
18
18
  class ArgumentError < StandardError; end # thrown by methods that take parameters from users
@@ -76,7 +76,9 @@ class Rouster
76
76
  @verbosity_logfile = 2 # this is kind of arbitrary, but won't actually be created unless opts[:logfile] is also passed
77
77
  end
78
78
 
79
- @ostype = nil
79
+ @ostype = nil
80
+ @osversion = nil
81
+
80
82
  @output = Array.new
81
83
  @cache = Hash.new
82
84
  @deltas = Hash.new
@@ -410,14 +412,8 @@ class Rouster
410
412
  elsif line.match(/Port (\d*?)$/)
411
413
  h[:ssh_port] = $1
412
414
  elsif line.match(/IdentityFile (.*?)$/)
413
- key = $1
414
- unless @sshkey.eql?(key)
415
- h[:identity_file] = key
416
- else
417
- @logger.info(sprintf('using specified key[%s] instead of discovered key[%s]', @sshkey, key))
418
- h[:identity_file] = @sshkey
419
- end
420
-
415
+ h[:identity_file] = $1
416
+ @logger.info(sprintf('vagrant specified key[%s] differs from provided[%s], will use both', @sshkey, h[:identity_file]))
421
417
  end
422
418
  end
423
419
 
@@ -477,7 +473,7 @@ class Rouster
477
473
  @ssh_info[:hostname],
478
474
  @ssh_info[:user],
479
475
  :port => @ssh_info[:ssh_port],
480
- :keys => [@sshkey],
476
+ :keys => [ @sshkey, @ssh_info[:identity_file] ].uniq, # try to use what the user specified first, but fall back to what vagrant says
481
477
  :paranoid => false
482
478
  )
483
479
  else
@@ -511,16 +507,9 @@ class Rouster
511
507
  return @ostype
512
508
  end
513
509
 
514
- files = {
515
- :ubuntu => '/etc/os-release', # debian too
516
- :solaris => '/etc/release',
517
- :rhel => ['/etc/os-release', '/etc/redhat-release'], # and centos
518
- :osx => '/System/Library/CoreServices/SystemVersion.plist',
519
- }
520
-
521
510
  res = :invalid
522
511
 
523
- files.each_pair do |os, f|
512
+ Rouster.os_files.each_pair do |os, f|
524
513
  [ f ].flatten.each do |candidate|
525
514
  if self.is_file?(candidate)
526
515
  next if candidate.eql?('/etc/os-release') and ! self.is_in_file?(candidate, os.to_s, 'i') # CentOS detection
@@ -531,12 +520,48 @@ class Rouster
531
520
  break unless res.eql?(:invalid)
532
521
  end
533
522
 
534
- @logger.error(sprintf('unable to determine OS, looking for[%s]', files)) if res.eql?(:invalid)
523
+ @logger.error(sprintf('unable to determine OS, looking for[%s]', Rouster.os_files)) if res.eql?(:invalid)
535
524
 
536
525
  @ostype = res
537
526
  res
538
527
  end
539
528
 
529
+ ##
530
+ # os_version
531
+ #
532
+ #
533
+ def os_version(os_type)
534
+ return @osversion if @osversion
535
+
536
+ res = :invalid
537
+
538
+ [ Rouster.os_files[os_type] ].flatten.each do |candidate|
539
+ if self.is_file?(candidate)
540
+ next if candidate.eql?('/etc/os-release') and ! self.is_in_file?(candidate, os_type.to_s, 'i') # CentOS detection
541
+ contents = self.run(sprintf('cat %s', candidate))
542
+ if os_type.eql?(:ubuntu)
543
+ version = $1 if contents.match(/.*VERSION\="(\d+\.\d+).*"/) # VERSION="13.10, Saucy Salamander"
544
+ res = version unless version.nil?
545
+ elsif os_type.eql?(:rhel)
546
+ version = $1 if contents.match(/.*VERSION\="(\d+)"/) # VERSION="7 (Core)"
547
+ version = $1 if version.nil? and contents.match(/.*(\d+.\d+)/) # CentOS release 6.4 (Final)
548
+ res = version unless version.nil?
549
+ elsif os_type.eql?(:osx)
550
+ version = $1 if contents.match(/<key>ProductVersion<\/key>.*<string>(.*)<\/string>/m) # <key>ProductVersion</key>\n <string>10.12.1</string>
551
+ res = version unless version.nil?
552
+ end
553
+
554
+ end
555
+ break unless res.eql?(:invalid)
556
+ end
557
+
558
+ @logger.error(sprintf('unable to determine OS version, looking for[%s]', Rouster.os_files[os_type])) if res.eql?(:invalid)
559
+
560
+ @osversion = res
561
+
562
+ res
563
+ end
564
+
540
565
  ##
541
566
  # get
542
567
  #
@@ -620,7 +645,7 @@ class Rouster
620
645
  #
621
646
  # parameters
622
647
  # * [wait] - number of seconds to wait until is_available_via_ssh?() returns true before assuming failure
623
- def restart(wait=nil)
648
+ def restart(wait=nil, expected_exitcodes = [0])
624
649
  @logger.debug('restart()')
625
650
 
626
651
  if self.is_passthrough? and self.passthrough[:type].eql?(:local)
@@ -630,11 +655,15 @@ class Rouster
630
655
 
631
656
  case os_type
632
657
  when :osx
633
- self.run('shutdown -r now')
634
- when :rhel, :ubuntu, :debian
635
- self.run('/sbin/shutdown -rf now')
658
+ self.run('shutdown -r now', expected_exitcodes)
659
+ when :rhel, :ubuntu
660
+ if os_type.eql?(:rhel) and os_version(os_type).match(/7/)
661
+ self.run('shutdown --halt --reboot now', expected_exitcodes << 256)
662
+ else
663
+ self.run('shutdown -rf now')
664
+ end
636
665
  when :solaris
637
- self.run('shutdown -y -i5 -g0')
666
+ self.run('shutdown -y -i5 -g0', expected_exitcodes)
638
667
  else
639
668
  raise InternalError.new(sprintf('unsupported OS[%s]', @ostype))
640
669
  end
@@ -783,6 +812,15 @@ class Rouster
783
812
  nil
784
813
  end
785
814
 
815
+ def self.os_files
816
+ {
817
+ :ubuntu => '/etc/os-release', # debian too
818
+ :solaris => '/etc/release',
819
+ :rhel => ['/etc/os-release', '/etc/redhat-release'], # and centos
820
+ :osx => '/System/Library/CoreServices/SystemVersion.plist',
821
+ }
822
+ end
823
+
786
824
  end
787
825
 
788
826
  class Object
@@ -473,7 +473,8 @@ class Rouster
473
473
  :upstart => 'initctl list',
474
474
  },
475
475
  :rhel => {
476
- :systemv => '/sbin/service --status-all',
476
+ :systemd => 'systemctl list-units --type=service --no-pager',
477
+ :systemv => 'service --status-all',
477
478
  :upstart => 'initctl list',
478
479
  },
479
480
 
@@ -493,6 +494,11 @@ class Rouster
493
494
  raise InternalError.new(sprintf('unable to get service information from VM operating system[%s]', os)) if provider.eql?(:invalid)
494
495
  raise ArgumentError.new(sprintf('unable to find command provider[%s] for [%s]', provider, os)) if commands[os][provider].nil?
495
496
 
497
+ unless seed or self.is_in_path?(commands[os][provider].split(' ').first)
498
+ @logger.info(sprintf('skipping provider[%s], not in $PATH[%s]', provider, commands[os][provider]))
499
+ next
500
+ end
501
+
496
502
  @logger.info(sprintf('get_services using provider [%s] on [%s]', provider, os))
497
503
 
498
504
  # TODO while this is true, what if self.user is 'root'.. -- the problem is we don't have self.user, and we store this data differently depending on self.passthrough?
@@ -665,6 +671,26 @@ class Rouster
665
671
 
666
672
  res[service] = mode unless res.has_key?(service)
667
673
 
674
+ elsif provider.eql?(:systemd)
675
+ # UNIT LOAD ACTIVE SUB DESCRIPTION
676
+ # nfs-utils.service loaded inactive dead NFS server and client services
677
+ # crond.service loaded active running Command Scheduler
678
+
679
+ if line.match(/^\W*(.*?)\.service\s+(?:.*?)\s+(.*?)\s+(.*?)\s+(?:.*?)$/) # 5 space separated characters
680
+ service = $1
681
+ active = $2
682
+ sub = $3
683
+
684
+ if humanize
685
+ mode = sub.match('running') ? 'running' : 'stopped'
686
+ mode = 'unsure' unless mode.eql?('stopped') or mode.eql?('running')
687
+ end
688
+
689
+ res[service] = mode
690
+ else
691
+ # not logging here, there is a bunch of garbage output at the end of the output that we can't seem to suppress
692
+ next
693
+ end
668
694
 
669
695
  end
670
696
 
@@ -37,15 +37,25 @@ class Rouster
37
37
  self.connect_ssh_tunnel
38
38
  else
39
39
  server = @nova.servers.create(:name => @name, :flavor_ref => @passthrough[:flavor_ref],
40
- :image_ref => @passthrough[:image_ref], :key_name => @passthrough[:keypair])
40
+ :image_ref => @passthrough[:image_ref], :key_name => @passthrough[:keypair], :user_data => @passthrough[:user_data])
41
41
  server.wait_for { ready? }
42
42
  @instance_data = server
43
- self.passthrough[:host] = server.addresses["NextGen"][0]["addr"]
43
+ if defined?(self.addresses['NextGen'][0]['addr'])
44
+ self.passthrough[:host] = self.addresses['NextGen'][0]['addr']
45
+ else
46
+ server.addresses.each_key do |address_key|
47
+ if defined?(server.addresses[address_key])
48
+ self.passthrough[:host] = server.addresses[address_key][0]['addr']
49
+ end
50
+ end
51
+ end
44
52
  self.passthrough[:instance] = self.ostack_get_instance_id
53
+ @logger.debug(sprintf('Connecting to running instance [%s] while calling ostack_up()', self.passthrough[:instance]))
54
+ self.connect_ssh_tunnel
45
55
  end
46
56
  self.passthrough[:instance]
47
57
  end
48
-
58
+
49
59
  def ostack_get_ip()
50
60
  self.passthrough[:host]
51
61
  end
@@ -7,14 +7,6 @@ require 'test/unit'
7
7
 
8
8
  class TestValidateFileFunctional < Test::Unit::TestCase
9
9
 
10
- # TODO this should probably be further abstracted into the implementation, but this is fine for now
11
- FLAG_FILES = {
12
- :ubuntu => '/etc/os-release', # debian too
13
- :solaris => '/etc/release',
14
- :rhel => '/etc/redhat-release', # centos too
15
- :osx => '/System/Library/CoreServices/SystemVersion.plist',
16
- }
17
-
18
10
  def setup
19
11
  # expose private methods
20
12
  Rouster.send(:public, *Rouster.private_instance_methods)
@@ -25,10 +17,12 @@ class TestValidateFileFunctional < Test::Unit::TestCase
25
17
 
26
18
  def teardown
27
19
  # put the flag file back in place
28
- FLAG_FILES.each_pair do |_os, ff|
29
- bkup = sprintf('%s.bkup', ff)
30
- if @app.is_file?(bkup)
31
- @app.run(sprintf('mv %s %s', bkup, ff))
20
+ Rouster.os_files.each_pair do |_os, ff|
21
+ [ ff ].flatten.each do |f|
22
+ bkup = sprintf('%s.bkup', f)
23
+ if @app.is_file?(bkup)
24
+ @app.run(sprintf('mv %s %s', bkup, f))
25
+ end
32
26
  end
33
27
  end
34
28
  end
@@ -39,6 +33,10 @@ class TestValidateFileFunctional < Test::Unit::TestCase
39
33
  assert_not_nil(type, sprintf('unable to determine vm[%s] OS', @app))
40
34
  assert_not_equal(:invalid, type)
41
35
 
36
+ version = @app.os_version(type)
37
+ assert_not_nil(version, sprintf('unable to determine vm[%s] OS version', @app))
38
+ assert_not_equal(:invalid, version)
39
+
42
40
  assert_nothing_raised do
43
41
  @app.get_services
44
42
  end
@@ -47,9 +45,11 @@ class TestValidateFileFunctional < Test::Unit::TestCase
47
45
 
48
46
  def test_unhappy_path
49
47
  # move the flag file out of the way
50
- FLAG_FILES.each_pair do |_os, ff|
51
- if @app.is_file?(ff)
52
- @app.run(sprintf('mv %s %s.bkup', ff, ff))
48
+ Rouster.os_files.each_pair do |_os, ff|
49
+ [ ff ].flatten.each do |f|
50
+ if @app.is_file?(ff)
51
+ @app.run(sprintf('mv %s %s.bkup', f, f))
52
+ end
53
53
  end
54
54
  end
55
55
 
@@ -58,7 +58,7 @@ class TestValidateFileFunctional < Test::Unit::TestCase
58
58
  assert_equal(:invalid, type, sprintf('got wrong value for unmarked OS[%s]', type))
59
59
 
60
60
  e = assert_raise do
61
- @app.get_services
61
+ @app.get_services
62
62
  end
63
63
 
64
64
  assert_equal(Rouster::InternalError, e.class, sprintf('wrong exception raised[%s] [%s]', e.class, e.message))
@@ -0,0 +1,46 @@
1
+ UNIT LOAD ACTIVE SUB DESCRIPTION
2
+ crond.service loaded active running Command Scheduler
3
+ dbus.service loaded active running D-Bus System Message Bus
4
+ getty@tty1.service loaded active running Getty on tty1
5
+ gssproxy.service loaded active running GSSAPI Proxy Daemon
6
+ ● kdump.service loaded failed failed Crash recovery kernel arming
7
+ kmod-static-nodes.service loaded active exited Create list of required static device nodes for the current kernel
8
+ lldpad.service loaded active running Link Layer Discovery Protocol Agent Daemon.
9
+ mdmonitor.service loaded active running Software RAID monitoring and management
10
+ network.service loaded active running LSB: Bring up/down networking
11
+ nfs-config.service loaded active exited Preprocess NFS configuration
12
+ ntpd.service loaded active running Network Time Service
13
+ postfix.service loaded active running Postfix Mail Transport Agent
14
+ rhel-dmesg.service loaded active exited Dump dmesg to /var/log/dmesg
15
+ rhel-import-state.service loaded active exited Import network configuration from initramfs
16
+ rhel-readonly.service loaded active exited Configure read-only root support
17
+ rsyslog.service loaded active running System Logging Service
18
+ sshd.service loaded active running OpenSSH server daemon
19
+ systemd-fsck-root.service loaded active exited File System Check on Root Device
20
+ systemd-fsck@dev-disk-by\x2dlabel-boot.service loaded active exited File System Check on /dev/disk/by-label/boot
21
+ systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
22
+ systemd-journald.service loaded active running Journal Service
23
+ systemd-logind.service loaded active running Login Service
24
+ systemd-random-seed.service loaded active exited Load/Save Random Seed
25
+ systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
26
+ systemd-sysctl.service loaded active exited Apply Kernel Variables
27
+ systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
28
+ systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories
29
+ systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
30
+ systemd-udevd.service loaded active running udev Kernel Device Manager
31
+ systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdown
32
+ systemd-user-sessions.service loaded active exited Permit User Sessions
33
+ systemd-vconsole-setup.service loaded active exited Setup Virtual Console
34
+ tuned.service loaded active running Dynamic System Tuning Daemon
35
+ vboxadd-service.service loaded active running LSB: VirtualBox Additions service
36
+ vboxadd-x11.service loaded active exited LSB: VirtualBox Linux Additions kernel modules
37
+ vboxadd.service loaded active exited LSB: VirtualBox Linux Additions kernel modules
38
+
39
+ LOAD = Reflects whether the unit definition was properly loaded.
40
+ ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
41
+ SUB = The low-level unit activation state, values depend on unit type.
42
+
43
+ 36 loaded units listed. Pass --all to see loaded but inactive units, too.
44
+ To show all installed unit files use 'systemctl list-unit-files'.
45
+
46
+
@@ -42,6 +42,31 @@ class TestUnitGetPackages < Test::Unit::TestCase
42
42
 
43
43
  end
44
44
 
45
+ def test_rhel_systemd
46
+ @app.instance_variable_set(:@ostype, :rhel)
47
+ @app.instance_variable_set(:@osversion, '7')
48
+ services = {}
49
+
50
+ raw = File.read(sprintf('%s/../../../test/unit/testing/resources/rhel-systemd', File.dirname(File.expand_path(__FILE__))))
51
+
52
+ assert_nothing_raised do
53
+ services = @app.get_services(false, true, :systemd, raw)
54
+ end
55
+
56
+ expected = {
57
+ 'kdump' => 'stopped', # ● kdump.service loaded failed failed Crash recovery kernel arming
58
+ 'rhel-dmesg' => 'stopped', # rhel-dmesg.service loaded active exited Dump dmesg to /var/log/dmesg
59
+ 'sshd' => 'running', # sshd.service loaded active running OpenSSH server daemon
60
+ 'systemd-journal-flush'=> 'stopped', # this is a test for output without leading spaces
61
+ }
62
+
63
+ expected.each_pair do |service,state|
64
+ assert(services.has_key?(service), "service[#{service}]")
65
+ assert_equal(services[service], state, "service[#{service}] state[#{state}]")
66
+ end
67
+
68
+ end
69
+
45
70
  def test_rhel_upstart
46
71
  @app.instance_variable_set(:@ostype, :rhel)
47
72
  services = {}
@@ -134,8 +159,8 @@ class TestUnitGetPackages < Test::Unit::TestCase
134
159
  end
135
160
 
136
161
  expected = {
137
- 'com.bigfix.BESAgent' => 'running', # 100 - com.bigfix.BESAgent
138
- 'com.trendmicro.mpm.icore.agent' => 'stopped', # - 0 com.trendmicro.mpm.icore.agent
162
+ 'com.bigfix.BESAgent' => 'running', # 100 - com.bigfix.BESAgent
163
+ 'com.trendmicro.mpm.icore.agent' => 'stopped', # - 0 com.trendmicro.mpm.icore.agent
139
164
  }
140
165
 
141
166
  expected.each_pair do |service,state|
@@ -150,3 +175,4 @@ class TestUnitGetPackages < Test::Unit::TestCase
150
175
  end
151
176
 
152
177
  end
178
+
@@ -18,6 +18,11 @@ class TestMeetsConstraint < Test::Unit::TestCase
18
18
  @app.facts = fake_facts
19
19
  end
20
20
 
21
+ def test_multiple_positive
22
+ assert(@app.meets_constraint?([['is_virtual', 'true'], ['timezone', 'PDT',]]))
23
+ end
24
+
25
+
21
26
  def test_positive
22
27
 
23
28
  assert(@app.meets_constraint?('is_virtual', 'true'))
@@ -52,4 +57,4 @@ class TestMeetsConstraint < Test::Unit::TestCase
52
57
  # noop
53
58
  end
54
59
 
55
- end
60
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rouster
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.64'
4
+ version: '0.67'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conor Horan-Kates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-12 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -183,6 +183,7 @@ files:
183
183
  - test/unit/test_parse_ls_string.rb
184
184
  - test/unit/test_traverse_up.rb
185
185
  - test/unit/testing/resources/osx-launchd
186
+ - test/unit/testing/resources/rhel-systemd
186
187
  - test/unit/testing/resources/rhel-systemv
187
188
  - test/unit/testing/resources/rhel-upstart
188
189
  - test/unit/testing/test_get_services.rb
@@ -219,3 +220,4 @@ signing_key:
219
220
  specification_version: 4
220
221
  summary: Rouster is an abstraction layer for Vagrant
221
222
  test_files: []
223
+ has_rdoc: