mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
vapp returns false if power action returns bad_request
Fixed issues - where fog models throw exception if it fails to execute power action on vapp. This happens because the current state of vapp does not let user execute the action. e.g If vapp is in power_off state, it throw bad_request if user executes power_off, suspend,reboot or shutdown action. In such case, fog model should return false instead of throwing exception. Also printing the error message.
This commit is contained in:
parent
7b61bd5f5a
commit
7b253d4fd3
1 changed files with 49 additions and 8 deletions
|
@ -44,55 +44,96 @@ module Fog
|
|||
# * default (Use the actions, order, and delay specified in the
|
||||
# StartupSection)
|
||||
def undeploy(action='powerOff')
|
||||
response = service.post_undeploy_vapp(id, :UndeployPowerAction => action)
|
||||
begin
|
||||
response = service.post_undeploy_vapp(id, :UndeployPowerAction => action)
|
||||
rescue Excon::Errors::BadRequest => ex
|
||||
puts ex.message
|
||||
return false
|
||||
end
|
||||
service.process_task(response.body)
|
||||
end
|
||||
|
||||
|
||||
# Power off all VMs in the vApp.
|
||||
def power_off
|
||||
requires :id
|
||||
response = service.post_power_off_vapp(id)
|
||||
begin
|
||||
response = service.post_power_off_vapp(id)
|
||||
rescue Excon::Errors::BadRequest => ex
|
||||
puts ex.message
|
||||
return false
|
||||
end
|
||||
service.process_task(response.body)
|
||||
end
|
||||
|
||||
# Power on all VMs in the vApp.
|
||||
def power_on
|
||||
requires :id
|
||||
response = service.post_power_on_vapp(id)
|
||||
begin
|
||||
response = service.post_power_on_vapp(id)
|
||||
rescue Excon::Errors::BadRequest => ex
|
||||
puts ex.message
|
||||
return false
|
||||
end
|
||||
service.process_task(response.body)
|
||||
end
|
||||
|
||||
# Reboot all VMs in the vApp.
|
||||
def reboot
|
||||
requires :id
|
||||
response = service.post_reboot_vapp(id)
|
||||
begin
|
||||
response = service.post_reboot_vapp(id)
|
||||
rescue Excon::Errors::BadRequest => ex
|
||||
puts ex.message
|
||||
return false
|
||||
end
|
||||
service.process_task(response.body)
|
||||
end
|
||||
|
||||
# Reset all VMs in the vApp.
|
||||
def reset
|
||||
requires :id
|
||||
response = service.post_reset_vapp(id)
|
||||
begin
|
||||
response = service.post_reset_vapp(id)
|
||||
rescue Excon::Errors::BadRequest => ex
|
||||
puts ex.message
|
||||
return false
|
||||
end
|
||||
service.process_task(response.body)
|
||||
end
|
||||
|
||||
# Shut down all VMs in the vApp.
|
||||
def shutdown
|
||||
requires :id
|
||||
response = service.post_shutdown_vapp(id)
|
||||
begin
|
||||
response = service.post_shutdown_vapp(id)
|
||||
rescue Excon::Errors::BadRequest => ex
|
||||
puts ex.message
|
||||
return false
|
||||
end
|
||||
service.process_task(response.body)
|
||||
end
|
||||
|
||||
# Suspend all VMs in the vApp.
|
||||
def suspend
|
||||
requires :id
|
||||
response = service.post_suspend_vapp(id)
|
||||
begin
|
||||
response = service.post_suspend_vapp(id)
|
||||
rescue Excon::Errors::BadRequest => ex
|
||||
puts ex.message
|
||||
return false
|
||||
end
|
||||
service.process_task(response.body)
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
response = service.delete_vapp(id)
|
||||
begin
|
||||
response = service.delete_vapp(id)
|
||||
rescue Excon::Errors::BadRequest => ex
|
||||
puts ex.message
|
||||
return false
|
||||
end
|
||||
service.process_task(response.body)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue