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

Merge pull request #2481 from alphagov/vcloud_director_put_vapp

vApp rename via put_vapp_name_and_description
This commit is contained in:
Nick Osborn 2013-12-17 02:49:25 -08:00
commit e64931a56e
3 changed files with 68 additions and 0 deletions

View file

@ -244,6 +244,7 @@ module Fog
request :put_metadata_value # deprecated
request :put_network_connection_system_section_vapp
request :put_vapp_metadata_item_metadata
request :put_vapp_name_and_description
request :put_vapp_template_metadata_item_metadata
request :put_vm
request :put_vm_capabilities

View file

@ -0,0 +1,30 @@
module Fog
module Generators
module Compute
module VcloudDirector
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/types/VAppType.html
class Vapp
attr_reader :name, :options
def initialize(name, options={})
@name = name
@options = options
end
def generate_xml
attrs = @attrs
Nokogiri::XML::Builder.new do
VApp('xmlns' => 'http://www.vmware.com/vcloud/v1.5',
'name' => name
) {
Description options[:Description] if options.key?(:Description)
}
end.to_xml
end
end
end
end
end
end

View file

@ -0,0 +1,37 @@
module Fog
module Compute
class VcloudDirector
class Real
require 'fog/vcloud_director/generators/compute/vapp'
# Modify the name or description of a vApp.
#
# This operation is asynchronous and returns a task that you can monitor
# to track the progress of the request.
#
#
# @param [String] id Object identifier of the vApp.
# @param [String] name of the vApp.
# @param [Hash] options
# * :Description<~String>: - description to be assigned (optional)
# @return [Excon::Response]
# * body<~Hash>:
#
# @see http://pubs.vmware.com/vcd-55/topic/com.vmware.vcloud.api.reference.doc_55/doc/operations/PUT-VAppNameAndDescription.html
# @since vCloud API version 0.9
def put_vapp_name_and_description(id, name, options={})
body = Fog::Generators::Compute::VcloudDirector::Vapp.new(name, options).generate_xml
request(
:body => body,
:expects => 202,
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.vApp+xml'},
:method => 'PUT',
:parser => Fog::ToHashDocument.new,
:path => "vApp/#{id}"
)
end
end
end
end
end