Interfaces¶
Module for working with interfaces in EOS
This module provides an API for pragmatically working with EOS interface configurations. Interfaces include any data or management plane interface available in EOS.
- param name
The name of the interface the configuration should be applied to. The interface name is the full interface identifier.
- type name
string
- param shutdown
True if the interface is administratively disabled, and False if the interface is administratively enable. This value does not validate the interfaces operational state.
- type shutdown
boolean
- param description
The interface description string. This value is an arbitrary operator defined value.
- type description
string
- param sflow
True if sFlow is enabled on the interface otherwise False
- type sflow
boolean
- param flowcontrol_send
The flowcontrol send configuration value for the interface. Valid values are on or off
- type flowcontrol_send
string
- param flowcontrol_receive
The flowcontrol receive configuration value for the interface. Valid values are on or off
- type flowcontrol_receive
string
- class pyeapi.api.interfaces.BaseInterface(node)[source]¶
Bases:
pyeapi.api.abstract.EntityCollection
- create(name)[source]¶
Creates a new interface on the node
Note
This method will attempt to create the interface regardless if the interface exists or not. If the interface already exists then this method will still return True
- Parameters
name (string) – The full name of the interface.
- Returns
True if the interface could be created otherwise False (see Note)
- default(name)[source]¶
Defaults an interface in the running configuration
- Parameters
name (string) – The full name of the interface
- Returns
True if the command operation succeeds otherwise False
- delete(name)[source]¶
Deletes the interface from the node
Note
This method will attempt to delete the interface from the nodes operational config. If the interface does not exist then this method will not perform any changes but still return True
- Parameters
name (string) – The full name of the interface
- Returns
True if the interface could be deleted otherwise False (see Node)
- get(name)[source]¶
Returns a generic interface as a set of key/value pairs
This class is should normally serve as a base class for building more specific interface resources. The attributes of this resource are common to all interfaces regardless of type in EOS.
The generic interface resource returns the following:
name (str): The name of the interface
type (str): Always returns ‘generic’
shutdown (bool): True if the interface is shutdown
description (str): The interface description value
- Parameters
name (str) – The interface identifier to retrieve from the running-configuration
- Returns
- A Python dictionary object of key/value pairs that represents
the interface configuration. If the specified interface does not exist, then None is returned
- set_description(name, value=None, default=False, disable=False)[source]¶
Configures the interface description
- EosVersion:
4.13.7M
- Parameters
name (string) – The interface identifier. It must be a full interface name (ie Ethernet, not Et)
value (string) – The value to set the description to.
default (boolean) – Specifies to default the interface description
disable (boolean) – Specifies to negate the interface description
- Returns
True if the operation succeeds otherwise False
- set_encapsulation(name, vid, default=False, disable=False)[source]¶
Configures the subinterface encapsulation value
- Parameters
name (string) – The interface identifier. It must be a full interface name (ie Ethernet, not Et)
vid (int) – The vlan id number
default (boolean) – Specifies to default the subinterface encapsulation
disable (boolean) – Specifies to disable the subinterface encapsulation
- Returns
True if the operation succeeds otherwise False is returned
- set_shutdown(name, default=False, disable=True)[source]¶
Configures the interface shutdown state
Default configuration for set_shutdown is disable=True, meaning ‘no shutdown’. Setting both default and disable to False will effectively enable shutdown on the interface.
- Parameters
name (string) – The interface identifier. It must be a full interface name (ie Ethernet, not Et)
default (boolean) – Specifies to default the interface shutdown
disable (boolean) – Specifies to disable interface shutdown, i.e. disable=True => no shutdown
- Returns
True if the operation succeeds otherwise False is returned
- class pyeapi.api.interfaces.EthernetInterface(node)[source]¶
Bases:
pyeapi.api.interfaces.BaseInterface
- create(name)[source]¶
Create an Ethernet subinterface
- Parameters
name (string) – The subinterface name. Ex: Ethernet1.1
- Raises
NotImplementedError – creating physical Ethernet interfaces is not
supported. Only subinterfaces can be created. –
- delete(name)[source]¶
Delete an Ethernet subinterfaces
- Parameters
name (string) – The subinterface name. Ex: Ethernet1.1
- Raises
NotImplementedError – creating physical Ethernet interfaces is not
supported. Only subinterfaces can be created. –
- get(name)[source]¶
Returns an interface as a set of key/value pairs
- Parameters
name (string) – the interface identifier to retrieve the from the configuration
- Returns
A Python dictionary object of key/value pairs that represent the current configuration for the specified node. If the specified interface name does not exist, then None is returned:
{ "name": <string>, "type": "ethernet", "sflow": [true, false], "flowcontrol_send": [on, off], "flowcontrol_receive": [on, off] }
- set_flowcontrol(name, direction, value=None, default=False, disable=False)[source]¶
Configures the interface flowcontrol value
- Parameters
name (string) – The interface identifier. It must be a full interface name (ie Ethernet, not Et)
direction (string) – one of either ‘send’ or ‘receive’
value (boolean) – True if the interface should enable flow control packet handling, otherwise False
default (boolean) – Specifies to default the interface flow control send or receive value
disable (boolean) – Specifies to disable the interface flow control send or receive value
- Returns
True if the operation succeeds otherwise False is returned
- set_flowcontrol_receive(name, value=None, default=False, disable=False)[source]¶
Configures the interface flowcontrol receive value
- Parameters
name (string) – The interface identifier. It must be a full interface name (ie Ethernet, not Et)
value (boolean) – True if the interface should enable receiving flow control packets, otherwise False
default (boolean) – Specifies to default the interface flow control receive value
disable (boolean) – Specifies to disable the interface flow control receive value
- Returns
True if the operation succeeds otherwise False is returned
- set_flowcontrol_send(name, value=None, default=False, disable=False)[source]¶
Configures the interface flowcontrol send value
- Parameters
name (string) – The interface identifier. It must be a full interface name (ie Ethernet, not Et)
value (boolean) – True if the interface should enable sending flow control packets, otherwise False
default (boolean) – Specifies to default the interface flow control send value
disable (boolean) – Specifies to disable the interface flow control send value
- Returns
True if the operation succeeds otherwise False is returned
- set_sflow(name, value=None, default=False, disable=False)[source]¶
Configures the sFlow state on the interface
- Parameters
name (string) – The interface identifier. It must be a full interface name (ie Ethernet, not Et)
value (boolean) – True if sFlow should be enabled otherwise False
default (boolean) – Specifies the default value for sFlow
disable (boolean) – Specifies to disable sFlow
- Returns
True if the operation succeeds otherwise False is returned
- set_vrf(name, vrf, default=False, disable=False)[source]¶
Applies a VRF to the interface
- Note: VRF being applied to interface must already exist in switch
config. Ethernet port must be in routed mode. This functionality can also be handled in the VRF api.
- Parameters
name (str) – The interface identifier. It must be a full interface name (ie Ethernet, not Et)
vrf (str) – The vrf name to be applied to the interface
default (bool) – Specifies the default value for VRF
disable (bool) – Specifies to disable VRF
- Returns
True if the operation succeeds otherwise False is returned
- class pyeapi.api.interfaces.Interfaces(node, *args, **kwargs)[source]¶
- class pyeapi.api.interfaces.PortchannelInterface(node)[source]¶
Bases:
pyeapi.api.interfaces.BaseInterface
- get(name)[source]¶
Returns a Port-Channel interface as a set of key/value pairs
- Parameters
name (str) – The interface identifier to retrieve from the running-configuration
- Returns
A Python dictionary object of key/value pairs that represents the interface configuration. If the specified interface does not exist, then None is returned:
{ "name": <string>, "type": "portchannel", "members": <arrary of interface names>, "minimum_links: <integer>, "lacp_mode": [on, active, passive] }
- get_lacp_mode(name)[source]¶
Returns the LACP mode for the specified Port-Channel interface
- Parameters
name (str) – The Port-Channel interface name to return the LACP mode for from the configuration
- Returns
- The configured LACP mode for the interface. Valid mode values
are ‘on’, ‘passive’, ‘active’
- get_members(name)[source]¶
Returns the member interfaces for the specified Port-Channel
- Parameters
name (str) – The Port-channel interface name to return the member interfaces for
- Returns
- A list of physical interface names that belong to the specified
interface
- set_lacp_fallback(name, mode=None)[source]¶
Configures the Port-Channel lacp_fallback
- Parameters
name (str) – The Port-Channel interface name
mode (str) –
The Port-Channel LACP fallback setting Valid values are ‘disabled’, ‘static’, ‘individual’:
static - Fallback to static LAG mode
individual - Fallback to individual ports
disabled - Disable LACP fallback
- Returns
True if the operation succeeds otherwise False is returned
- set_lacp_mode(name, mode)[source]¶
Configures the LACP mode of the member interfaces
- Parameters
name (str) – The Port-Channel interface name to configure the LACP mode
mode (str) – The LACP mode to configure the member interfaces to. Valid values are ‘on, ‘passive’, ‘active’
- Returns
True if the operation succeeds otherwise False
- set_lacp_timeout(name, value=None)[source]¶
- Configures the Port-Channel LACP fallback timeout
The fallback timeout configures the period an interface in fallback mode remains in LACP mode without receiving a PDU.
- Parameters
name (str) – The Port-Channel interface name
value (int) – port-channel lacp fallback timeout in seconds
- Returns
True if the operation succeeds otherwise False is returned
- set_members(name, members, mode=None)[source]¶
Configures the array of member interfaces for the Port-Channel
- Parameters
name (str) – The Port-Channel interface name to configure the member interfaces
members (list) – The list of Ethernet interfaces that should be member interfaces
mode (str) – The LACP mode to configure the member interfaces to. Valid values are ‘on, ‘passive’, ‘active’. When there are existing channel-group members and their lacp mode differs from this attribute, all of those members will be removed and then re-added using the specified lacp mode. If this attribute is omitted, the existing lacp mode will be used for new member additions.
- Returns
True if the operation succeeds otherwise False
- set_minimum_links(name, value=None, default=False, disable=False)[source]¶
Configures the Port-Channel min-links value
- Parameters
name (str) – The Port-Channel interface name
value (str) – The value to configure the min-links
default (bool) – Specifies to default the port channel min-links value
disable (bool) – Specifies to disable the port channel min-links value
- Returns
True if the operation succeeds otherwise False is returned
- class pyeapi.api.interfaces.VxlanInterface(node)[source]¶
Bases:
pyeapi.api.interfaces.BaseInterface
- DEFAULT_MCAST_GRP = ''¶
- DEFAULT_SRC_INTF = ''¶
- add_vtep(name, vtep, vlan=None)[source]¶
Adds a new VTEP endpoint to the global or local flood list
- EosVersion:
4.13.7M
- Parameters
name (str) – The name of the interface to configure
vtep (str) – The IP address of the remote VTEP endpoint to add
vlan (str) – The VLAN ID associated with this VTEP. If the VLAN
used (keyword is) –
flood (then the VTEP is configured as a local) –
endpoing –
- Returns
True if the command completes successfully
- get(name)[source]¶
Returns a Vxlan interface as a set of key/value pairs
The Vxlan interface resource returns the following:
name (str): The name of the interface
type (str): Always returns ‘vxlan’
source_interface (str): The vxlan source-interface value
multicast_group (str): The vxlan multicast-group value
udp_port (int): The vxlan udp-port value
vlans (dict): The vlan to vni mappings
flood_list (list): The list of global VTEP flood list
- multicast_decap (bool): If the multicast decap
feature is configured
- Parameters
name (str) – The interface identifier to retrieve from the running-configuration
- Returns
- A Python dictionary object of key/value pairs that represents
the interface configuration. If the specified interface does not exist, then None is returned
- remove_vlan(name, vid)[source]¶
Removes a vlan to vni mapping for the interface
- EosVersion:
4.13.7M
- Parameters
vlan (str, int) – The vlan id to map to the vni
- Returns
True if the command completes successfully
- remove_vtep(name, vtep, vlan=None)[source]¶
Removes a VTEP endpoint from the global or local flood list
- EosVersion:
4.13.7M
- Parameters
name (str) – The name of the interface to configure
vtep (str) – The IP address of the remote VTEP endpoint to add
vlan (str) – The VLAN ID associated with this VTEP. If the VLAN
used (keyword is) –
flood (then the VTEP is configured as a local) –
endpoing –
- Returns
True if the command completes successfully
- set_multicast_decap(name, default=False, disable=False)[source]¶
Configures the Vxlan multicast-group decap feature
- EosVersion:
4.15.0M
- Parameters
name – The interface identifier to configure, defaults to Vxlan1
- Returns
True if the operation succeeds otherwise False
- set_multicast_group(name, value=None, default=False, disable=False)[source]¶
Configures the Vxlan multicast-group value
- EosVersion:
4.13.7M
- Parameters
name – The interface identifier to configure, defaults to Vxlan1
- Returns
True if the operation succeeds otherwise False
- set_source_interface(name, value=None, default=False, disable=False)[source]¶
Configures the Vxlan source-interface value
- EosVersion:
4.13.7M
- Parameters
name – The interface identifier to configure, defaults to Vxlan1
- Returns
True if the operation succeeds otherwise False
- set_udp_port(name, value=None, default=False, disable=False)[source]¶
Configures vxlan udp-port value
- EosVersion:
4.13.7M
- Parameters
name (str) – The name of the interface to configure
value (str) – The value to set udp-port to
default (bool) – Configure using the default keyword
disable (bool) – Negate the udp-port value
- Returns
True if the operation succeeds otherwise False