Class: VCloudSdk::Xml::VirtualHardwareSection

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb

Instance Method Summary collapse

Methods inherited from Wrapper

#==, #[], #[]=, #add_child, #attribute, #content, #content=, #create_child, #create_qualified_name, #create_xpath_query, #doc_namespaces, #get_nodes, #href, #href=, #href_id, #initialize, #name, #name=, #power_off_link, #power_on_link, #remove_link, #running_tasks, #to_s, #type, #type=, #undeploy_link, #urn, #xpath

Constructor Details

This class inherits a constructor from VCloudSdk::Xml::Wrapper

Instance Method Details

#add_item(item) ⇒ Object



4
5
6
7
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb', line 4

def add_item(item)
  system_node = get_nodes("System", nil, true, OVF).first
  system_node.node.after(item.node)
end

#cpuObject



16
17
18
19
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb', line 16

def cpu
  hardware.find { |h| h.get_rasd_content(RASD_TYPES[:RESOURCE_TYPE]) ==
    HARDWARE_TYPE[:CPU] }
end


9
10
11
12
13
14
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb', line 9

def edit_link
  get_nodes(XML_TYPE[:LINK],
            { rel: XML_TYPE[:EDIT],
              type: MEDIA_TYPE[:VIRTUAL_HARDWARE_SECTION] },
            true).first
end

#hard_disksObject



57
58
59
60
61
62
63
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb', line 57

def hard_disks
  items = hardware.select do |h|
    h.get_rasd_content(
    RASD_TYPES[:RESOURCE_TYPE]) == HARDWARE_TYPE[:HARD_DISK]
  end
  items.map { |i| HardDiskItemWrapper.new(i) }
end

#hardwareObject



65
66
67
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb', line 65

def hardware
  get_nodes("Item", nil, false, OVF)
end

#highest_instance_idObject



31
32
33
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb', line 31

def highest_instance_id
  hardware.map{|h| h.instance_id}.max
end

#memoryObject



21
22
23
24
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb', line 21

def memory
  hardware.find { |h| h.get_rasd_content(RASD_TYPES[:RESOURCE_TYPE]) ==
    HARDWARE_TYPE[:MEMORY] }
end

#nicsObject



35
36
37
38
39
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb', line 35

def nics
  items = hardware.find_all {|h| h.get_rasd_content(
    RASD_TYPES[:RESOURCE_TYPE]) == HARDWARE_TYPE[:NIC] }
  items.map { |i| NicItemWrapper.new(i) }
end

#remove_hw(hw_type, index) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb', line 45

def remove_hw(hw_type, index)
  item = hardware.find { |h|
    h.get_rasd_content(RASD_TYPES[:RESOURCE_TYPE]) == hw_type &&
    h.get_rasd_content(RASD_TYPES[:ADDRESS_ON_PARENT]) == index }
  if item
    item.node.remove
  else
    raise ObjectNotFoundError,
      "Cannot remove hw item #{hw_type}:#{index}, does not exist."
  end
end

#remove_nic(index) ⇒ Object



41
42
43
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb', line 41

def remove_nic(index)
  remove_hw(HARDWARE_TYPE[:NIC], index)
end

#scsi_controllerObject



26
27
28
29
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb', line 26

def scsi_controller
  hardware.find { |h| h.get_rasd_content(RASD_TYPES[:RESOURCE_TYPE]) ==
    HARDWARE_TYPE[:SCSI_CONTROLLER] }
end