Class: Fog::VcloudDirector::Compute::Vm
- Defined in:
- lib/fog/vcloud_director/models/compute/vm.rb
Instance Method Summary collapse
- #customization ⇒ Object
- #disks ⇒ Object
- #network ⇒ Object
-
#power_off ⇒ Object
Power off the VM.
-
#power_on ⇒ Object
Power on the VM.
- #ready? ⇒ Boolean
-
#reboot ⇒ Object
Reboot the VM.
-
#reconfigure(options, current: nil) ⇒ Object
Reconfigure a VM using any of the options documented in post_reconfigure_vm.
- #reload ⇒ Object
- #reload_single_vm ⇒ Object
-
#reset ⇒ Object
Reset the VM.
-
#shutdown ⇒ Object
Shut down the VM.
-
#suspend ⇒ Object
Suspend the VM.
- #tags ⇒ Object
- #undeploy ⇒ Object
- #vapp ⇒ Object
Methods inherited from Model
#initialize, #inspect, #lazy_load_attrs, #make_attr_loaded_method, #make_lazy_load_method
Constructor Details
This class inherits a constructor from Fog::VcloudDirector::Compute::Model
Instance Method Details
#customization ⇒ Object
136 137 138 139 140 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 136 def customization requires :id data = service.get_vm_customization(id).body service.vm_customizations.new(data) end |
#disks ⇒ Object
148 149 150 151 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 148 def disks requires :id service.disks(:vm => self) end |
#network ⇒ Object
142 143 144 145 146 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 142 def network requires :id data = service.get_vm_network(id).body service.vm_networks.new(data) end |
#power_off ⇒ Object
Power off the VM.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 49 def power_off requires :id begin response = service.post_power_off_vapp(id) rescue Fog::VcloudDirector::Compute::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#power_on ⇒ Object
Power on the VM.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 61 def power_on requires :id begin response = service.post_power_on_vapp(id) rescue Fog::VcloudDirector::Compute::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#ready? ⇒ Boolean
165 166 167 168 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 165 def ready? reload status == 'on' end |
#reboot ⇒ Object
Reboot the VM.
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 73 def reboot requires :id begin response = service.post_reboot_vapp(id) rescue Fog::VcloudDirector::Compute::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#reconfigure(options, current: nil) ⇒ Object
Reconfigure a VM using any of the options documented in post_reconfigure_vm
155 156 157 158 159 160 161 162 163 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 155 def reconfigure(, current: nil) # Fetch current XML. current ||= service.get_vapp(id, :parser => 'xml').body # Let post_reconfigure_vm apply modifications. response = service.post_reconfigure_vm(id, current, ) service.process_task(response.body) # TODO: apply modifications on current VM instance. end |
#reload ⇒ Object
26 27 28 29 30 31 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 26 def reload # when collection.vapp is nil, it means it's fatherless, # vms from different vapps are loaded in the same collection. # This situation comes from a "query" result collection.vapp.nil? ? reload_single_vm : super end |
#reload_single_vm ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 33 def reload_single_vm return unless data = begin collection.get_single_vm(identity) rescue Excon::Errors::SocketError nil end # these two attributes don't exists in the get_single_vm response # that's why i use the old attributes 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
Reset the VM.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 85 def reset requires :id begin response = service.post_reset_vapp(id) rescue Fog::VcloudDirector::Compute::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#shutdown ⇒ Object
Shut down the VM.
108 109 110 111 112 113 114 115 116 117 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 108 def shutdown requires :id begin response = service.post_shutdown_vapp(id) rescue Fog::VcloudDirector::Compute::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#suspend ⇒ Object
Suspend the VM.
120 121 122 123 124 125 126 127 128 129 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 120 def suspend requires :id begin response = service.post_suspend_vapp(id) rescue Fog::VcloudDirector::Compute::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#tags ⇒ Object
131 132 133 134 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 131 def requires :id service.(:vm => self) end |
#undeploy ⇒ Object
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 96 def undeploy requires :id begin response = service.post_undeploy_vapp(id) rescue Fog::VcloudDirector::Compute::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#vapp ⇒ Object
170 171 172 173 |
# File 'lib/fog/vcloud_director/models/compute/vm.rb', line 170 def vapp # get_by_metadata returns a vm collection where every vapp parent is orpahn collection.vapp ||= service.vapps.get(vapp_id) end |