rbvmomi 2.0.0 → 2.0.1
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 +4 -4
- data/lib/rbvmomi/#vim.rb# +155 -0
- data/lib/rbvmomi/version.rb +1 -1
- data/lib/rbvmomi/vmodl.rb +49 -0
- data/vmodl.db +0 -0
- metadata +5 -35
- data/.gitignore +0 -13
- data/.travis.yml +0 -11
- data/.yardopts +0 -6
- data/CONTRIBUTORS.md +0 -44
- data/Gemfile +0 -10
- data/Rakefile +0 -16
- data/devel/analyze-vim-declarations.rb +0 -217
- data/devel/analyze-xml.rb +0 -49
- data/devel/benchmark.rb +0 -121
- data/devel/collisions.rb +0 -22
- data/devel/merge-internal-vmodl.rb +0 -63
- data/devel/merge-manual-vmodl.rb +0 -36
- data/examples/annotate.rb +0 -57
- data/examples/cached_ovf_deploy.rb +0 -124
- data/examples/clone_vm.rb +0 -88
- data/examples/create_vm-1.9.rb +0 -97
- data/examples/create_vm.rb +0 -97
- data/examples/delete_disk_from_vm.rb +0 -57
- data/examples/extraConfig.rb +0 -57
- data/examples/lease_tool.rb +0 -106
- data/examples/logbundle.rb +0 -66
- data/examples/logtail.rb +0 -63
- data/examples/nfs_datastore.rb +0 -99
- data/examples/power.rb +0 -62
- data/examples/readme-1.rb +0 -38
- data/examples/readme-2.rb +0 -54
- data/examples/run.sh +0 -41
- data/examples/screenshot.rb +0 -51
- data/examples/vdf.rb +0 -84
- data/examples/vm_drs_behavior.rb +0 -80
- data/rbvmomi.gemspec +0 -33
data/devel/analyze-xml.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010-2017 VMware, Inc. All Rights Reserved.
|
2
|
-
# SPDX-License-Identifier: MIT
|
3
|
-
|
4
|
-
require 'nokogiri'
|
5
|
-
|
6
|
-
# removes line breaks and whitespace between xml nodes.
|
7
|
-
def prepare_xml(xml)
|
8
|
-
xml = xml.gsub(/\n+/, "")
|
9
|
-
xml = xml.gsub(/(>)\s*(<)/, '\1\2')
|
10
|
-
end
|
11
|
-
|
12
|
-
def analyze_xml x, tree
|
13
|
-
subtree = (tree[x.name] ||= { :attributes => [], :min_occur => nil, :max_occur => nil })
|
14
|
-
attrs = x.attributes.keys.sort
|
15
|
-
subtree[:attributes] << attrs unless subtree[:attributes].member? attrs
|
16
|
-
|
17
|
-
child_occurs = Hash.new 0
|
18
|
-
x.children.select(&:element?).each do |c|
|
19
|
-
child_occurs[c.name] += 1
|
20
|
-
analyze_xml c, subtree
|
21
|
-
end
|
22
|
-
|
23
|
-
subtree.select { |k,v| k.is_a? String }.each do |k,v|
|
24
|
-
v[:min_occur] = [v[:min_occur], child_occurs[k]].compact.min
|
25
|
-
v[:max_occur] = [v[:max_occur], child_occurs[k]].compact.max
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def print_tree tree, indent=0
|
30
|
-
tree.select { |k,v| k.is_a? String }.sort.each do |k,v|
|
31
|
-
attrs = v[:attributes] || []
|
32
|
-
min, max = v[:min_occur], v[:max_occur]
|
33
|
-
numsym = if min == 0 and max == 0 then fail
|
34
|
-
elsif min == 0 and max == 1 then '?'
|
35
|
-
elsif min == 0 then '*'
|
36
|
-
elsif min == 1 and max == 1 then ''
|
37
|
-
else '+'
|
38
|
-
end
|
39
|
-
puts "#{' '*indent}#{k}#{numsym}: #{attrs.sort.map { |a| "[#{a * ' '}]"} * ', '} {#{min},#{max}}"
|
40
|
-
print_tree v, (indent+1)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
tree = {}
|
45
|
-
ARGV.each do |fn|
|
46
|
-
nk = Nokogiri(prepare_xml(File.read fn))
|
47
|
-
analyze_xml nk.root, tree
|
48
|
-
end
|
49
|
-
print_tree tree
|
data/devel/benchmark.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright (c) 2011-2017 VMware, Inc. All Rights Reserved.
|
4
|
-
# SPDX-License-Identifier: MIT
|
5
|
-
|
6
|
-
require 'tempfile'
|
7
|
-
|
8
|
-
if ENV['RBVMOMI_COVERAGE'] == '1'
|
9
|
-
require 'simplecov'
|
10
|
-
SimpleCov.start
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'rbvmomi'
|
14
|
-
require 'rbvmomi/deserialization'
|
15
|
-
require 'benchmark'
|
16
|
-
require 'libxml'
|
17
|
-
|
18
|
-
NS_XSI = 'http://www.w3.org/2001/XMLSchema-instance'
|
19
|
-
|
20
|
-
VIM = RbVmomi::VIM
|
21
|
-
$conn = VIM.new(:ns => 'urn:vim25', :rev => '4.0')
|
22
|
-
raw = File.read(ARGV[0])
|
23
|
-
|
24
|
-
def diff a, b
|
25
|
-
a_io = Tempfile.new 'rbvmomi-diff-a'
|
26
|
-
b_io = Tempfile.new 'rbvmomi-diff-b'
|
27
|
-
PP.pp a, a_io
|
28
|
-
PP.pp b, b_io
|
29
|
-
a_io.close
|
30
|
-
b_io.close
|
31
|
-
system("diff -u #{a_io.path} #{b_io.path}")
|
32
|
-
a_io.unlink
|
33
|
-
b_io.unlink
|
34
|
-
end
|
35
|
-
|
36
|
-
begin
|
37
|
-
deserializer = RbVmomi::OldDeserializer.new($conn)
|
38
|
-
end_time = Time.now + 1
|
39
|
-
n = 0
|
40
|
-
while n == 0 or end_time > Time.now
|
41
|
-
deserializer.deserialize Nokogiri::XML(raw).root
|
42
|
-
n += 1
|
43
|
-
end
|
44
|
-
N = n*10
|
45
|
-
end
|
46
|
-
|
47
|
-
puts "iterations: #{N}"
|
48
|
-
|
49
|
-
parsed_nokogiri = Nokogiri::XML(raw)
|
50
|
-
parsed_libxml = LibXML::XML::Parser.string(raw).parse
|
51
|
-
|
52
|
-
if true
|
53
|
-
nokogiri_xml = parsed_nokogiri.root
|
54
|
-
libxml_xml = parsed_libxml.root
|
55
|
-
|
56
|
-
old_nokogiri_result = RbVmomi::OldDeserializer.new($conn).deserialize nokogiri_xml
|
57
|
-
new_nokogiri_result = RbVmomi::NewDeserializer.new($conn).deserialize nokogiri_xml
|
58
|
-
new_libxml_result = RbVmomi::NewDeserializer.new($conn).deserialize libxml_xml
|
59
|
-
|
60
|
-
if new_nokogiri_result != old_nokogiri_result
|
61
|
-
puts "new_nokogiri_result doesnt match old_nokogiri_result"
|
62
|
-
puts "old_nokogiri_result:"
|
63
|
-
pp old_nokogiri_result
|
64
|
-
puts "new_nokogiri_result:"
|
65
|
-
pp new_nokogiri_result
|
66
|
-
puts "diff:"
|
67
|
-
diff old_nokogiri_result, new_nokogiri_result
|
68
|
-
exit 1
|
69
|
-
end
|
70
|
-
|
71
|
-
if new_libxml_result != old_nokogiri_result
|
72
|
-
puts "new_libxml_result doesnt match old_nokogiri_result"
|
73
|
-
puts "old_nokogiri_result:"
|
74
|
-
pp old_nokogiri_result
|
75
|
-
puts "new_libxml_result:"
|
76
|
-
pp new_libxml_result
|
77
|
-
puts "diff:"
|
78
|
-
diff old_nokogiri_result, new_libxml_result
|
79
|
-
exit 1
|
80
|
-
end
|
81
|
-
|
82
|
-
puts "all results match"
|
83
|
-
end
|
84
|
-
|
85
|
-
Benchmark.bmbm do|b|
|
86
|
-
GC.start
|
87
|
-
b.report("nokogiri parsing") do
|
88
|
-
N.times { Nokogiri::XML(raw) }
|
89
|
-
end
|
90
|
-
|
91
|
-
GC.start
|
92
|
-
b.report("libxml parsing") do
|
93
|
-
N.times do
|
94
|
-
LibXML::XML::Parser.string(raw).parse
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
GC.start
|
99
|
-
b.report("old deserialization (nokogiri)") do
|
100
|
-
deserializer = RbVmomi::OldDeserializer.new($conn)
|
101
|
-
N.times do
|
102
|
-
deserializer.deserialize Nokogiri::XML(raw).root
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
GC.start
|
107
|
-
b.report("new deserialization (nokogiri)") do
|
108
|
-
deserializer = RbVmomi::NewDeserializer.new($conn)
|
109
|
-
N.times do
|
110
|
-
deserializer.deserialize Nokogiri::XML(raw).root
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
GC.start
|
115
|
-
b.report("new deserialization (libxml)") do
|
116
|
-
deserializer = RbVmomi::NewDeserializer.new($conn)
|
117
|
-
N.times do
|
118
|
-
deserializer.deserialize LibXML::XML::Parser.string(raw).parse.root
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
data/devel/collisions.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright (c) 2011-2017 VMware, Inc. All Rights Reserved.
|
4
|
-
# SPDX-License-Identifier: MIT
|
5
|
-
|
6
|
-
# Find collisions between VMODL property names and Ruby methods
|
7
|
-
require 'rbvmomi'
|
8
|
-
VIM = RbVmomi::VIM
|
9
|
-
|
10
|
-
conn = VIM.new(:ns => 'urn:vim25', :rev => '4.0')
|
11
|
-
|
12
|
-
VIM.loader.typenames.each do |name|
|
13
|
-
klass = VIM.loader.get name
|
14
|
-
next unless klass.respond_to? :kind and [:managed, :data].member? klass.kind
|
15
|
-
methods = klass.kind == :managed ?
|
16
|
-
RbVmomi::BasicTypes::ObjectWithMethods.instance_methods :
|
17
|
-
RbVmomi::BasicTypes::ObjectWithProperties.instance_methods
|
18
|
-
klass.props_desc.each do |x|
|
19
|
-
name = x['name']
|
20
|
-
puts "collision: #{klass}##{name}" if methods.member? name.to_sym
|
21
|
-
end
|
22
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright (c) 2011-2017 VMware, Inc. All Rights Reserved.
|
4
|
-
# SPDX-License-Identifier: MIT
|
5
|
-
|
6
|
-
# These types are not public and so may change between releases. Do not
|
7
|
-
# use them directly.
|
8
|
-
|
9
|
-
public_vmodl_filename = ARGV[0] or abort "public vmodl filename required"
|
10
|
-
internal_vmodl_filename = ARGV[1] or abort "internal vmodl filename required"
|
11
|
-
output_vmodl_filename = ARGV[2] or abort "output vmodl filename required"
|
12
|
-
|
13
|
-
TYPES = %w(
|
14
|
-
DVSKeyedOpaqueData
|
15
|
-
DVSOpaqueDataConfigSpec
|
16
|
-
DVPortgroupSelection
|
17
|
-
DVPortSelection
|
18
|
-
DVSSelection
|
19
|
-
DynamicTypeEnumTypeInfo
|
20
|
-
DynamicTypeMgrAllTypeInfo
|
21
|
-
DynamicTypeMgrAnnotation
|
22
|
-
DynamicTypeMgrDataTypeInfo
|
23
|
-
DynamicTypeMgrFilterSpec
|
24
|
-
DynamicTypeMgrManagedTypeInfo
|
25
|
-
DynamicTypeMgrMethodTypeInfo
|
26
|
-
DynamicTypeMgrMethodTypeInfoAnnotationType
|
27
|
-
DynamicTypeMgrMoFilterSpec
|
28
|
-
DynamicTypeMgrMoInstance
|
29
|
-
DynamicTypeMgrParamTypeInfo
|
30
|
-
DynamicTypeMgrParamTypeInfoAnnotationType
|
31
|
-
DynamicTypeMgrPropertyTypeInfo
|
32
|
-
DynamicTypeMgrPropertyTypeInfoAnnotationType
|
33
|
-
DynamicTypeMgrTypeFilterSpec
|
34
|
-
InternalDynamicTypeManager
|
35
|
-
ReflectManagedMethodExecuter
|
36
|
-
ReflectManagedMethodExecuterSoapArgument
|
37
|
-
ReflectManagedMethodExecuterSoapFault
|
38
|
-
ReflectManagedMethodExecuterSoapResult
|
39
|
-
SelectionSet
|
40
|
-
)
|
41
|
-
|
42
|
-
METHODS = %w(
|
43
|
-
DistributedVirtualSwitchManager.UpdateDvsOpaqueData_Task
|
44
|
-
HostSystem.RetrieveDynamicTypeManager
|
45
|
-
HostSystem.RetrieveManagedMethodExecuter
|
46
|
-
)
|
47
|
-
|
48
|
-
public_vmodl = File.open(public_vmodl_filename, 'r') { |io| Marshal.load io }
|
49
|
-
internal_vmodl = File.open(internal_vmodl_filename, 'r') { |io| Marshal.load io }
|
50
|
-
|
51
|
-
TYPES.each do |k|
|
52
|
-
puts "Merging in #{k}"
|
53
|
-
fail "Couldn't find type #{k} in internal VMODL" unless internal_vmodl.member? k
|
54
|
-
public_vmodl[k] = internal_vmodl[k]
|
55
|
-
end
|
56
|
-
|
57
|
-
METHODS.each do |x|
|
58
|
-
puts "Merging in #{x}"
|
59
|
-
type, method = x.split '.'
|
60
|
-
public_vmodl[type]['methods'][method] = internal_vmodl[type]['methods'][method] or fail
|
61
|
-
end
|
62
|
-
|
63
|
-
File.open(output_vmodl_filename, 'w') { |io| Marshal.dump public_vmodl, io }
|
data/devel/merge-manual-vmodl.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright (c) 2013-2017 VMware, Inc. All Rights Reserved.
|
4
|
-
# SPDX-License-Identifier: MIT
|
5
|
-
|
6
|
-
# Manually merge two versions of vmodl.db
|
7
|
-
|
8
|
-
public_vmodl_filename = ARGV[0] or abort "public vmodl filename required"
|
9
|
-
internal_vmodl_filename = ARGV[1] or abort "internal vmodl filename required"
|
10
|
-
output_vmodl_filename = ARGV[2] or abort "output vmodl filename required"
|
11
|
-
|
12
|
-
public_vmodl = File.open(public_vmodl_filename, 'r') { |io| Marshal.load io }
|
13
|
-
internal_vmodl = File.open(internal_vmodl_filename, 'r') { |io| Marshal.load io }
|
14
|
-
|
15
|
-
db = {}
|
16
|
-
tn = {}
|
17
|
-
public_vmodl.each do |k,v|
|
18
|
-
unless k == '_typenames'
|
19
|
-
db[k] = v
|
20
|
-
else
|
21
|
-
tn['_typenames'] = v
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
internal_vmodl.each do |k, v|
|
26
|
-
unless k == '_typenames'
|
27
|
-
db[k] = v unless db[k]
|
28
|
-
else
|
29
|
-
tn['_typenames'] = tn['_typenames'] + v
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
db['_typenames'] = tn
|
34
|
-
|
35
|
-
|
36
|
-
File.open(output_vmodl_filename, 'w') { |io| Marshal.dump db, io }
|
data/examples/annotate.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011-2017 VMware, Inc. All Rights Reserved.
|
2
|
-
# SPDX-License-Identifier: MIT
|
3
|
-
|
4
|
-
require 'optimist'
|
5
|
-
require 'rbvmomi'
|
6
|
-
require 'rbvmomi/optimist'
|
7
|
-
|
8
|
-
VIM = RbVmomi::VIM
|
9
|
-
CMDS = %w(get set)
|
10
|
-
|
11
|
-
opts = Optimist.options do
|
12
|
-
banner <<-EOS
|
13
|
-
Annotate a VM.
|
14
|
-
|
15
|
-
Usage:
|
16
|
-
annotate.rb [options] VM get
|
17
|
-
annotate.rb [options] VM set annotation
|
18
|
-
|
19
|
-
Commands: #{CMDS * ' '}
|
20
|
-
|
21
|
-
VIM connection options:
|
22
|
-
EOS
|
23
|
-
|
24
|
-
rbvmomi_connection_opts
|
25
|
-
|
26
|
-
text <<-EOS
|
27
|
-
|
28
|
-
VM location options:
|
29
|
-
EOS
|
30
|
-
|
31
|
-
rbvmomi_datacenter_opt
|
32
|
-
|
33
|
-
text <<-EOS
|
34
|
-
|
35
|
-
Other options:
|
36
|
-
EOS
|
37
|
-
|
38
|
-
stop_on CMDS
|
39
|
-
end
|
40
|
-
|
41
|
-
vm_name = ARGV[0] or Optimist.die("no VM name given")
|
42
|
-
cmd = ARGV[1] or Optimist.die("no command given")
|
43
|
-
abort "invalid command" unless CMDS.member? cmd
|
44
|
-
Optimist.die("must specify host") unless opts[:host]
|
45
|
-
|
46
|
-
vim = VIM.connect opts
|
47
|
-
|
48
|
-
dc = vim.serviceInstance.find_datacenter(opts[:datacenter]) or abort "datacenter not found"
|
49
|
-
vm = dc.find_vm(vm_name) or abort "VM not found"
|
50
|
-
|
51
|
-
case cmd
|
52
|
-
when 'get'
|
53
|
-
puts vm.config.annotation
|
54
|
-
when 'set'
|
55
|
-
value = ARGV[2] or Optimist.die("no annotation given")
|
56
|
-
vm.ReconfigVM_Task(:spec => VIM.VirtualMachineConfigSpec(:annotation => value)).wait_for_completion
|
57
|
-
end
|
@@ -1,124 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright (c) 2012-2017 VMware, Inc. All Rights Reserved.
|
4
|
-
# SPDX-License-Identifier: MIT
|
5
|
-
|
6
|
-
require 'optimist'
|
7
|
-
require 'rbvmomi'
|
8
|
-
require 'rbvmomi/optimist'
|
9
|
-
require 'rbvmomi/utils/deploy'
|
10
|
-
require 'rbvmomi/utils/admission_control'
|
11
|
-
require 'yaml'
|
12
|
-
|
13
|
-
VIM = RbVmomi::VIM
|
14
|
-
|
15
|
-
opts = Optimist.options do
|
16
|
-
banner <<-EOS
|
17
|
-
Deploy an OVF to a cluster, using a cached template if available.
|
18
|
-
|
19
|
-
Usage:
|
20
|
-
cached_ovf_deploy.rb [options] <vmname> <ovfurl>
|
21
|
-
|
22
|
-
VIM connection options:
|
23
|
-
EOS
|
24
|
-
|
25
|
-
rbvmomi_connection_opts
|
26
|
-
|
27
|
-
text <<-EOS
|
28
|
-
|
29
|
-
VM location options:
|
30
|
-
EOS
|
31
|
-
|
32
|
-
rbvmomi_datacenter_opt
|
33
|
-
rbvmomi_datastore_opt
|
34
|
-
|
35
|
-
text <<-EOS
|
36
|
-
|
37
|
-
Other options:
|
38
|
-
EOS
|
39
|
-
|
40
|
-
opt :template_name, "Name to give to the (cached) template", :type => :string
|
41
|
-
opt :template_path, "Path where templates are stored", :default => 'templates', :type => :string
|
42
|
-
opt :computer_path, "Path to the cluster to deploy into", :type => :string
|
43
|
-
opt :network, "Name of the network to attach template to", :type => :string
|
44
|
-
opt :vm_folder_path, "Path to VM folder to deploy VM into", :type => :string
|
45
|
-
opt :lease, "Lease in days", :type => :int, :default => 3
|
46
|
-
end
|
47
|
-
|
48
|
-
Optimist.die("must specify host") unless opts[:host]
|
49
|
-
Optimist.die("no cluster path given") unless opts[:computer_path]
|
50
|
-
template_folder_path = opts[:template_path]
|
51
|
-
template_name = opts[:template_name] or Optimist.die("no template name given")
|
52
|
-
vm_name = ARGV[0] or Optimist.die("no VM name given")
|
53
|
-
ovf_url = ARGV[1] or Optimist.die("No OVF URL given")
|
54
|
-
|
55
|
-
vim = VIM.connect opts
|
56
|
-
dc = vim.serviceInstance.find_datacenter(opts[:datacenter]) or abort "datacenter not found"
|
57
|
-
|
58
|
-
root_vm_folder = dc.vmFolder
|
59
|
-
vm_folder = root_vm_folder
|
60
|
-
if opts[:vm_folder_path]
|
61
|
-
vm_folder = root_vm_folder.traverse(opts[:vm_folder_path], VIM::Folder)
|
62
|
-
end
|
63
|
-
template_folder = root_vm_folder.traverse!(template_folder_path, VIM::Folder)
|
64
|
-
|
65
|
-
scheduler = AdmissionControlledResourceScheduler.new(
|
66
|
-
vim,
|
67
|
-
:datacenter => dc,
|
68
|
-
:computer_names => [opts[:computer_path]],
|
69
|
-
:vm_folder => vm_folder,
|
70
|
-
:rp_path => '/',
|
71
|
-
:datastore_paths => [opts[:datastore]],
|
72
|
-
:max_vms_per_pod => nil, # No limits
|
73
|
-
:min_ds_free => nil, # No limits
|
74
|
-
)
|
75
|
-
scheduler.make_placement_decision
|
76
|
-
|
77
|
-
datastore = scheduler.datastore
|
78
|
-
computer = scheduler.pick_computer
|
79
|
-
# XXX: Do this properly
|
80
|
-
if opts[:network]
|
81
|
-
network = computer.network.find{|x| x.name == opts[:network]}
|
82
|
-
else
|
83
|
-
network = computer.network[0]
|
84
|
-
end
|
85
|
-
|
86
|
-
lease_tool = LeaseTool.new
|
87
|
-
lease = opts[:lease] * 24 * 60 * 60
|
88
|
-
deployer = CachedOvfDeployer.new(
|
89
|
-
vim, network, computer, template_folder, vm_folder, datastore
|
90
|
-
)
|
91
|
-
template = deployer.lookup_template template_name
|
92
|
-
|
93
|
-
if !template
|
94
|
-
puts "#{Time.now}: Uploading/Preparing OVF template ..."
|
95
|
-
|
96
|
-
template = deployer.upload_ovf_as_template(
|
97
|
-
ovf_url, template_name,
|
98
|
-
:run_without_interruptions => true,
|
99
|
-
:config => lease_tool.set_lease_in_vm_config({}, lease)
|
100
|
-
)
|
101
|
-
end
|
102
|
-
|
103
|
-
puts "#{Time.now}: Cloning template ..."
|
104
|
-
config = {
|
105
|
-
:numCPUs => opts[:cpus],
|
106
|
-
:memoryMB => opts[:memory],
|
107
|
-
}
|
108
|
-
config = lease_tool.set_lease_in_vm_config(config, lease)
|
109
|
-
vm = deployer.linked_clone template, vm_name, config
|
110
|
-
|
111
|
-
puts "#{Time.now}: Powering On VM ..."
|
112
|
-
# XXX: Add a retrying version?
|
113
|
-
vm.PowerOnVM_Task.wait_for_completion
|
114
|
-
|
115
|
-
puts "#{Time.now}: Waiting for VM to be up ..."
|
116
|
-
ip = nil
|
117
|
-
while !(ip = vm.guest_ip)
|
118
|
-
sleep 5
|
119
|
-
end
|
120
|
-
|
121
|
-
puts "#{Time.now}: VM got IP: #{ip}"
|
122
|
-
|
123
|
-
puts "#{Time.now}: Done"
|
124
|
-
|