Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[vcloud_director] Implement post_create_catalog_item #2530

Merged
merged 1 commit into from

4 participants

@nosborn
Collaborator

No description provided.

@geemus
Owner

@nosborn - thanks!

@restebanez - could you review?

@coveralls

Coverage Status

Coverage increased (+0.16%) when pulling adaf1dc on nosborn:vcloud_director_create_catalog_item into 4d8d0b0 on fog:master.

@coveralls

Coverage Status

Coverage remained the same when pulling adaf1dc on nosborn:vcloud_director_create_catalog_item into 4d8d0b0 on fog:master.

@coveralls

Coverage Status

Coverage remained the same when pulling b79a429 on nosborn:vcloud_director_create_catalog_item into 86bf2d8 on fog:master.

@philandstuff

I'd be interested in seeing this and #2531 merged. Can I do anything to help move it along?

@philandstuff

if it helps, we've been using both of these PRs (via our alphagov/fog fork) to capture vApp templates and create catalog items for a few months now, and can confirm that these PRs work as expected.

@geemus geemus merged commit b083fcf into from
@philandstuff

@geemus thanks very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 2, 2014
This page is out of date. Refresh to see the latest.
View
1  lib/fog/vcloud_director/compute.rb
@@ -203,6 +203,7 @@ class TaskError < Fog::VcloudDirector::Errors::TaskError; end
request :post_configure_edge_gateway_services
request :post_consolidate_vm_vapp
request :post_consolidate_vm_vapp_template
+ request :post_create_catalog_item
request :post_create_org_vdc_network
request :post_deploy_vapp
request :post_detach_disk
View
56 lib/fog/vcloud_director/requests/compute/post_create_catalog_item.rb
@@ -0,0 +1,56 @@
+module Fog
+ module Compute
+ class VcloudDirector
+ class Real
+ # Add an item to a catalog.
+ #
+ # @param [String] id Object identifier of the catalog.
+ # @param [String] name The name of the entity.
+ # @param [Hash] entity A reference to a VAppTemplate or Media object.
+ # * href<~String> - Contains the URI to the entity.
+ # @param [Hash] options
+ # @option options [String] :operationKey Optional unique identifier to
+ # support idempotent semantics for create and delete operations.
+ # @option options [String] :Description Optional description.
+ # @return [Excon::Response]
+ # * 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-CreateCatalogItem.html
+ # @since vCloud API version 0.9
+ def post_create_catalog_item(id, name, entity, options={})
+ body = Nokogiri::XML::Builder.new do
+ attrs = {
+ :xmlns => 'http://www.vmware.com/vcloud/v1.5',
+ :name => name,
+ }
+ attrs[:operationKey] = options[:operationKey] if options.key?(:operationKey)
+ CatalogItem(attrs) {
+ if options.key?(:Description)
+ Description options[:Description]
+ end
+ Entity(entity)
+ }
+ end.to_xml
+
+ begin
+ request(
+ :body => body,
+ :expects => 201,
+ :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.catalogItem+xml'},
+ :method => 'POST',
+ :parser => Fog::ToHashDocument.new,
+ :path => "catalog/#{id}/catalogItems"
+ )
+ 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
Something went wrong with that request. Please try again.