class Rbeapi::Api::VxlanInterface
The VxlanInterface
class manages all Vxlan interfaces on an EOS node.
Constants
- DEFAULT_MCAST_GRP
- DEFAULT_SRC_INTF
Public Instance Methods
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.
@since eos_version 4.13.7M
@param name [String] The name of the interface to configure.
@param vtep [String] The IP address of the remote VTEP endpoint.
@return [Boolean] Returns true if the commands completed successfully.
# File lib/rbeapi/api/interfaces.rb, line 1404 def add_vtep(name, vtep) configure_interface(name, "vxlan flood vtep add #{vtep}") end
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.
@example
{ 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> }
@param name [String] The interface name to return from the nodes
configuration. This optional parameter defaults to Vxlan1.
@return [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.
Rbeapi::Api::BaseInterface#get
# 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
deletes a previously configured VLAN to VNI mapping on the specified interface.
@since eos_version 4.13.7M
@param name [String] the name of the interface to configure.
@param vlan [Fixnum] The VLAN ID to remove from the configuration. If
the VLAN ID does not exist, this method will still return successfully.
@return [Boolean] Returns true if the command completed successfully.
# File lib/rbeapi/api/interfaces.rb, line 1454 def remove_vlan(name, vlan) configure_interface(name, "no vxlan vlan #{vlan} vni") end
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.
@since eos_version 4.13.7M
@param name [String] The name of the interface to configure.
@param vtep [String] The IP address of the remote VTEP endpoint.
@return [Boolean] Returns true if the commands completed successfully.
# File lib/rbeapi/api/interfaces.rb, line 1420 def remove_vtep(name, vtep) configure_interface(name, "vxlan flood vtep remove #{vtep}") end
Configures the vxlan multicast-group flood address to the specified value. The value should be a valid multicast address.
@param name [String] The name of the interface to apply the
configuration values to.
@param opts [Hash] Optional keyword arguments.
@option opts value [String] Configures the multicast-group flood
address to the specified value.
@option opts enable [Boolean] If false then the command is
negated. Default is true.
@option opts 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.
@return [Boolean] Returns true if the commands complete successfully.
# 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
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.
@param name [String] The name of the interface to apply the
configuration values to.
@param opts [Hash] Optional keyword arguments.
@option opts value [String] Configures the vxlan source-interface to
the specified value.
@option opts enable [Boolean] If false then the command is
negated. Default is true.
@option opts 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.
@return [Boolean] Returns true if the commands complete successfully.
# 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
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.
@since eos_version 4.13.7M
@param name [String] The name of the vxlan interface to configure.
@param opts [Hash] Optional keyword arguments.
@option opts value [String] Specifies the value to configure the
udp-port setting to. Valid values are in the range of 1024 to 65535.
@option opts enable [Boolean] If false then the command is
negated. Default is true.
@option opts default [Boolean] Configures the udp-port value on
the interface using the default keyword.
@return [Boolean] Returns true if the command completed successfully.
# 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
creates a new vlan to vni mapping for the specified interface in the nodes current configuration.
@since eos_verson 4.13.7M
@param name [String] The name of the interface to configure.
@param vlan [Fixnum] The VLAN ID to configure.
@param vni [Fixnum] The VNI value to map the VLAN into.
@return [Boolean] Returns true if the command completed successfully.
# File lib/rbeapi/api/interfaces.rb, line 1437 def update_vlan(name, vlan, vni) configure_interface(name, "vxlan vlan #{vlan} vni #{vni}") end
Private Instance Methods
parse_flood_list
scans the interface config block and returns the list of configured VTEPs that comprise the flood list. If there are no flood list values configured, the value will return DEFAULT_FLOOD_LIST. The returned value is intended to be merged into the interface resource Hash.
@api private
@param config [String] The interface configuration block to parse the
vxlan flood list values from.
@return [Hash<Symbol, Object>]
# File lib/rbeapi/api/interfaces.rb, line 1285 def parse_flood_list(config) values = config.scan(/(?<=\s{3}vxlan flood vtep ).+$/) values = values.first.split(' ') unless values.empty? { flood_list: values } end
parse_multicast_group
scans the interface config block and returns the value of the vxlan multicast-group. If the multicast-group is not configured then the value of DEFAULT_MCAST_GRP
is used. The hash returned is intended to be merged into the interface resource hash.
@api private
@param config [String] The interface configuration block to extract
the vxlan multicast-group value from.
@return [Hash<Symbol, Object>]
# File lib/rbeapi/api/interfaces.rb, line 1248 def parse_multicast_group(config) mdata = /^\s*vxlan multicast-group ([^\s]+)$/.match(config) { multicast_group: mdata ? mdata[1] : DEFAULT_MCAST_GRP } end
parse_source_interface
scans the interface config block and returns the value of the vxlan source-interface. If the source-interface is not configured then the value of DEFAULT_SRC_INTF
is used. The hash returned is intended to be merged into the interface resource hash
@api private
@param config [String] The interface configuration block to extract
the vxlan source-interface value from.
@return [Hash<Symbol, Object>]
# File lib/rbeapi/api/interfaces.rb, line 1230 def parse_source_interface(config) mdata = /source-interface ([^\s]+)$/.match(config) { source_interface: mdata ? mdata[1] : DEFAULT_SRC_INTF } end
parse_udp_port
scans the interface config block and returns the value of the vxlan udp-port setting. The vxlan udp-port value is expected to always be present in the configuration. The returned value is intended to be merged into the interface resource Hash.
@api private
@param config [String] The interface configuration block to parse the
vxlan udp-port value from.
@return [Hash<Symbol, Object>]
# File lib/rbeapi/api/interfaces.rb, line 1266 def parse_udp_port(config) value = config.scan(/(?<=vxlan udp-port )\d+/) { udp_port: value.first.to_i } end
parse_vlans
scans the interface config block and returns the set of configured vlan to vni mappings. If there are no vlans configured, the value will return an empty Hash.
@api private
@param config [String] The interface configuration block to parse the
vxlan flood list values from.
@return [Hash<Symbol, Object>]
# File lib/rbeapi/api/interfaces.rb, line 1303 def parse_vlans(config) values = config.scan(/vxlan vlan (\d+) vni (\d+)/) values = values.each_with_object({}) do |v, hsh| hsh[v.first] = { vni: v.last } end { vlans: values } end