mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[vcloud_director] Add post_capture_vapp request.
This commit is contained in:
parent
2a18843704
commit
e8edcc0717
4 changed files with 93 additions and 0 deletions
|
@ -110,6 +110,7 @@ module Fog
|
|||
request :get_vms_by_metadata
|
||||
request :instantiate_vapp_template
|
||||
request :post_cancel_task
|
||||
request :post_capture_vapp
|
||||
request :post_power_off_vapp
|
||||
request :post_power_on_vapp
|
||||
request :post_reboot_vapp
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
module Fog
|
||||
module Generators
|
||||
module Compute
|
||||
module VcloudDirector
|
||||
require 'fog/vcloud_director/generators/compute/base'
|
||||
|
||||
# Parameters for a captureVapp request.
|
||||
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/types/CaptureVAppParamsType.html
|
||||
# vCloud API Documentation
|
||||
class CaptureVappParams < Base
|
||||
|
||||
attr_reader :name, :source_href
|
||||
|
||||
def initialize(name, source_href, options={})
|
||||
super options
|
||||
@name = name
|
||||
@source_href = source_href
|
||||
end
|
||||
|
||||
# @api private
|
||||
# @return [Nokogiri::XML::Builder]
|
||||
def builder
|
||||
@builder ||= Nokogiri::XML::Builder.new do |xml|
|
||||
attrs = {:xmlns => 'http://www.vmware.com/vcloud/v1.5', :name => name}
|
||||
xml.CaptureVAppParams(attrs) {
|
||||
xml.Description options[:Description] || ''
|
||||
xml.Source(:href => source_href)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,39 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class VcloudDirector
|
||||
class Real
|
||||
require 'fog/vcloud_director/generators/compute/capture_vapp_params'
|
||||
|
||||
# Create a vApp template from a vApp.
|
||||
#
|
||||
# The response includes a Task element. You can monitor the task to to
|
||||
# track the creation of the vApp template.
|
||||
#
|
||||
# @param [String] vdc_id Object identifier of the vDC.
|
||||
# @param [String] name Name of the vApp template.
|
||||
# @param [String] source_id Object identifier of the vApp to capture.
|
||||
# @param [Hash] options
|
||||
# @option options [String] :Description Optional description.
|
||||
# @return [Excon::Response]
|
||||
# * body<~Hash>:
|
||||
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/POST-CaptureVApp.html
|
||||
# vCloud API Documentation
|
||||
# @since vCloud API version 0.9
|
||||
def post_capture_vapp(vdc_id, name, source_id, options={})
|
||||
body = Fog::Generators::Compute::VcloudDirector::CaptureVappParams.new(
|
||||
name, "#{endpoint}vApp/#{source_id}", options
|
||||
)
|
||||
|
||||
request(
|
||||
:body => body.to_xml,
|
||||
:expects => 201,
|
||||
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.captureVAppParams+xml'},
|
||||
:method => 'POST',
|
||||
:parser => Fog::ToHashDocument.new,
|
||||
:path => "vdc/#{vdc_id}/action/captureVApp"
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
Shindo.tests('Compute::VcloudDirector | CaptureVAppParams generator', ['vclouddirector', 'xsd']) do
|
||||
|
||||
require 'fog/vcloud_director/generators/compute/capture_vapp_params'
|
||||
|
||||
tests('#to_xml').returns(String) do
|
||||
@capture_vapp_params = Fog::Generators::Compute::VcloudDirector::CaptureVappParams.new(
|
||||
'name', 'http://example.com/api/vApp/0'
|
||||
)
|
||||
@capture_vapp_params.to_xml.class
|
||||
end
|
||||
|
||||
tests('#validate').returns([]) do
|
||||
pending unless VcloudDirector::Generators::Helpers.have_xsd?
|
||||
VcloudDirector::Generators::Helpers.validate(@capture_vapp_params.doc)
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue