class Vcloud::Core::VappTemplate

Attributes

id[R]

Public Class Methods

get(vapp_template_name, catalog_name) click to toggle source

Get a template by name and catalog

@param vapp_template_name [String] The name of the vAppTemplate @param catalog_name [String] The name of the catalog containing vAppTemplate @return [String] the ID of the template

# File lib/vcloud/core/vapp_template.rb, line 58
def self.get vapp_template_name, catalog_name
  ids = self.get_ids_by_name_and_catalog(vapp_template_name, catalog_name)
  raise 'Could not find template vApp' if ids.size == 0
  if ids.size > 1
    raise "Template #{vapp_template_name} is not unique in catalog #{catalog_name}"
  end
  return self.new(ids.first)
end
get_ids_by_name_and_catalog(name, catalog_name) click to toggle source

Get a list of templates with a particular name in a catalog

@param name [String] The name of the vAppTemplate to find @param catalog_name [String] The name of the catalog to search @return [Array] an array of IDs of matching templates

# File lib/vcloud/core/vapp_template.rb, line 43
def self.get_ids_by_name_and_catalog name, catalog_name
  raise "provide Catalog and vAppTemplate name" unless name && catalog_name
  q = Vcloud::Core::QueryRunner.new
  query_results = q.run('vAppTemplate', :filter => "name==#{name};catalogName==#{catalog_name}")
  raise "Error retreiving #{q.type} query '#{q.filter}'" unless query_results
  query_results.collect do |record|
    record[:href].split('/').last if record.key?(:href)
  end
end
id_prefix() click to toggle source

Return the id_prefix to be used for vAppTemplates

@return [String] returns 'vappTemplate' as an id_prefix

# File lib/vcloud/core/vapp_template.rb, line 70
def self.id_prefix
  'vappTemplate'
end
new(id) click to toggle source

Return the vCloud data associated with vApp

@return [Hash] the complete vCloud data for vApp

# File lib/vcloud/core/vapp_template.rb, line 10
def initialize(id)
  unless id =~ /^#{self.class.id_prefix}-[-0-9a-f]+$/
    raise "#{self.class.id_prefix} id : #{id} is not in correct format"
  end
  @id = id
end

Public Instance Methods

href() click to toggle source

Return the name of vAppTemplate

@return [String] the name of instance

# File lib/vcloud/core/vapp_template.rb, line 27
def href
  vcloud_attributes[:href]
end
name() click to toggle source

Return the name of vAppTemplate

@return [String] the name of instance

# File lib/vcloud/core/vapp_template.rb, line 34
def name
  vcloud_attributes[:name]
end
vcloud_attributes() click to toggle source

Return the vCloud data associated with vAppTemplate

@return [Hash] the complete vCloud data for vAppTemplate

# File lib/vcloud/core/vapp_template.rb, line 20
def vcloud_attributes
  Vcloud::Core::Fog::ServiceInterface.new.get_vapp_template(id)
end