Class: Fog::Compute::VcloudDirector::Vm
- Inherits:
-
Model
- Object
- Model
- Model
- Fog::Compute::VcloudDirector::Vm
show all
- Defined in:
- lib/fog/vcloud_director/models/compute/vm.rb
Instance Method Summary
collapse
Methods inherited from Model
#initialize, #inspect, #lazy_load_attrs, #make_attr_loaded_method, #make_lazy_load_method
Instance Method Details
#cpu=(new_cpu) ⇒ Object
162
163
164
165
166
167
168
169
170
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 162
def cpu=(new_cpu)
has_changed = ( cpu != new_cpu.to_i )
not_first_set = !cpu.nil?
attributes[:cpu] = new_cpu.to_i
if not_first_set && has_changed
response = service.put_cpu(id, cpu)
service.process_task(response.body)
end
end
|
#customization ⇒ Object
135
136
137
138
139
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 135
def customization
requires :id
data = service.get_vm_customization(id).body
service.vm_customizations.new(data)
end
|
#disks ⇒ Object
147
148
149
150
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 147
def disks
requires :id
service.disks(:vm => self)
end
|
#memory=(new_memory) ⇒ Object
152
153
154
155
156
157
158
159
160
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 152
def memory=(new_memory)
has_changed = ( memory != new_memory.to_i )
not_first_set = !memory.nil?
attributes[:memory] = new_memory.to_i
if not_first_set && has_changed
response = service.put_memory(id, memory)
service.process_task(response.body)
end
end
|
#network ⇒ Object
141
142
143
144
145
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 141
def network
requires :id
data = service.get_vm_network(id).body
service.vm_networks.new(data)
end
|
#power_off ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 48
def power_off
requires :id
begin
response = service.post_power_off_vapp(id)
rescue Fog::Compute::VcloudDirector::BadRequest => ex
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end
|
#power_on ⇒ Object
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 60
def power_on
requires :id
begin
response = service.post_power_on_vapp(id)
rescue Fog::Compute::VcloudDirector::BadRequest => ex
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end
|
#ready? ⇒ Boolean
185
186
187
188
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 185
def ready?
reload
status == 'on'
end
|
#reboot ⇒ Object
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 72
def reboot
requires :id
begin
response = service.post_reboot_vapp(id)
rescue Fog::Compute::VcloudDirector::BadRequest => ex
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end
|
Reconfigure a VM using any of the options documented in post_reconfigure_vm
174
175
176
177
178
179
180
181
182
183
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 174
def reconfigure(options)
options[:name] ||= name [:cpu, :memory, :description].each do |k|
options.delete(k) if options.key? k and options[k] == attributes[k]
end
response = service.post_reconfigure_vm(id, options)
service.process_task(response.body)
options.each {|k,v| attributes[k] = v}
end
|
#reload ⇒ Object
25
26
27
28
29
30
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 25
def reload
collection.vapp.nil? ? reload_single_vm : super
end
|
#reload_single_vm ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 32
def reload_single_vm
return unless data = begin
collection.get_single_vm(identity)
rescue Excon::Errors::SocketError
nil
end
data.attributes[:vapp_id] = attributes[:vapp_id]
data.attributes[:vapp_name] = attributes[:vapp_name]
new_attributes = data.attributes
merge_attributes(new_attributes)
self
end
|
#reset ⇒ Object
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 84
def reset
requires :id
begin
response = service.post_reset_vapp(id)
rescue Fog::Compute::VcloudDirector::BadRequest => ex
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end
|
#shutdown ⇒ Object
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 107
def shutdown
requires :id
begin
response = service.post_shutdown_vapp(id)
rescue Fog::Compute::VcloudDirector::BadRequest => ex
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end
|
#suspend ⇒ Object
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 119
def suspend
requires :id
begin
response = service.post_suspend_vapp(id)
rescue Fog::Compute::VcloudDirector::BadRequest => ex
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end
|
130
131
132
133
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 130
def tags
requires :id
service.tags(:vm => self)
end
|
#undeploy ⇒ Object
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 95
def undeploy
requires :id
begin
response = service.post_undeploy_vapp(id)
rescue Fog::Compute::VcloudDirector::BadRequest => ex
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end
|
#vapp ⇒ Object
190
191
192
193
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 190
def vapp
collection.vapp ||= service.vapps.get(vapp_id)
end
|