diff --git a/lib/fog/vcloudng/compute.rb b/lib/fog/vcloudng/compute.rb index 1938ddd1b..62f335793 100644 --- a/lib/fog/vcloudng/compute.rb +++ b/lib/fog/vcloudng/compute.rb @@ -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 diff --git a/lib/fog/vcloudng/models/compute/vm.rb b/lib/fog/vcloudng/models/compute/vm.rb index 0e6ecedd3..32bf32029 100644 --- a/lib/fog/vcloudng/models/compute/vm.rb +++ b/lib/fog/vcloudng/models/compute/vm.rb @@ -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) diff --git a/lib/fog/vcloudng/requests/compute/post_vm_poweron.rb b/lib/fog/vcloudng/requests/compute/post_vm_poweron.rb new file mode 100644 index 000000000..1d8d5c7e6 --- /dev/null +++ b/lib/fog/vcloudng/requests/compute/post_vm_poweron.rb @@ -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