Class: Rbeapi::Api::VxlanInterface

Inherits:
BaseInterface show all
Defined in:
lib/rbeapi/api/interfaces.rb

Overview

The VxlanInterface class manages all Vxlan interfaces on an EOS node.

Constant Summary collapse

DEFAULT_SRC_INTF =
''.freeze
DEFAULT_MCAST_GRP =
''.freeze

Constants inherited from BaseInterface

BaseInterface::DEFAULT_INTF_DESCRIPTION, BaseInterface::DEFAULT_INTF_ENCAPSULATION, BaseInterface::DEFAULT_LOAD_INTERVAL

Instance Attribute Summary

Attributes inherited from Entity

#config, #error, #node

Instance Method Summary collapse

Methods inherited from BaseInterface

#create, #default, #delete, #set_description, #set_encapsulation, #set_load_interval, #set_shutdown

Methods inherited from Entity

#command_builder, #configure, #configure_interface, #get_block, #initialize, instance

Constructor Details

This class inherits a constructor from Rbeapi::Api::Entity

Instance Method Details

#add_vtep(name, vtep) ⇒ Boolean

add_vtep adds a new VTEP endpoint to the global flood list for the specified interface. If the VTEP endpoint is already configured, this method will still return successfully.

Parameters:

  • name (String)

    The name of the interface to configure.

  • vtep (String)

    The IP address of the remote VTEP endpoint.

Returns:

  • (Boolean)

    Returns true if the commands completed successfully.

Since:

  • eos_version 4.13.7M



1404
1405
1406
# File 'lib/rbeapi/api/interfaces.rb', line 1404

def add_vtep(name, vtep)
  configure_interface(name, "vxlan flood vtep add #{vtep}")
end

#get(name = 'Vxlan1') ⇒ nil, Hash<String, String>

Returns the Vxlan interface configuration as a Ruby hash of key/value pairs from the nodes running configuration. This method extends the BaseInterface get method and adds the Vxlan specific attributes to the hash.

Examples:

{
  name: <string>,
  type: <string>,
  description: <string>,
  encapsulation: <string>,
  shutdown: <boolean>,
  load_interval: <string>
  source_interface: <string>,
  multicast_group: <string>,
  udp_port: <fixnum>,
  flood_list: <array>,
  vlans: <hash>
}

Parameters:

  • name (String) (defaults to: 'Vxlan1')

    The interface name to return from the nodes configuration. This optional parameter defaults to Vxlan1.

Returns:

  • (nil, Hash<String, String>)

    Returns the interface configuration as a Ruby hash object. If the provided interface name is not found then this method will return nil.



1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
# File 'lib/rbeapi/api/interfaces.rb', line 1204

def get(name = 'Vxlan1')
  config = get_block("interface #{name}")
  return nil unless config

  response = super(name)
  response[:type] = 'vxlan'
  response.merge!(parse_source_interface(config))
  response.merge!(parse_multicast_group(config))
  response.merge!(parse_udp_port(config))
  response.merge!(parse_flood_list(config))
  response.merge!(parse_vlans(config))
  response
end

#remove_vlan(name, vlan) ⇒ Boolean

remove_vlan deletes a previously configured VLAN to VNI mapping on the specified interface.

Parameters:

  • name (String)

    the name of the interface to configure.

  • vlan (Fixnum)

    The VLAN ID to remove from the configuration. If the VLAN ID does not exist, this method will still return successfully.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_version 4.13.7M



1454
1455
1456
# File 'lib/rbeapi/api/interfaces.rb', line 1454

def remove_vlan(name, vlan)
  configure_interface(name, "no vxlan vlan #{vlan} vni")
end

#remove_vtep(name, vtep) ⇒ Boolean

remove_vtep deletes a VTEP endpoint from the global flood list for the specified interface. If the VTEP endpoint specified is not configured, this method will still return successfully.

Parameters:

  • name (String)

    The name of the interface to configure.

  • vtep (String)

    The IP address of the remote VTEP endpoint.

