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) ⇒ Vcloud::Core::Vdc

Initialize a Vcloud::Core::Vdc

Parameters:

  • id (String)

    the vDC ID



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

#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) ⇒ String

Get the ID of a named vDC

Parameters:

  • name (String)

    The name of the vDC

Returns:

  • (String)

    The ID of the 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

#hrefString

Return the href of vDC

Returns:

  • (String)

    the href of instance



47
48
49
# File 'lib/vcloud/core/vdc.rb', line 47

def href
  vcloud_attributes[:href]
end

#nameString

Return the name of vDC

Returns:

  • (String)

    the name of instance



40
41
42
# File 'lib/vcloud/core/vdc.rb', line 40

def name
  vcloud_attributes[:name]
end

#vcloud_attributesHash

Return the vCloud data associated with vDC

Returns:

  • (Hash)

    the complete vCloud data for vDC



33
34
35
# File 'lib/vcloud/core/vdc.rb', line 33

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