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
148
149
150
151
152
153
154
155
156
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 148
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
121
122
123
124
125
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 121
def customization
requires :id
data = service.get_vm_customization(id).body
service.vm_customizations.new(data)
end
|
#disks ⇒ Object
133
134
135
136
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 133
def disks
requires :id
service.disks(:vm => self)
end
|
#memory=(new_memory) ⇒ Object
138
139
140
141
142
143
144
145
146
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 138
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
127
128
129
130
131
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 127
def network
requires :id
data = service.get_vm_network(id).body
service.vm_networks.new(data)
end
|
#power_off ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 45
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
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 57
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
158
159
160
161
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 158
def ready?
reload
status == 'on'
end
|
#reboot ⇒ Object
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 69
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
|
#reload ⇒ Object
22
23
24
25
26
27
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 22
def reload
collection.vapp.nil? ? reload_single_vm : super
end
|
#reload_single_vm ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 29
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
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 81
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
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 93
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
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 105
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
|
116
117
118
119
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 116
def tags
requires :id
service.tags(:vm => self)
end
|
#vapp ⇒ Object
163
164
165
166
|
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 163
def vapp
collection.vapp ||= service.vapps.get(vapp_id)
end
|