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

[vcloud_director] Explicitly handle duplicate names.

This commit is contained in:
Nick Osborn 2013-10-14 18:30:24 +01:00
parent f521ad2ed0
commit 739f9e2731

View file

@ -45,6 +45,8 @@ module Fog
# @return [Excon::Response] # @return [Excon::Response]
# * body<~Hash>: # * body<~Hash>:
# #
# @raise Fog::Compute::VcloudDirector::DuplicateName
#
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/POST-InstantiateVAppTemplate.html # @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/POST-InstantiateVAppTemplate.html
# @since vCloud API version 0.9 # @since vCloud API version 0.9
def post_instantiate_vapp_template(id, vapp_template_id, name, options={}) def post_instantiate_vapp_template(id, vapp_template_id, name, options={})
@ -109,14 +111,21 @@ module Fog
} }
end.to_xml end.to_xml
request( begin
:body => body, request(
:expects => 201, :body => body,
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml'}, :expects => 201,
:method => 'POST', :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml'},
:parser => Fog::ToHashDocument.new, :method => 'POST',
:path => "vdc/#{id}/action/instantiateVAppTemplate" :parser => Fog::ToHashDocument.new,
) :path => "vdc/#{id}/action/instantiateVAppTemplate"
)
rescue Fog::Compute::VcloudDirector::BadRequest => e
if e.minor_error_code == 'DUPLICATE_NAME'
raise Fog::Compute::VcloudDirector::DuplicateName.new(e.message)
end
raise
end
end end
end end
end end