class VCloudSdk::Xml::NetworkConnectionSection

Public Instance Methods

add_item(item) click to toggle source
# 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) click to toggle source
# 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_connections() click to toggle source
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/network_connection_section.rb, line 9
def network_connections
  get_nodes("NetworkConnection")
end
primary_network_connection_index() click to toggle source

This will be nil if there are no network connections

# 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) click to toggle source
# 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) click to toggle source
# 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

Private Instance Methods

reconcile_primary_network() click to toggle source
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/network_connection_section.rb, line 50
def reconcile_primary_network
  new_primary = network_connections.first
  if new_primary
    primary_index = new_primary.network_connection_index
    self.primary_network_connection_index = primary_index
    primary_index
  else
    primary = get_nodes("PrimaryNetworkConnectionIndex").first
    primary.node.remove if primary
    nil
  end
end