Class: Vcloud::Walker::Resource::Vm

Inherits:
Entity
  • Object
show all
Defined in:
lib/vcloud/walker/resource/vm.rb

Constant Summary collapse

HARDWARE_RESOURCE_TYPES =
{
    :cpu => '3',
    :memory => '4',
    :hard_disk => '17',
    :network_adapter => '10'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#to_summary

Constructor Details

#initialize(fog_vm) ⇒ Vm

Returns a new instance of Vm.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vcloud/walker/resource/vm.rb', line 28

def initialize fog_vm
  @id = extract_id(fog_vm[:href])
  @status = fog_vm[:status]
  @operating_system = fog_vm[:'ovf:OperatingSystemSection'][:'ovf:Description']
  @network_connections = fog_vm[:NetworkConnectionSection][:NetworkConnection] if fog_vm[:NetworkConnectionSection]
  @primary_network_connection_index = fog_vm[:NetworkConnectionSection][:PrimaryNetworkConnectionIndex]
  extract_compute_capacity fog_vm[:'ovf:VirtualHardwareSection'][:'ovf:Item']
  @vmware_tools = fog_vm[:RuntimeInfoSection][:VMWareTools]
  @virtual_system_type = extract_virtual_system_type(fog_vm[:'ovf:VirtualHardwareSection'])
  @storage_profile = {
    :id   => fog_vm[:StorageProfile][:href].split('/').last,
    :name => fog_vm[:StorageProfile][:name],
  }
  @metadata = Vcloud::Core::Vm.(id)
end

Instance Attribute Details

#cpuObject (readonly)

Returns the value of attribute cpu.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def cpu
  @cpu
end

#disksObject (readonly)

Returns the value of attribute disks.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def disks
  @disks
end

#idObject (readonly)

Returns the value of attribute id.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def id
  @id
end

#memoryObject (readonly)

Returns the value of attribute memory.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def memory
  @memory
end

#metadataObject (readonly)

Returns the value of attribute metadata.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def 
  @metadata
end

#network_cardsObject (readonly)

Returns the value of attribute network_cards.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def network_cards
  @network_cards
end

#network_connectionsObject (readonly)

Returns the value of attribute network_connections.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def network_connections
  @network_connections
end

#operating_systemObject (readonly)

Returns the value of attribute operating_system.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def operating_system
  @operating_system
end

#primary_network_connection_indexObject (readonly)

Returns the value of attribute primary_network_connection_index.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def primary_network_connection_index
  @primary_network_connection_index
end

#statusObject (readonly)

Returns the value of attribute status.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def status
  @status
end

#storage_profileObject (readonly)

Returns the value of attribute storage_profile.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def storage_profile
  @storage_profile
end

#virtual_system_typeObject (readonly)

Returns the value of attribute virtual_system_type.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def virtual_system_type
  @virtual_system_type
end

#vmware_toolsObject (readonly)

Returns the value of attribute vmware_tools.



16
17
18
# File 'lib/vcloud/walker/resource/vm.rb', line 16

def vmware_tools
  @vmware_tools
end