Class: VCloudCloud::Steps::PowerOff
- Inherits:
-
VCloudCloud::Step
- Object
- VCloudCloud::Step
- VCloudCloud::Steps::PowerOff
- Defined in:
- lib/cloud/vcloud/steps/poweroff.rb
Instance Attribute Summary
Attributes inherited from VCloudCloud::Step
Instance Method Summary collapse
Methods inherited from VCloudCloud::Step
#cleanup, #initialize, #rollback
Constructor Details
This class inherits a constructor from VCloudCloud::Step
Instance Method Details
#perform(ref, discard_suspend_state = false, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/cloud/vcloud/steps/poweroff.rb', line 4 def perform(ref, discard_suspend_state = false, &block) entity = client.reload state[ref] if entity['status'] == VCloudSdk::Xml::RESOURCE_ENTITY_STATUS[:POWERED_OFF].to_s @logger.debug "#{entity.name} already powered off" return end if discard_suspend_state && entity['status'] == VCloudSdk::Xml::RESOURCE_ENTITY_STATUS[:SUSPENDED].to_s client.invoke_and_wait :post, entity.discard_state entity = state[ref] = client.reload entity end poweroff_link = entity.power_off_link raise "#{entity.name} unable to power off" unless poweroff_link client.invoke_and_wait :post, poweroff_link state[ref] = client.reload entity end |