Class: Vcloud::Core::Vdc

Inherits:
Object
  • Object
show all
Defined in:
lib/vcloud/core/vdc.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Vdc

Returns a new instance of Vdc.



7
8
9
10
11
12
# File 'lib/vcloud/core/vdc.rb', line 7

def initialize(id)
  unless id =~ /^[-0-9a-f]+$/
    raise "vdc id : #{id} is not in correct format"
  end
  @id = id
end

Instance Attribute Details

#idObject (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) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/vcloud/core/vdc.rb', line 14

def self.get_by_name(name)
  q = QueryRunner.new
  unless res = q.run('orgVdc', :filter => "name==#{name}")
    raise "Error finding vDC by name #{name}"
  end
  raise "vDc #{name} not found" unless res.size == 1
  return self.new(res.first[:href].split('/').last)
end

Instance Method Details

#hrefObject



31
32
33
# File 'lib/vcloud/core/vdc.rb', line 31

def href
  vcloud_attributes[:href]
end

#nameObject



27
28
29
# File 'lib/vcloud/core/vdc.rb', line 27

def name
  vcloud_attributes[:name]
end

#vcloud_attributesObject



23
24
25
# File 'lib/vcloud/core/vdc.rb', line 23

def vcloud_attributes
  Vcloud::Fog::ServiceInterface.new.get_vdc(id)
end