Class: VCloudCloud::Steps::AddCatalog

Inherits:
VCloudCloud::Step show all
Defined in:
lib/cloud/vcloud/steps/add_catalog.rb

Instance Attribute Summary

Attributes inherited from VCloudCloud::Step

#client, #state

Instance Method Summary collapse

Methods inherited from VCloudCloud::Step

#cleanup, #initialize

Constructor Details

This class inherits a constructor from VCloudCloud::Step

Instance Method Details

#perform(name, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cloud/vcloud/steps/add_catalog.rb', line 4

def perform(name, &block)
  catalog = VCloudSdk::Xml::WrapperFactory.create_instance 'AdminCatalog'
  catalog.name = name
  link = client.org.add_catalog_link
  begin
    result = client.invoke :post,
                           link,
                           :payload => catalog,
                           :headers => { :content_type => link.type }
    catalog = client.wait_entity result
    client.flush_cache
    return catalog
  rescue RestClient::BadRequest
    # check if catalog already exists; if so, this is not an error
    client.flush_cache
    catalog = client.org.catalog_link(name)
    if catalog
      return client.resolve_link(catalog)
    end
    raise
  end
end

#rollbackObject



27
28
29
30
# File 'lib/cloud/vcloud/steps/add_catalog.rb', line 27

def rollback
  # rollback is purposely not implemented because it could affect VMs
  # in other deployments that share the same catalog
end