BaseInterfaceLine

class BaseInterfaceLine(number, text, config, verbosity=3, name='BaseInterfaceLine')

Bases: ccutils.ccparser.BaseConfigLine.BaseConfigLine

Object for retrieving various config options on the interface level.

This class is not meant to be instantiated directly, but only from BaseConfigParser instance.

Parameters:
  • number (int) – Index of line in config
  • text (str) – Text of the config line
  • config (BaseConfigParser) – Reference to the parent BaseConfigParser object
  • verbosity (int, optional) – Logging output level, defaults to 3: Warning
access_vlan

Return a number of access VLAN or None if the command switchport access vlan x is not present.

Caution: This does not mean the interface is necessarily an access port.

Returns:Number of access VLAN or None

Returns None if absent

Return type:int
bandwidth

Return bandwidth of the interface set by command bandwidth X.

Returns:Bandwidth

Returns None if absent

Return type:int
cdp

Checks whether CDP is enabled on the interface. This property takes global CDP configuration into account, meaning if there is no specific configuration on the interface level, it will return state based on the entire config (eg. no cdp run in the global config will make this property be False)

Returns:True if CDP is enabled, False otherwise
Return type:bool
channel_group

Return a dictionary describing Port-channel/Etherchannel related configuration

Returns:Channel-group parameters

Example:

{"channel_group_number": "1", "channel_group_mode": "active"}

Otherwise returns None

Return type:dict
delay

Return delay of the interface set by command delay X.

Returns:Delay

Returns None if absent

Return type:int
description

Returns description of the interface.

Returns:Interface description

Returns None if absent

Return type:str
device_tracking_policy
duplex

Return duplex of the interface set by command duplex X.

Returns:Duplex

Returns None if absent

Return type:str
encapsulation

Return encapsulation type and tag for subinterfaces

Returns:Encapsualtion parameters

Example:

{"type": "dot1q", "tag": 10, "native": False}

Returns None if absent

Return type:dict
flags

List of flags/tags describing basic properties of the interface. Used for filtering purposes. Currently supported flags are:

l2 - Interface is switched port

l3 - Interface is routed port

physical - Interface is a physical interface (Only *Ethernet interfaces)

svi - Interface is SVI (VLAN Interface)

port-channel - Interface is port-channel

pc-member - Interface is a member of Port-channel

tunnel - Interface is a Tunnel

Returns:List of flags
Return type:list
get_unprocessed

Return a list of config lines under the interface, which did not match any of the existing regex patterns. Mostly for development/testing purposes.

By default returns list of objects.

Parameters:return_type (str) – Set this to “text” to receive list of strings
Returns:List of unprocessed config lines
Return type:list
helper_address

Return a list of IP addresses specified with ip helper-address command (DHCP relay).

Returns:List of helper addresses

Returns None if absent

Return type:list
interface_description
interface_name
ip_addresses

Return list of IP addresses present on the interface

Returns:List of dictionaries representing individual IP addresses

Example:

[
    {
        "ip_address": "10.0.0.1",
        "mask": "255.255.255.0",
        "secondary": False
    },
    {
        "ip_address": "10.0.1.1",
        "mask": "255.255.255.0",
        "secondary": True
    }
]

If there is no IP address present on the interface, an empty list is returned.

Return type:list
ip_mtu

Return IP MTU of the interface set by command ip mtu X.

Returns:IP MTU

Returns None if absent

Return type:int
ip_unnumbered_interface
keepalive
load_interval

Return Load Interval of the interface set by command load-interval X.

Returns:Load Interval

Returns None if absent

Return type:int
logging_events
mtu

Return MTU of the interface set by command mtu X.

Returns:MTU

Returns None if absent

Return type:int
name

Return name of the interface, such as GigabitEthernet0/1.

Returns:Name of the interface
Return type:str
native_vlan

Return Native VLAN of L2 Interface

Returns:Native VLAN Number (None if absent)

Returns None if absent

Return type:int
ospf

Return OSPF interface parameters

Returns:OSPF parameters

Example:

{"process_id": 1, "area": 0, "network_type": "point-to-point", "priority": 200}

Returns None if absent

Return type:dict
ospf_priority

Returns OSPF priority of the interface.

Returns:OSPF Priority or None
Return type:int
port_mode

Checks whether the interface is running in switched (l2) or routed (l3) mode.

Returns:l2 or l3
Return type:str
service_instances
service_policy

Return names of applied service policies

Returns:Dictionary containing names of both input and output policies.

Example:

{"input": "TEST_INPUT_POLICY", "output": "TEST_OUTPUT_POLICY"}

If there are no policies specified, returns:

{"input": None, "output": None}
Return type:dict
shutdown
speed

Return speed of the interface set by command speed X

Returns:Speed

Returns None if absent

Return type:int
standby

HSRP related configuration. Groups, IP addresses, hello/hold timers, priority and authentication.

Returns:Dictionary with top level keys being HSRP groups.
storm_control
switchport_mode

Return L2 Mode of interface, either access or trunk

Returns:“access” or “trunk”

Returns None if absent

Return type:str
switchport_nonegotiate

Check whether the port is running DTP or not. Checks for presence of switchport nonegotiate command

Returns:True if command is present, False otherwise
Return type:bool
tcp_mss

Return TCP Max Segment Size of the interface set by command ip tcp adjust-mss X.

Returns:TCP MSS

Returns None if absent

Return type:int
trunk_allowed_vlans

Return a expanded list of VLANs allowed with switchport trunk allowed vlan x,y,z.

Caution: This does not mean the interface is necessarily a trunk port.

Returns:Expanded list of allowed VLANs

Returns None if absent

Returns “none” if switchport trunk allowed vlan none

Return type:list
trunk_encapsulation

Return encapsulation on trunk interfaces

Returns:“dot1q” or “isl”

Returns None if absent

Return type:str
tunnel_properties

Return properties related to Tunnel interfaces

Returns:Dictionary with tunnel properties.

Example:

{
    "source": "Loopback0",
    "destination": "10.0.0.1",
    "vrf": None,
    "mode": "ipsec ipv4",
    "ipsec_profile": "TEST_IPSEC_PROFILE"
}

Returns None if absent

Return type:dict
voice_vlan

Return a number of voice VLAN

Returns:Number of voice VLAN or None

Returns None if absent

Return type:int
vrf

Return VRF of the interface

Returns:Name of the VRF

Returns None if absent

Return type:str