Class: Vcloud::Core::Vdc
- Inherits:
-
Object
- Object
- Vcloud::Core::Vdc
- Defined in:
- lib/vcloud/core/vdc.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
-
.get_by_name(name) ⇒ String
Get the ID of a named vDC.
Instance Method Summary collapse
-
#href ⇒ String
Return the href of vDC.
-
#initialize(id) ⇒ Vcloud::Core::Vdc
constructor
Initialize a Vcloud::Core::Vdc.
-
#name ⇒ String
Return the name of vDC.
-
#vcloud_attributes ⇒ Hash
Return the vCloud data associated with vDC.
Constructor Details
#initialize(id) ⇒ Vcloud::Core::Vdc
Initialize a Vcloud::Core::Vdc
11 12 13 14 15 16 |
# File 'lib/vcloud/core/vdc.rb', line 11 def initialize(id) unless id =~ /^[-0-9a-f]+$/ raise "vdc 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/vdc.rb', line 5 def id @id end |
Class Method Details
.get_by_name(name) ⇒ String
Get the ID of a named vDC
22 23 24 25 26 27 28 |
# File 'lib/vcloud/core/vdc.rb', line 22 def self.get_by_name(name) q = Vcloud::Core::QueryRunner.new query_results = q.run('orgVdc', :filter => "name==#{name}") raise "Error finding vDC by name #{name}" unless query_results raise "vDc #{name} not found" unless query_results.size == 1 return self.new(query_results.first[:href].split('/').last) end |
Instance Method Details
#href ⇒ String
Return the href of vDC
47 48 49 |
# File 'lib/vcloud/core/vdc.rb', line 47 def href vcloud_attributes[:href] end |
#name ⇒ String
Return the name of vDC
40 41 42 |
# File 'lib/vcloud/core/vdc.rb', line 40 def name vcloud_attributes[:name] end |
#vcloud_attributes ⇒ Hash
Return the vCloud data associated with vDC
33 34 35 |
# File 'lib/vcloud/core/vdc.rb', line 33 def vcloud_attributes Vcloud::Core::Fog::ServiceInterface.new.get_vdc(id) end |