Returns:

  • (Boolean)

    Returns true if the commands completed successfully.

Since:

  • eos_version 4.13.7M



1420
1421
1422
# File 'lib/rbeapi/api/interfaces.rb', line 1420

def remove_vtep(name, vtep)
  configure_interface(name, "vxlan flood vtep remove #{vtep}")
end

#set_multicast_group(name = 'Vxlan1', opts = {}) ⇒ Boolean

Configures the vxlan multicast-group flood address to the specified value. The value should be a valid multicast address.

Parameters:

  • name (String) (defaults to: 'Vxlan1')

    The name of the interface to apply the configuration values to.

  • opts (Hash) (defaults to: {})

    Optional keyword arguments.

Options Hash (opts):

  • value (String)

    Configures the multicast-group flood address to the specified value.

  • enable (Boolean)

    If false then the command is negated. Default is true.

  • default (Boolean)

    Specifies whether or not the multicast-group command is configured as default. The value of this option has a higher precedence than :value.

Returns:

  • (Boolean)

    Returns true if the commands complete successfully.



1358
1359
1360
1361
# File 'lib/rbeapi/api/interfaces.rb', line 1358

def set_multicast_group(name = 'Vxlan1', opts = {})
  commands = command_builder('vxlan multicast-group', opts)
  configure_interface(name, commands)
end

#set_source_interface(name = 'Vxlan1', opts = {}) ⇒ Boolean

Configures the vxlan source-interface to the specified value. This parameter should be the interface identifier of the interface to act as the source for all Vxlan traffic.

Parameters:

  • name (String) (defaults to: 'Vxlan1')

    The name of the interface to apply the configuration values to.

  • opts (Hash) (defaults to: {})

    Optional keyword arguments.

Options Hash (opts):

  • value (String)

    Configures the vxlan source-interface to the specified value.

  • enable (Boolean)

    If false then the command is negated. Default is true.

  • default (Boolean)

    Specifies whether or not the multicast-group command is configured as default. The value of this option has a higher precedence than :enable.

Returns:

  • (Boolean)

    Returns true if the commands complete successfully.



1333
1334
1335
1336
# File 'lib/rbeapi/api/interfaces.rb', line 1333

def set_source_interface(name = 'Vxlan1', opts = {})
  commands = command_builder('vxlan source-interface', opts)
  configure_interface(name, commands)
end

#set_udp_port(name, opts = {}) ⇒ Boolean

set_udp_port configures the Vxlan udp-port value in EOS for the specified interface name. If the enable keyword is false then the no keyword is used to configure the value. If the default option is provided and set to true, then the default keyword is used. If both options are provided, the default keyword will take precedence.

Parameters:

  • name (String)

    The name of the vxlan interface to configure.

  • opts (Hash) (defaults to: {})

    Optional keyword arguments.

Options Hash (opts):

  • value (String)

    Specifies the value to configure the udp-port setting to. Valid values are in the range of 1024 to 65535.

  • enable (Boolean)

    If false then the command is negated. Default is true.

  • default (Boolean)

    Configures the udp-port value on the interface using the default keyword.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_version 4.13.7M



1387
1388
1389
1390
# File 'lib/rbeapi/api/interfaces.rb', line 1387

def set_udp_port(name, opts = {})
  commands = command_builder('vxlan udp-port', opts)
  configure_interface(name, commands)
end

#update_vlan(name, vlan, vni) ⇒ Boolean

update_vlan creates a new vlan to vni mapping for the specified interface in the nodes current configuration.

Parameters:

  • name (String)

    The name of the interface to configure.

  • vlan (Fixnum)

    The VLAN ID to configure.

  • vni (Fixnum)

    The VNI value to map the VLAN into.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_verson 4.13.7M



1437
1438
1439
# File 'lib/rbeapi/api/interfaces.rb', line 1437

def update_vlan(name, vlan, vni)
  configure_interface(name, "vxlan vlan #{vlan} vni #{vni}")
end