Class: VCloudSdk::Xml::NetworkConnectionSection

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/ruby_vcloud_sdk/xml/wrapper_classes/network_connection_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, #edit_link, #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



5
6
7
8
# File 'lib/ruby_vcloud_sdk/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

#network_connection(index) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/network_connection_section.rb', line 14

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



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

def network_connections
  get_nodes("NetworkConnection")
end

#primary_network_connection_indexObject

This will be nil if there are no network connections



24
25
26
27
28
29
30
31
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/network_connection_section.rb', line 24

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



33
34
35
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/network_connection_section.rb', line 33

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

#remove_network_connection(index) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/ruby_vcloud_sdk/xml/wrapper_classes/network_connection_section.rb', line 37

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