Class: Fog::Compute::Vsphere::Server
- Inherits:
-
Server
show all
- Defined in:
- lib/fog/vsphere/models/compute/server.rb
Instance Attribute Summary
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Server
#scp, #scp_download, #ssh
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
Instance Method Details
#clone(options = {}) ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 91
def clone(options = {})
requires :name, :path
req_options = options.inject({}) { |hsh, (k,v)| hsh[k.to_s] = v; hsh }
req_options['path'] ="#{path}/#{name}"
clone_results = connection.vm_clone(req_options)
new_vm = self.class.new(clone_results['vm_attributes'])
new_vm.collection = self.collection
new_vm.connection = self.connection
new_vm
end
|
#config_vnc(options = {}) ⇒ Object
defines VNC attributes on the hypervisor
118
119
120
121
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 118
def config_vnc(options = {})
requires :instance_uuid
connection.vm_config_vnc(options.merge('instance_uuid' => instance_uuid))
end
|
#create(options = {}) ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 83
def create(options ={})
requires :name, :path
new_vm = self.class.new(create_results['vm_attributes'])
new_vm.collection = self.collection
new_vm.connection = self.connection
new_vm
end
|
#destroy(options = {}) ⇒ Object
72
73
74
75
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 72
def destroy(options = {})
requires :instance_uuid
connection.vm_destroy('instance_uuid' => instance_uuid)
end
|
#memory ⇒ Object
129
130
131
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 129
def memory
memory_mb * 1024 * 1024
end
|
#migrate(options = {}) ⇒ Object
77
78
79
80
81
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 77
def migrate(options = {})
options = { :priority => 'defaultPriority' }.merge(options)
requires :instance_uuid
connection.vm_migrate('instance_uuid' => instance_uuid, 'priority' => options[:priority])
end
|
#ready? ⇒ Boolean
109
110
111
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 109
def ready?
power_state == "poweredOn"
end
|
#reboot(options = {}) ⇒ Object
66
67
68
69
70
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 66
def reboot(options = {})
options = { :force => false }.merge(options)
requires :instance_uuid
connection.vm_reboot('instance_uuid' => instance_uuid, 'force' => options[:force])
end
|
#start(options = {}) ⇒ Object
55
56
57
58
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 55
def start(options = {})
requires :instance_uuid
connection.vm_power_on('instance_uuid' => instance_uuid)
end
|
#stop(options = {}) ⇒ Object
60
61
62
63
64
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 60
def stop(options = {})
options = { :force => !tools_installed? }.merge(options)
requires :instance_uuid
connection.vm_power_off('instance_uuid' => instance_uuid, 'force' => options[:force])
end
|
113
114
115
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 113
def tools_installed?
tools_state != "toolsNotInstalled"
end
|
#vm_reconfig_cpus(options = {}) ⇒ Object
45
46
47
48
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 45
def vm_reconfig_cpus(options = {})
requires :instance_uuid, :cpus
connection.vm_reconfig_cpus('instance_uuid' => instance_uuid, 'cpus' => cpus)
end
|
#vm_reconfig_hardware(options = {}) ⇒ Object
50
51
52
53
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 50
def vm_reconfig_hardware(options = {})
requires :instance_uuid, :hardware_spec
connection.vm_reconfig_hardware('instance_uuid' => instance_uuid, 'hardware_spec' => hardware_spec)
end
|
#vm_reconfig_memory(options = {}) ⇒ Object
40
41
42
43
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 40
def vm_reconfig_memory(options = {})
requires :instance_uuid, :memory
connection.vm_reconfig_memory('instance_uuid' => instance_uuid, 'memory' => memory)
end
|
#vnc ⇒ Object
returns a hash of VNC attributes required for connection
124
125
126
127
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 124
def vnc
requires :instance_uuid
connection.vm_get_vnc(instance_uuid)
end
|