Class: VCloudCloud::Steps::CreateTemplate

Inherits:
VCloudCloud::Step show all
Defined in:
lib/cloud/vcloud/steps/create_template.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, catalog_type, &block) ⇒ Object



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

def perform(name, catalog_type, &block)
  catalog = client.catalog catalog_type

  params = VCloudSdk::Xml::WrapperFactory.create_instance 'UploadVAppTemplateParams'
  params.name = name
  upload_link = catalog.add_vapp_template_link
  catalog_item = client.invoke(
    :post,
    upload_link,
    :payload => params,
    :headers => {:content_type => upload_link.type}
  )

  template = client.invoke :get, catalog_item.entity.href

  # commit states
  state[:catalog_item] = catalog_item
  state[:vapp_template] = template
end

#rollbackObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cloud/vcloud/steps/create_template.rb', line 24

def rollback
  template = state[:vapp_template]
  if template
    if template.cancel_link
      client.invoke :post, template.cancel_link
      template = client.reload template
    end
    if template.remove_link
      client.invoke_and_wait :delete, template.remove_link
    end
  end
end