Class: VCloudSdk::Xml::VirtualHardwareSection
- Inherits:
-
Wrapper
- Object
- Wrapper
- VCloudSdk::Xml::VirtualHardwareSection
show all
- Defined in:
- lib/cloud/vcloud/xml/wrapper_classes/virtual_hardware_section.rb
Instance Method Summary
collapse
Methods inherited from Wrapper
#==, #[], #[]=, #add_child, #attribute_with_ns, #content, #content=, #create_child, #create_qualified_name, #create_xpath_query, #doc_namespaces, #error, #get_nodes, #href, #href_id, #initialize, #name, #name=, #to_s, #type, #urn, #xpath
Instance Method Details
#add_item(item) ⇒ Object
5
6
7
8
|
# File 'lib/cloud/vcloud/xml/wrapper_classes/virtual_hardware_section.rb', line 5
def add_item(item)
system_node = get_nodes("System", nil, true, OVF).first
system_node.node.after(item.node)
end
|
#cpu ⇒ Object
15
16
17
18
|
# File 'lib/cloud/vcloud/xml/wrapper_classes/virtual_hardware_section.rb', line 15
def cpu
hardware.find { |h| h.get_rasd_content(RASD_TYPES[:RESOURCE_TYPE]) ==
HARDWARE_TYPE[:CPU] }
end
|
#edit_link ⇒ Object
10
11
12
13
|
# File 'lib/cloud/vcloud/xml/wrapper_classes/virtual_hardware_section.rb', line 10
def edit_link
get_nodes("Link", {"rel" => "edit",
"type" => MEDIA_TYPE[:VIRTUAL_HARDWARE_SECTION]}, true).first
end
|
#hard_disks ⇒ Object
57
58
59
60
61
|
# File 'lib/cloud/vcloud/xml/wrapper_classes/virtual_hardware_section.rb', line 57
def hard_disks
items = hardware.find_all { |h| h.get_rasd_content(
RASD_TYPES[:RESOURCE_TYPE]) == HARDWARE_TYPE[:HARD_DISK] }
items.map { |i| HardDiskItemWrapper.new(i) }
end
|
#hardware ⇒ Object
63
64
65
|
# File 'lib/cloud/vcloud/xml/wrapper_classes/virtual_hardware_section.rb', line 63
def hardware
get_nodes("Item", nil, false, OVF)
end
|
#highest_instance_id ⇒ Object
30
31
32
33
|
# File 'lib/cloud/vcloud/xml/wrapper_classes/virtual_hardware_section.rb', line 30
def highest_instance_id
ids = hardware.map{|h| h.get_rasd_content(RASD_TYPES[:INSTANCE_ID])}.compact
ids.map {|id| id.to_i}.max
end
|
#memory ⇒ Object
20
21
22
23
|
# File 'lib/cloud/vcloud/xml/wrapper_classes/virtual_hardware_section.rb', line 20
def memory
hardware.find { |h| h.get_rasd_content(RASD_TYPES[:RESOURCE_TYPE]) ==
HARDWARE_TYPE[:MEMORY] }
end
|
#nics ⇒ Object
35
36
37
38
39
|
# File 'lib/cloud/vcloud/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/cloud/vcloud/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/cloud/vcloud/xml/wrapper_classes/virtual_hardware_section.rb', line 41
def remove_nic(index)
remove_hw(HARDWARE_TYPE[:NIC], index)
end
|
#scsi_controller ⇒ Object
25
26
27
28
|
# File 'lib/cloud/vcloud/xml/wrapper_classes/virtual_hardware_section.rb', line 25
def scsi_controller
hardware.find { |h| h.get_rasd_content(RASD_TYPES[:RESOURCE_TYPE]) ==
HARDWARE_TYPE[:SCSI_CONTROLLER] }
end
|