beaker 0.0.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.travis.yml +8 -0
- data/README.md +6 -6
- data/beaker.gemspec +6 -2
- data/lib/beaker.rb +1 -1
- data/lib/beaker/answers.rb +34 -7
- data/lib/beaker/answers/version20.rb +124 -0
- data/lib/beaker/answers/version28.rb +21 -0
- data/lib/beaker/answers/version30.rb +24 -5
- data/lib/beaker/cli.rb +55 -41
- data/lib/beaker/command.rb +2 -2
- data/lib/beaker/dsl/helpers.rb +320 -106
- data/lib/beaker/dsl/install_utils.rb +202 -81
- data/lib/beaker/dsl/roles.rb +40 -0
- data/lib/beaker/host.rb +28 -20
- data/lib/beaker/host/unix.rb +7 -4
- data/lib/beaker/host/unix/pkg.rb +42 -12
- data/lib/beaker/host/windows.rb +9 -5
- data/lib/beaker/host/windows/group.rb +1 -1
- data/lib/beaker/host/windows/pkg.rb +41 -8
- data/lib/beaker/hypervisor.rb +23 -10
- data/lib/beaker/hypervisor/aixer.rb +15 -19
- data/lib/beaker/hypervisor/blimper.rb +71 -72
- data/lib/beaker/hypervisor/fusion.rb +11 -10
- data/lib/beaker/hypervisor/solaris.rb +17 -23
- data/lib/beaker/hypervisor/vagrant.rb +27 -12
- data/lib/beaker/hypervisor/vcloud.rb +154 -138
- data/lib/beaker/hypervisor/vcloud_pooled.rb +97 -0
- data/lib/beaker/hypervisor/vsphere.rb +8 -5
- data/lib/beaker/hypervisor/vsphere_helper.rb +43 -33
- data/lib/beaker/network_manager.rb +16 -12
- data/lib/beaker/options/command_line_parser.rb +199 -0
- data/lib/beaker/options/hosts_file_parser.rb +39 -0
- data/lib/beaker/options/options_file_parser.rb +45 -0
- data/lib/beaker/options/options_hash.rb +294 -0
- data/lib/beaker/options/parser.rb +288 -0
- data/lib/beaker/options/pe_version_scraper.rb +35 -0
- data/lib/beaker/options/presets.rb +70 -0
- data/lib/beaker/shared.rb +2 -1
- data/lib/beaker/shared/host_handler.rb +7 -2
- data/lib/beaker/shared/repetition.rb +1 -0
- data/lib/beaker/shared/timed.rb +14 -0
- data/lib/beaker/test_case.rb +2 -38
- data/lib/beaker/test_suite.rb +11 -25
- data/lib/beaker/utils/repo_control.rb +6 -8
- data/lib/beaker/utils/setup_helper.rb +9 -20
- data/spec/beaker/answers_spec.rb +109 -0
- data/spec/beaker/command_spec.rb +2 -2
- data/spec/beaker/dsl/assertions_spec.rb +1 -3
- data/spec/beaker/dsl/helpers_spec.rb +519 -84
- data/spec/beaker/dsl/install_utils_spec.rb +265 -16
- data/spec/beaker/dsl/roles_spec.rb +31 -10
- data/spec/beaker/host/windows/group_spec.rb +55 -0
- data/spec/beaker/host_spec.rb +130 -40
- data/spec/beaker/hypervisor/aixer_spec.rb +34 -0
- data/spec/beaker/hypervisor/blimper_spec.rb +77 -0
- data/spec/beaker/hypervisor/fusion_spec.rb +26 -0
- data/spec/beaker/hypervisor/hypervisor_spec.rb +66 -0
- data/spec/beaker/hypervisor/solaris_spec.rb +39 -0
- data/spec/beaker/hypervisor/vagrant_spec.rb +105 -0
- data/spec/beaker/hypervisor/vcloud_pooled_spec.rb +60 -0
- data/spec/beaker/hypervisor/vcloud_spec.rb +70 -0
- data/spec/beaker/hypervisor/vsphere_helper_spec.rb +162 -0
- data/spec/beaker/hypervisor/vsphere_spec.rb +76 -0
- data/spec/beaker/options/command_line_parser_spec.rb +25 -0
- data/spec/beaker/options/data/LATEST +1 -0
- data/spec/beaker/options/data/badyaml.cfg +21 -0
- data/spec/beaker/options/data/hosts.cfg +21 -0
- data/spec/beaker/options/data/opts.txt +6 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -0
- data/spec/beaker/options/options_file_parser_spec.rb +23 -0
- data/spec/beaker/options/options_hash_spec.rb +111 -0
- data/spec/beaker/options/parser_spec.rb +172 -0
- data/spec/beaker/options/pe_version_scaper_spec.rb +15 -0
- data/spec/beaker/options/presets_spec.rb +24 -0
- data/spec/beaker/puppet_command_spec.rb +54 -21
- data/spec/beaker/shared/error_handler_spec.rb +40 -0
- data/spec/beaker/shared/host_handler_spec.rb +104 -0
- data/spec/beaker/shared/repetition_spec.rb +72 -0
- data/spec/beaker/test_suite_spec.rb +3 -16
- data/spec/beaker/utils/ntp_control_spec.rb +42 -0
- data/spec/beaker/utils/repo_control_spec.rb +168 -0
- data/spec/beaker/utils/setup_helper_spec.rb +82 -0
- data/spec/beaker/utils/validator_spec.rb +58 -0
- data/spec/helpers.rb +97 -0
- data/spec/matchers.rb +39 -0
- data/spec/mock_blimpy.rb +48 -0
- data/spec/mock_fission.rb +60 -0
- data/spec/mock_vsphere.rb +310 -0
- data/spec/mock_vsphere_helper.rb +183 -0
- data/spec/mocks.rb +83 -0
- data/spec/spec_helper.rb +8 -1
- metadata +106 -13
- data/beaker.rb +0 -10
- data/lib/beaker/options_parsing.rb +0 -323
- data/lib/beaker/test_config.rb +0 -148
- data/spec/beaker/options_parsing_spec.rb +0 -37
- data/spec/mocks_and_helpers.rb +0 -34
data/spec/helpers.rb
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
module TestFileHelpers
|
|
2
|
+
def create_files file_array
|
|
3
|
+
file_array.each do |f|
|
|
4
|
+
FileUtils.mkdir_p File.dirname(f)
|
|
5
|
+
FileUtils.touch f
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def fog_file_contents
|
|
10
|
+
{ :default => { :aws_access_key_id => "IMANACCESSKEY",
|
|
11
|
+
:aws_secret_access_key => "supersekritkey",
|
|
12
|
+
:aix_hypervisor_server => "aix_hypervisor.labs.net",
|
|
13
|
+
:aix_hypervisor_username => "aixer",
|
|
14
|
+
:aix_hypervisor_keyfile => "/Users/user/.ssh/id_rsa-acceptance",
|
|
15
|
+
:solaris_hypervisor_server => "solaris_hypervisor.labs.net",
|
|
16
|
+
:solaris_hypervisor_username => "harness",
|
|
17
|
+
:solaris_hypervisor_keyfile => "/Users/user/.ssh/id_rsa-old.private",
|
|
18
|
+
:solaris_hypervisor_vmpath => "rpoooool/zs",
|
|
19
|
+
:solaris_hypervisor_snappaths => ["rpoooool/USER/z0"],
|
|
20
|
+
:vsphere_server => "vsphere.labs.net",
|
|
21
|
+
:vsphere_username => "vsphere@labs.com",
|
|
22
|
+
:vsphere_password => "supersekritpassword"} }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
module HostHelpers
|
|
28
|
+
HOST_DEFAULTS = { :platform => 'unix',
|
|
29
|
+
:snapshot => 'pe',
|
|
30
|
+
:box => 'box_name',
|
|
31
|
+
:roles => ['agent'],
|
|
32
|
+
:snapshot => 'snap',
|
|
33
|
+
:ip => 'default.ip.address',
|
|
34
|
+
:box => 'default_box_name',
|
|
35
|
+
:box_url => 'http://default.box.url',
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
HOST_NAME = "vm%d"
|
|
39
|
+
HOST_SNAPSHOT = "snapshot%d"
|
|
40
|
+
HOST_IP = "ip.address.for.%s"
|
|
41
|
+
HOST_BOX = "%s_of_my_box"
|
|
42
|
+
HOST_BOX_URL = "http://address.for.my.box.%s"
|
|
43
|
+
HOST_TEMPLATE = "%s_has_a_template"
|
|
44
|
+
|
|
45
|
+
def logger
|
|
46
|
+
double( 'logger' ).as_null_object
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def make_opts
|
|
50
|
+
Beaker::Options::Presets.presets.merge( { :logger => logger,
|
|
51
|
+
:host_config => 'sample.config',
|
|
52
|
+
:type => :foss,
|
|
53
|
+
:pooling_api => 'http://vcloud.delivery.puppetlabs.net/',
|
|
54
|
+
:datastore => 'instance0',
|
|
55
|
+
:folder => 'Delivery/Quality Assurance/Staging/Dynamic',
|
|
56
|
+
:resourcepool => 'delivery/Quality Assurance/Staging/Dynamic' } )
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def generate_result (name, opts )
|
|
60
|
+
result = double( 'result' )
|
|
61
|
+
stdout = opts.has_key?(:stdout) ? opts[:stdout] : name
|
|
62
|
+
stderr = opts.has_key?(:stderr) ? opts[:stderr] : name
|
|
63
|
+
exit_code = opts.has_key?(:exit_code) ? opts[:exit_code] : 0
|
|
64
|
+
result.stub( :stdout ).and_return( stdout )
|
|
65
|
+
result.stub( :stderr ).and_return( stderr )
|
|
66
|
+
result.stub( :exit_code ).and_return( exit_code )
|
|
67
|
+
result
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def make_host_opts name, opts
|
|
71
|
+
make_opts.merge( { 'HOSTS' => { name => opts } } ).merge( opts )
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def make_host name, opts
|
|
75
|
+
opts = HOST_DEFAULTS.merge(opts)
|
|
76
|
+
|
|
77
|
+
host = Beaker::Host.create( name, make_host_opts(name, opts) )
|
|
78
|
+
|
|
79
|
+
host.stub( :exec ).and_return( generate_result( name, opts ) )
|
|
80
|
+
host
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def make_hosts preset_opts = {}, amt = 3
|
|
84
|
+
hosts = []
|
|
85
|
+
(1..amt).each do |num|
|
|
86
|
+
name = HOST_NAME % num
|
|
87
|
+
opts = { :snapshot => HOST_SNAPSHOT % num,
|
|
88
|
+
:ip => HOST_IP % name,
|
|
89
|
+
:template => HOST_TEMPLATE % name,
|
|
90
|
+
:box => HOST_BOX % name,
|
|
91
|
+
:box_url => HOST_BOX_URL % name }.merge( preset_opts )
|
|
92
|
+
hosts << make_host(name, opts)
|
|
93
|
+
end
|
|
94
|
+
hosts
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
end
|
data/spec/matchers.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
RSpec::Matchers.define :execute_commands_matching do |pattern|
|
|
2
|
+
|
|
3
|
+
match do |actual|
|
|
4
|
+
raise(RuntimeError, "Expected #{actual} to be a FakeHost") unless actual.kind_of?(FakeHost)
|
|
5
|
+
@found_count = actual.command_strings.grep(pattern).size
|
|
6
|
+
@times.nil? ?
|
|
7
|
+
@found_count > 0 :
|
|
8
|
+
@found_count == @times
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
chain :exactly do |times|
|
|
12
|
+
@times = times
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
chain :times do
|
|
16
|
+
# clarity only
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
chain :once do
|
|
20
|
+
@times = 1
|
|
21
|
+
# clarity only
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def message(actual, pattern, times, found_count)
|
|
25
|
+
msg = times == 1 ?
|
|
26
|
+
"#{pattern} once" :
|
|
27
|
+
"#{pattern} #{times} times"
|
|
28
|
+
msg += " but instead found a count of #{found_count}" if found_count != times
|
|
29
|
+
msg + " in:\n #{actual.command_strings.pretty_inspect}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
failure_message_for_should do |actual|
|
|
33
|
+
"Expected to find #{message(actual, pattern, @times, @found_count)}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
failure_message_for_should_not do |actual|
|
|
37
|
+
"Unexpectedly found #{message(actual, pattern, @times, @found_count)}"
|
|
38
|
+
end
|
|
39
|
+
end
|
data/spec/mock_blimpy.rb
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
class MockShip
|
|
2
|
+
attr_accessor :name, :ports, :image_id, :flavor, :region, :username, :dns
|
|
3
|
+
|
|
4
|
+
def initialize
|
|
5
|
+
@dns = "my.ip.address"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def wait_for_sshd
|
|
9
|
+
@dns = "#{@name}.my.ip"
|
|
10
|
+
return true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class MockFleet
|
|
16
|
+
attr_accessor :ships
|
|
17
|
+
@@attempts = 0
|
|
18
|
+
|
|
19
|
+
def initialize
|
|
20
|
+
@ships = []
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def add type
|
|
24
|
+
@ships << MockShip.new
|
|
25
|
+
yield(@ships[-1])
|
|
26
|
+
@ships[-1]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def start
|
|
30
|
+
if @@attempts < 1
|
|
31
|
+
@@attempts += 1
|
|
32
|
+
raise Fog::Errors::Error
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def destroy
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class MockBlimpy
|
|
42
|
+
@@fleet = nil
|
|
43
|
+
def self.fleet
|
|
44
|
+
yield(@@fleet = MockFleet.new)
|
|
45
|
+
@@fleet
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
class Response
|
|
2
|
+
attr_accessor :code, :message, :data
|
|
3
|
+
def initialize(code = 0, message = '', data = nil)
|
|
4
|
+
@code = code
|
|
5
|
+
@message = message
|
|
6
|
+
@data = data
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class MockFissionVM
|
|
11
|
+
attr_accessor :name
|
|
12
|
+
@@snaps = []
|
|
13
|
+
def initialize name
|
|
14
|
+
@name = name
|
|
15
|
+
@running = true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.set_snapshots snaps
|
|
19
|
+
@@snaps = snaps
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def snapshots
|
|
23
|
+
Response.new(0, '', @@snaps)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def revert_to_snapshot name
|
|
27
|
+
@running = false
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def running?
|
|
31
|
+
Response.new(0, '', @running)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def start opt
|
|
35
|
+
@running = true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def exists?
|
|
39
|
+
true
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class MockFission
|
|
44
|
+
@@vms = []
|
|
45
|
+
def self.presets hosts
|
|
46
|
+
snaps = []
|
|
47
|
+
hosts.each do |host|
|
|
48
|
+
@@vms << MockFissionVM.new( host.name )
|
|
49
|
+
snaps << host[ :snapshot ]
|
|
50
|
+
end
|
|
51
|
+
MockFissionVM.set_snapshots(snaps)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.all
|
|
55
|
+
Response.new(0, '', @@vms)
|
|
56
|
+
end
|
|
57
|
+
def self.new name
|
|
58
|
+
MockFissionVM.new(name)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
class MockRbVmomiSnapshot
|
|
2
|
+
attr_accessor :name
|
|
3
|
+
attr_accessor :rootSnapshotList
|
|
4
|
+
attr_accessor :childSnapshotList
|
|
5
|
+
|
|
6
|
+
def initialize
|
|
7
|
+
@name = nil
|
|
8
|
+
@rootSnapshotList = []
|
|
9
|
+
@childSnapshotList = []
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def print_nested_array arg
|
|
13
|
+
str = '[ '
|
|
14
|
+
arg.each do |arry|
|
|
15
|
+
if arry.is_a?(Array)
|
|
16
|
+
str += print_nested_array( arry )
|
|
17
|
+
elsif arry.is_a?(MockRbVmomiSnapshot)
|
|
18
|
+
str += arry.to_s + ", "
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
str + ' ]'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def to_s
|
|
25
|
+
"Snapshot(name: #{@name}, rootSnapshotlist: #{print_nested_array(@rootSnapshotList)}, childSnapshotList: #{print_nested_array(@childSnapshotList)})"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def snapshot
|
|
29
|
+
self
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class MockRbVmomiVM
|
|
35
|
+
attr_accessor :snapshot, :name, :state
|
|
36
|
+
|
|
37
|
+
def info
|
|
38
|
+
self
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def process_snaphash snaphash
|
|
42
|
+
shotlist = []
|
|
43
|
+
snaphash.each do | name, subsnaps |
|
|
44
|
+
new_snap = MockRbVmomiSnapshot.new
|
|
45
|
+
new_snap.name = name
|
|
46
|
+
if subsnaps.is_a?(Hash)
|
|
47
|
+
new_snap.childSnapshotList = process_snaphash( subsnaps )
|
|
48
|
+
end
|
|
49
|
+
shotlist << new_snap
|
|
50
|
+
end
|
|
51
|
+
shotlist
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def get_snapshot name, snaplist = @snapshot.rootSnapshotList
|
|
55
|
+
snapshot = nil
|
|
56
|
+
snaplist.each do |snap|
|
|
57
|
+
if snap.is_a?(Array)
|
|
58
|
+
snapshot = get_snapshot(snap, name)
|
|
59
|
+
elsif snap.name == name
|
|
60
|
+
snapshot = snap.snapshot
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
snapshot
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def initialize name, snaphash
|
|
67
|
+
@name = name
|
|
68
|
+
@snapshot = MockRbVmomiSnapshot.new
|
|
69
|
+
@snapshot.name = name
|
|
70
|
+
@snapshot.rootSnapshotList = process_snaphash( snaphash )
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
class MockRbVmomiConnection
|
|
76
|
+
|
|
77
|
+
class CustomizationSpecManager
|
|
78
|
+
|
|
79
|
+
class CustomizationSpec
|
|
80
|
+
def spec
|
|
81
|
+
true
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def initialize
|
|
86
|
+
@customizationspec = CustomizationSpec.new
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def GetCustomizationSpec arg
|
|
90
|
+
@customizationspec
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class PropertyCollector
|
|
96
|
+
class Result
|
|
97
|
+
def initialize(name, object)
|
|
98
|
+
@name = name
|
|
99
|
+
@object = object
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def val
|
|
103
|
+
@name
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def obj
|
|
107
|
+
@object
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def propSet
|
|
111
|
+
[self]
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
class ResultContainer
|
|
117
|
+
attr_accessor :token
|
|
118
|
+
|
|
119
|
+
def initialize
|
|
120
|
+
@results = []
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def objects
|
|
124
|
+
@results
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def add_object obj
|
|
128
|
+
@results << obj
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def initialize
|
|
134
|
+
@results = ResultContainer.new
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def RetrievePropertiesEx hash
|
|
139
|
+
@results.token = true
|
|
140
|
+
@results
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def ContinueRetrievePropertiesEx token
|
|
144
|
+
@results.token = false
|
|
145
|
+
@results
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def add_result name, object
|
|
149
|
+
@results.add_object( Result.new(name, object) )
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def WaitForUpdates arg
|
|
153
|
+
result = OpenStruct.new
|
|
154
|
+
result.version = 'version'
|
|
155
|
+
result
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def CreateFilter arg
|
|
159
|
+
filter = OpenStruct.new
|
|
160
|
+
filter.DestroyPropertyFilter = true
|
|
161
|
+
filter
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
class ServiceInstance
|
|
167
|
+
class Datacenter
|
|
168
|
+
attr_accessor :vmFolder
|
|
169
|
+
attr_accessor :hostFolder
|
|
170
|
+
|
|
171
|
+
def initialize
|
|
172
|
+
@vmFolder = MockRbVmomi::VIM::Folder.new
|
|
173
|
+
@vmFolder.name = "/root"
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def find_datastore arg
|
|
177
|
+
true
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def initialize
|
|
183
|
+
@datacenter = Datacenter.new
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def find_datacenter
|
|
187
|
+
@datacenter
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
class ServiceManager
|
|
193
|
+
class ViewManager
|
|
194
|
+
|
|
195
|
+
def CreateContainerView hash
|
|
196
|
+
@view = hash
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def initialize
|
|
202
|
+
@customizationspecmanager = CustomizationSpecManager.new
|
|
203
|
+
@viewmanager = ViewManager.new
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def customizationSpecManager
|
|
207
|
+
@customizationspecmanager
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def viewManager
|
|
211
|
+
@viewmanager
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def rootFolder
|
|
215
|
+
"/root"
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def initialize opts
|
|
221
|
+
@host = opts[ :host ]
|
|
222
|
+
@user = opts[ :user ]
|
|
223
|
+
@password = opts[ :password ]
|
|
224
|
+
@insecure = opts[ :insecure ]
|
|
225
|
+
@serviceinstance = ServiceInstance.new
|
|
226
|
+
@servicemanager = ServiceManager.new
|
|
227
|
+
@propertycollector = PropertyCollector.new
|
|
228
|
+
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def serviceInstance
|
|
232
|
+
@serviceinstance
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def serviceContent
|
|
236
|
+
@servicemanager
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def propertyCollector
|
|
240
|
+
@propertycollector
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
def set_info vms
|
|
244
|
+
vms.each do |vm|
|
|
245
|
+
@propertycollector.add_result(vm.name, vm)
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
class MockRbVmomi
|
|
252
|
+
|
|
253
|
+
class VIM
|
|
254
|
+
class Folder
|
|
255
|
+
attr_accessor :name
|
|
256
|
+
|
|
257
|
+
def find
|
|
258
|
+
self
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
def childEntity
|
|
262
|
+
self
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def resourcePool
|
|
266
|
+
self
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
class ResourcePool
|
|
272
|
+
attr_accessor :name
|
|
273
|
+
|
|
274
|
+
def find
|
|
275
|
+
self
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def resourcePool
|
|
279
|
+
self
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
class ClusterComputeResource
|
|
285
|
+
attr_accessor :name
|
|
286
|
+
|
|
287
|
+
def find
|
|
288
|
+
self
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
def resourcePool
|
|
292
|
+
self
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
class TraversalSpec
|
|
298
|
+
def initialize hash
|
|
299
|
+
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
def self.connect opts
|
|
305
|
+
MockRbVmomiConnection.new( opts )
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
end
|