Class: Vcloud::Core::VappTemplate
- Inherits:
-
Object
- Object
- Vcloud::Core::VappTemplate
- Defined in:
- lib/vcloud/core/vapp_template.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
-
.get(vapp_template_name, catalog_name) ⇒ String
Get a template by name and catalog.
-
.get_ids_by_name_and_catalog(name, catalog_name) ⇒ Array
Get a list of templates with a particular name in a catalog.
-
.id_prefix ⇒ String
Return the id_prefix to be used for vAppTemplates.
Instance Method Summary collapse
-
#href ⇒ String
Return the name of vAppTemplate.
-
#initialize(id) ⇒ Hash
constructor
Return the vCloud data associated with vApp.
-
#name ⇒ String
Return the name of vAppTemplate.
-
#vcloud_attributes ⇒ Hash
Return the vCloud data associated with vAppTemplate.
Constructor Details
#initialize(id) ⇒ Hash
Return the vCloud data associated with vApp
10 11 12 13 14 15 |
# 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 |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/vcloud/core/vapp_template.rb', line 5 def id @id end |
Class Method Details
.get(vapp_template_name, catalog_name) ⇒ String
Get a template by name and catalog
58 59 60 61 62 63 64 65 |
# 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) ⇒ Array
Get a list of templates with a particular name in a catalog
43 44 45 46 47 48 49 50 51 |
# 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 ⇒ String
Return the id_prefix to be used for vAppTemplates
70 71 72 |
# File 'lib/vcloud/core/vapp_template.rb', line 70 def self.id_prefix 'vappTemplate' end |
Instance Method Details
#href ⇒ String
Return the name of vAppTemplate
27 28 29 |
# File 'lib/vcloud/core/vapp_template.rb', line 27 def href vcloud_attributes[:href] end |
#name ⇒ String
Return the name of vAppTemplate
34 35 36 |
# File 'lib/vcloud/core/vapp_template.rb', line 34 def name vcloud_attributes[:name] end |
#vcloud_attributes ⇒ Hash
Return the vCloud data associated with vAppTemplate
20 21 22 |
# File 'lib/vcloud/core/vapp_template.rb', line 20 def vcloud_attributes Vcloud::Core::Fog::ServiceInterface.new.get_vapp_template(id) end |