Class: VCloudSdk::Xml::NetworkConnectionSection

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/cloud/vcloud/xml/wrapper_classes/network_connection_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

Constructor Details

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

Instance Method Details

#add_item(item) ⇒ Object



5
6
7
8
# File 'lib/cloud/vcloud/xml/wrapper_classes/network_connection_section.rb', line 5

def add_item(item)
  link_node = get_nodes("Link").first
  link_node.node.before(item.node)
end


10
11
12
# File 'lib/cloud/vcloud/xml/wrapper_classes/network_connection_section.rb', line 10

def edit_link
  get_nodes("Link", {"rel" => "edit"}, true).first
end

#network_connection(index) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/cloud/vcloud/xml/wrapper_classes/network_connection_section.rb', line 18

def network_connection(index)
  net = network_connections.find {
    |n| n.network_connection_index == index.to_s }
  unless net
    raise ObjectNotFoundError, "Network connection #{index} does not exist."
  end
  net
end

#network_connectionsObject



14
15
16
# File 'lib/cloud/vcloud/xml/wrapper_classes/network_connection_section.rb', line 14

def network_connections
  get_nodes("NetworkConnection")
end

#primary_network_connection_indexObject

This will be nil if there are no network connections



28
29
30
31
32
33
34
35
# File 'lib/cloud/vcloud/xml/wrapper_classes/network_connection_section.rb', line 28

def primary_network_connection_index
  node = get_nodes("PrimaryNetworkConnectionIndex").first
  if node.nil?
    nil
  else
    node.content
  end
end

#primary_network_connection_index=(index) ⇒ Object



37
38
39
# File 'lib/cloud/vcloud/xml/wrapper_classes/network_connection_section.rb', line 37

def primary_network_connection_index=(index)
  get_nodes("PrimaryNetworkConnectionIndex").first.content = index
end

#remove_network_connection(index) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/cloud/vcloud/xml/wrapper_classes/network_connection_section.rb', line 41

def remove_network_connection(index)
  connection = network_connection(index)
  if connection
    connection.node.remove
    reconcile_primary_network()
  else
    raise ObjectNotFoundError,
      "Cannot remove network connection #{index}: does not exist."
  end
end