Class: RbVmomi::VIM
- Inherits:
-
Object
show all
- Defined in:
- lib/vmonkey/vim/vim.rb
Defined Under Namespace
Classes: Datacenter, Folder, VirtualApp, VirtualMachine
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#cluster ⇒ Object
Returns the value of attribute cluster.
7
8
9
|
# File 'lib/vmonkey/vim/vim.rb', line 7
def cluster
@cluster
end
|
#dc ⇒ Object
Returns the value of attribute dc.
6
7
8
|
# File 'lib/vmonkey/vim/vim.rb', line 6
def dc
@dc
end
|
#opts ⇒ Object
Returns the value of attribute opts.
8
9
10
|
# File 'lib/vmonkey/vim/vim.rb', line 8
def opts
@opts
end
|
Class Method Details
.default_opts ⇒ Object
20
21
22
|
# File 'lib/vmonkey/vim/vim.rb', line 20
def self.default_opts
self.read_yml_opts
end
|
.monkey_connect(opts = nil) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/vmonkey/vim/vim.rb', line 10
def self.monkey_connect(opts = nil)
opts ||= self.default_opts
vim = self.connect(opts)
vim.opts = opts
vim.dc = vim.serviceInstance.find_datacenter(vim.opts[:datacenter]) or raise "Datacenter not found [#{vim.opts[:datacenter]}]"
vim.cluster = vim.dc.find_compute_resource(vim.opts[:cluster]) or raise "Cluster not found [#{vim.opts[:cluster]}]"
vim
end
|
Instance Method Details
#customization_spec(spec_name) ⇒ Object
86
87
88
89
90
91
|
# File 'lib/vmonkey/vim/vim.rb', line 86
def customization_spec(spec_name)
return nil if spec_name.nil?
serviceContent.customizationSpecManager.GetCustomizationSpec(name: spec_name).spec
rescue
nil
end
|
#datastore(datastore_name) ⇒ Object
78
79
80
|
# File 'lib/vmonkey/vim/vim.rb', line 78
def datastore(datastore_name)
dc.datastore.find { |ds| ds.info.name.to_s == datastore_name.to_s }
end
|
#datastore!(datastore_name) ⇒ Object
82
83
84
|
# File 'lib/vmonkey/vim/vim.rb', line 82
def datastore!(datastore_name)
datastore(datastore_name) || raise("Datastore not found. [#{datastore_name}]")
end
|
#folder(path) ⇒ Object
24
25
26
|
# File 'lib/vmonkey/vim/vim.rb', line 24
def folder(path)
dc.vmFolder.traverse path, RbVmomi::VIM::Folder
end
|
#folder!(path) ⇒ Object
28
29
30
|
# File 'lib/vmonkey/vim/vim.rb', line 28
def folder!(path)
folder(path) || raise("Folder not found. [#{path}]")
end
|
#get(path) ⇒ Object
74
75
76
|
# File 'lib/vmonkey/vim/vim.rb', line 74
def get(path)
dc.vmFolder.traverse path
end
|
#template(path) ⇒ Object
40
41
42
43
44
|
# File 'lib/vmonkey/vim/vim.rb', line 40
def template(path)
t = vm path
return t if t && t.config && t.config.template
return nil
end
|
#template!(path) ⇒ Object
46
47
48
|
# File 'lib/vmonkey/vim/vim.rb', line 46
def template!(path)
template(path) || raise("Template not found. [#{path}]")
end
|
#vapp(path) ⇒ Object
66
67
68
|
# File 'lib/vmonkey/vim/vim.rb', line 66
def vapp(path)
dc.vmFolder.traverse path, RbVmomi::VIM::VirtualApp
end
|
#vapp!(path) ⇒ Object
70
71
72
|
# File 'lib/vmonkey/vim/vim.rb', line 70
def vapp!(path)
vapp(path) || raise("VirtualApp not found. [#{path}]")
end
|
#vm(path) ⇒ Object
32
33
34
|
# File 'lib/vmonkey/vim/vim.rb', line 32
def vm(path)
dc.vmFolder.traverse path, RbVmomi::VIM::VirtualMachine
end
|
#vm!(path) ⇒ Object
36
37
38
|
# File 'lib/vmonkey/vim/vim.rb', line 36
def vm!(path)
vm(path) || raise("VirtualMachine not found. [#{path}]")
end
|
#vm_by_instance_uuid(uuid) ⇒ Object
58
59
60
|
# File 'lib/vmonkey/vim/vim.rb', line 58
def vm_by_instance_uuid(uuid)
dc.vmFolder.findByInstanceUuid uuid
end
|
#vm_by_instance_uuid!(uuid) ⇒ Object
62
63
64
|
# File 'lib/vmonkey/vim/vim.rb', line 62
def vm_by_instance_uuid!(uuid)
vm_by_instance_uuid(uuid) || raise("VirtualMachine not found. [#{uuid}]")
end
|
#vm_by_uuid(uuid) ⇒ Object
50
51
52
|
# File 'lib/vmonkey/vim/vim.rb', line 50
def vm_by_uuid(uuid)
dc.vmFolder.findByUuid uuid, RbVmomi::VIM::VirtualMachine, dc
end
|
#vm_by_uuid!(uuid) ⇒ Object
54
55
56
|
# File 'lib/vmonkey/vim/vim.rb', line 54
def vm_by_uuid!(uuid)
vm_by_uuid(uuid) || raise("VirtualMachine not found. [#{uuid}]")
end
|