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



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

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

#network_connection(index) ⇒ Object



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

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

#network_connectionsObject



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

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
    fail ObjectNotFoundError,
         "Cannot remove network connection #{index}: does not exist."
  end
end