Class: Fog::Compute::VcloudDirector::Vapp
- Defined in:
- lib/fog/vcloud_director/models/compute/vapp.rb
Instance Method Summary collapse
- #custom_fields ⇒ Object
- #destroy ⇒ Object
- #human_status ⇒ Object
-
#initialize(*args, **kwargs) ⇒ Vapp
constructor
A new instance of Vapp.
-
#power_off ⇒ Object
Power off all VMs in the vApp.
-
#power_on ⇒ Object
Power on all VMs in the vApp.
-
#reboot ⇒ Object
Reboot all VMs in the vApp.
-
#reset ⇒ Object
Reset all VMs in the vApp.
-
#shutdown ⇒ Object
Shut down all VMs in the vApp.
-
#suspend ⇒ Object
Suspend all VMs in the vApp.
- #tags ⇒ Object
-
#undeploy(action = 'powerOff') ⇒ Object
-
powerOff (Power off the virtual machines. This is the default action if this attribute is missing or empty) * suspend (Suspend the virtual machines) * shutdown (Shut down the virtual machines) * force (Attempt to power off the virtual machines. Failures in undeploying the virtual machine or associated networks are ignored. All references to the vApp and its virtual machines are removed from the database) * default (Use the actions, order, and delay specified in the StartupSection).
-
- #vms(force: false) ⇒ Object
Methods inherited from Model
#inspect, #lazy_load_attrs, #make_attr_loaded_method, #make_lazy_load_method
Constructor Details
#initialize(*args, **kwargs) ⇒ Vapp
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 19 def initialize(*args, **kwargs) # Memorize VMs because their full XML description was already included in the vApp XML description. # Instead simple Array we rather store as Collection in order to provide common interface e.g. # vapp.vms.all # vapp.vms.get_by_name if (vms = kwargs.delete(:vms)) @vms = Fog::Compute::VcloudDirector::Vms.new( :vapp => self, :service => kwargs[:service] ).with_item_list(Array(vms)) end super(*args, **kwargs) end |
Instance Method Details
#custom_fields ⇒ Object
48 49 50 51 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 48 def custom_fields requires :id service.custom_fields( :vapp => self) end |
#destroy ⇒ Object
165 166 167 168 169 170 171 172 173 174 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 165 def destroy requires :id begin response = service.delete_vapp(id) rescue Fog::Compute::VcloudDirector::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#human_status ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 53 def human_status case status when '-1', -1 'failed_creation' when '0', 0 'creating' when '8', 8 'off' when '4', 4 'on' when '3', 3 'suspended' else 'unknown' end end |
#power_off ⇒ Object
Power off all VMs in the vApp.
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 94 def power_off requires :id begin response = service.post_power_off_vapp(id) rescue Fog::Compute::VcloudDirector::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#power_on ⇒ Object
Power on all VMs in the vApp.
106 107 108 109 110 111 112 113 114 115 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 106 def power_on requires :id begin response = service.post_power_on_vapp(id) rescue Fog::Compute::VcloudDirector::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#reboot ⇒ Object
Reboot all VMs in the vApp.
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 118 def reboot requires :id begin response = service.post_reboot_vapp(id) rescue Fog::Compute::VcloudDirector::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#reset ⇒ Object
Reset all VMs in the vApp.
130 131 132 133 134 135 136 137 138 139 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 130 def reset requires :id begin response = service.post_reset_vapp(id) rescue Fog::Compute::VcloudDirector::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#shutdown ⇒ Object
Shut down all VMs in the vApp.
142 143 144 145 146 147 148 149 150 151 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 142 def shutdown requires :id begin response = service.post_shutdown_vapp(id) rescue Fog::Compute::VcloudDirector::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#suspend ⇒ Object
Suspend all VMs in the vApp.
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 154 def suspend requires :id begin response = service.post_suspend_vapp(id) rescue Fog::Compute::VcloudDirector::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#tags ⇒ Object
43 44 45 46 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 43 def requires :id service.(:vm => self) end |
#undeploy(action = 'powerOff') ⇒ Object
-
powerOff (Power off the virtual machines. This is the default action if this attribute is missing or empty)
-
suspend (Suspend the virtual machines)
-
shutdown (Shut down the virtual machines)
-
force (Attempt to power off the virtual machines. Failures in undeploying the virtual machine or associated networks are ignored. All references to the vApp and its virtual machines are removed from the database)
-
default (Use the actions, order, and delay specified in the StartupSection)
83 84 85 86 87 88 89 90 91 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 83 def undeploy(action='powerOff') begin response = service.post_undeploy_vapp(id, :UndeployPowerAction => action) rescue Fog::Compute::VcloudDirector::BadRequest => ex Fog::Logger.debug(ex.) return false end service.process_task(response.body) end |
#vms(force: false) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/fog/vcloud_director/models/compute/vapp.rb', line 34 def vms(force: false) # Return memorized Collection that we parsed based on vApp XML description. This way we prevent # additional API request to be made for each VM in a vApp. return @vms unless @vms.nil? || force requires :id service.vms(:vapp => self) end |