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
#private_key=, #scp, #scp_download, #ssh, #ssh_port, #sshable?
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 92
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
119
120
121
122
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 119
def config_vnc(options = {})
requires :instance_uuid
connection.vm_config_vnc(options.merge('instance_uuid' => instance_uuid))
end
|
#create(options = {}) ⇒ Object
84
85
86
87
88
89
90
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 84
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
76
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 72
def destroy(options = {})
requires :instance_uuid
stop if ready? connection.vm_destroy('instance_uuid' => instance_uuid)
end
|
#memory ⇒ Object
130
131
132
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 130
def memory
memory_mb * 1024 * 1024
end
|
#migrate(options = {}) ⇒ Object
78
79
80
81
82
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 78
def migrate(options = {})
options = { :priority => 'defaultPriority' }.merge(options)
requires :instance_uuid
connection.vm_migrate('instance_uuid' => instance_uuid, 'priority' => options[:priority])
end
|
#ready? ⇒ Boolean
110
111
112
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 110
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
|
114
115
116
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 114
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
125
126
127
128
|
# File 'lib/fog/vsphere/models/compute/server.rb', line 125
def vnc
requires :instance_uuid
connection.vm_get_vnc(instance_uuid)
end
|