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

power_on a vm

This commit is contained in:
Rodrigo Estebanez 2013-07-05 14:35:23 +02:00
parent 2c85af5c83
commit 86d6bdd125
3 changed files with 36 additions and 0 deletions

View file

@ -46,6 +46,12 @@ module Fog
SCHEME = 'https'
end
module Errors
class ServiceError < Fog::Errors::Error; end
class Task < ServiceError; end
end
requires :vcloudng_username, :vcloudng_password, :vcloudng_host
secrets :vcloudng_password
@ -103,6 +109,7 @@ module Fog
request :post_vm_metadata
request :put_vm_metadata_value
request :delete_vm_metadata
request :post_vm_poweron
request :get_request
request :get_href

View file

@ -36,6 +36,16 @@ module Fog
end
end
def power_on
response = service.post_vm_poweron(id)
task_response = response.body
task_response[:id] = task_response[:href].split('/').last
task = service.tasks.new(task_response)
task.wait_for { non_running? }
raise Errors::Task.new "#{task.inspect}" if task.status != 'success'
true
end
def tags
requires :id
service.tags(:vm_id => id)

View file

@ -0,0 +1,19 @@
module Fog
module Compute
class Vcloudng
class Real
def post_vm_poweron(vm_id)
request(
:expects => 202,
:headers => { 'Accept' => 'application/*+xml;version=1.5' },
:method => 'POST',
:parser => Fog::ToHashDocument.new,
:path => "vApp/#{vm_id}/power/action/powerOn"
)
end
end
end
end
end