lib/ruby_nsx_cli/nsx_objects/nsx_edge.rb
def attach_interface(edge_id:, name:, primary_address:, subnet_mask:, mtu:, connected_to_id:, type:)
      api_endpoint = "/api/4.0/edges/#{edge_id}/interfaces/?action=patch"

      interface_hash = {
          :name => name,
          :primary_address => primary_address,
          :subnet_mask => subnet_mask,
          :mtu => mtu || 1500,
          :connected_to_id => connected_to_id,
          :type => type
      }

      validate_edge_args(interface_hash, edge_id)
      raise "The interface type must be one of: #{INTERFACE_TYPES.to_s}" if !INTERFACE_TYPES.include?(interface_hash[:type])

      @logger.info("Checking if interface already exists on edge: #{edge_id}")
      if (interface = check_interface_exists(edge_id, connected_to_id))
        @logger.info("Skipping interface - interface already exists (edgeId: #{edge_id} connectedToId: #{connected_to_id})")
        return interface
      end


      interface_obj = OpenStruct.new(interface_hash)
      payload = render_template('/templates/interface/interfaces.xml.erb', interface_obj)

      post(:api_endpoint => api_endpoint, :payload => payload)
    end
# Attaches an interface to the specified edge
#
# @param edge_id [String] Edge ID to
# @param name [String] Name of the interface
# @param primary_address [Integer] Primary IP address for the interface
# @param subnet_mask [String] Subnet mask for the network that the interface is attached to
# @param mtu [Integer] Maximum transmission unit for the interface
# @param connected_to_id [String] ID of the virtualwire or port group to attach the interface to
# @param type [Type] Network link type; either 'internal' or 'uplink'
# @return [String] Interface XML configuration from the NSX API
Attaches an interface to the specified edge
Attaches an interface to the specified edge
def attach_interface(edge_id:, name:, primary_address:, subnet_mask:, mtu:, connected_to_id:, type:)
      api_endpoint = "/api/4.0/edges/#{edge_id}/interfaces/?action=patch"
      interface_hash = {
          :name => name,
          :primary_address => primary_address,
          :subnet_mask => subnet_mask,
          :mtu => mtu || 1500,
          :connected_to_id => connected_to_id,
          :type => type
      }
      validate_edge_args(interface_hash, edge_id)
      raise "The interface type must be one of: #{INTERFACE_TYPES.to_s}" if !INTERFACE_TYPES.include?(interface_hash[:type])
      @logger.info("Checking if interface already exists on edge: #{edge_id}")
      if (interface = check_interface_exists(edge_id, connected_to_id))
        @logger.info("Skipping interface - interface already exists (edgeId: #{edge_id} connectedToId: #{connected_to_id})")
        return interface
      end
      interface_obj = OpenStruct.new(interface_hash)
      payload = render_template('/templates/interface/interfaces.xml.erb', interface_obj)
      post(:api_endpoint => api_endpoint, :payload => payload)
    end
def attach_interface ( edge_id : , name : , primary_address : , subnet_mask : , mtu : , connected_to_id : , type : ) api_endpoint = "/api/4.0/edges/#{edge_id}/interfaces/?action=patch" interface_hash = { :name => name , :primary_address => primary_address , :subnet_mask => subnet_mask , :mtu => mtu || 1500 , :connected_to_id => connected_to_id , :type => type } validate_edge_args ( interface_hash , edge_id ) raise "The interface type must be one of: #{INTERFACE_TYPES.to_s}" if ! INTERFACE_TYPES . include? ( interface_hash [ :type ] ) @logger . info ( "Checking if interface already exists on edge: #{edge_id}" ) if ( interface = check_interface_exists ( edge_id , connected_to_id ) ) @logger . info ( "Skipping interface - interface already exists (edgeId: #{edge_id} connectedToId: #{connected_to_id})" ) return interface end interface_obj = OpenStruct . new ( interface_hash ) payload = render_template ( '/templates/interface/interfaces.xml.erb' , interface_obj ) post ( :api_endpoint => api_endpoint , :payload => payload ) end
Attaches an interface to the specified edge
Attaches an interface to the specified edge
Interface XML configuration from the NSX API
Interface XML configuration from the NSX API
String
edge_id
Edge ID to
Edge ID to
name
Name of the interface
Name of the interface
primary_address
Primary IP address for the interface
Primary IP address for the interface
subnet_mask
Subnet mask for the network that the interface is attached to
Subnet mask for the network that the interface is attached to
mtu
Maximum transmission unit for the interface
Maximum transmission unit for the interface
connected_to_id
ID of the virtualwire or port group to attach the interface to
ID of the virtualwire or port group to attach the interface to
type
Network link type; either 'internal' or 'uplink'
Network link type ; either ' internal ' or ' uplink '