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) ⇒ Object
- .get_ids_by_name_and_catalog(name, catalog_name) ⇒ Object
- .id_prefix ⇒ Object
Instance Method Summary collapse
- #href ⇒ Object
-
#initialize(id) ⇒ VappTemplate
constructor
A new instance of VappTemplate.
- #name ⇒ Object
- #vcloud_attributes ⇒ Object
Constructor Details
#initialize(id) ⇒ VappTemplate
Returns a new instance of VappTemplate.
7 8 9 10 11 12 |
# File 'lib/vcloud/core/vapp_template.rb', line 7 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) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/vcloud/core/vapp_template.rb', line 36 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) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/vcloud/core/vapp_template.rb', line 26 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 ⇒ Object
45 46 47 |
# File 'lib/vcloud/core/vapp_template.rb', line 45 def self.id_prefix 'vappTemplate' end |
Instance Method Details
#href ⇒ Object
18 19 20 |
# File 'lib/vcloud/core/vapp_template.rb', line 18 def href vcloud_attributes[:href] end |
#name ⇒ Object
22 23 24 |
# File 'lib/vcloud/core/vapp_template.rb', line 22 def name vcloud_attributes[:name] end |
#vcloud_attributes ⇒ Object
14 15 16 |
# File 'lib/vcloud/core/vapp_template.rb', line 14 def vcloud_attributes Vcloud::Core::Fog::ServiceInterface.new.get_vapp_template(id) end |