1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

vm should return false if power action returns bad_request

Also logging error with fog_logger
This commit is contained in:
Sneha Somwanshi 2013-10-10 10:30:26 +01:00
parent 7bac90aae1
commit 03f34941ed
2 changed files with 45 additions and 14 deletions

View file

@ -47,7 +47,7 @@ module Fog
begin
response = service.post_undeploy_vapp(id, :UndeployPowerAction => action)
rescue Excon::Errors::BadRequest => ex
puts ex.message
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
@ -60,7 +60,7 @@ module Fog
begin
response = service.post_power_off_vapp(id)
rescue Excon::Errors::BadRequest => ex
puts ex.message
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
@ -72,7 +72,7 @@ module Fog
begin
response = service.post_power_on_vapp(id)
rescue Excon::Errors::BadRequest => ex
puts ex.message
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
@ -84,7 +84,7 @@ module Fog
begin
response = service.post_reboot_vapp(id)
rescue Excon::Errors::BadRequest => ex
puts ex.message
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
@ -96,7 +96,7 @@ module Fog
begin
response = service.post_reset_vapp(id)
rescue Excon::Errors::BadRequest => ex
puts ex.message
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
@ -108,7 +108,7 @@ module Fog
begin
response = service.post_shutdown_vapp(id)
rescue Excon::Errors::BadRequest => ex
puts ex.message
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
@ -120,7 +120,7 @@ module Fog
begin
response = service.post_suspend_vapp(id)
rescue Excon::Errors::BadRequest => ex
puts ex.message
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
@ -131,7 +131,7 @@ module Fog
begin
response = service.delete_vapp(id)
rescue Excon::Errors::BadRequest => ex
puts ex.message
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)

View file

@ -45,42 +45,73 @@ module Fog
# Power off the VM.
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
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end
# Power on the VM.
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
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end
# Reboot the VM.
def reboot
requires :id
response = service.post_reboot_vapp(id)
begin
response = service.post_reboot_vapp(id)
rescue Excon::Errors::BadRequest => ex
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end
# Reset the VM.
def reset
requires :id
response = service.post_reset_vapp(id)
begin
response = service.post_reset_vapp(id)
rescue Excon::Errors::BadRequest => ex
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end
# Shut down the VM.
def shutdown
requires :id
response = service.post_shutdown_vapp(id)
begin
response = service.post_shutdown_vapp(id)
rescue Excon::Errors::BadRequest => ex
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end
# Suspend the VM.
def suspend
requires :id
response = service.post_suspend_vapp(id)
begin
response = service.post_suspend_vapp(id)
rescue Excon::Errors::BadRequest => ex
Fog::Logger.debug(ex.message)
return false
end
service.process_task(response.body)
end