Package onep :: Package interfaces :: Module NetworkInterface :: Class NetworkInterface
[frames] | no frames]

Class NetworkInterface


This class represents a NetworkInterface. It is used for both physical and logical interfaces.

Instance Methods
 
name(self)
The name of the network Interface.
 
interface_type(self)
The type of the network Interface
 
network_element(self)
The source network element to which the interface belongs
 
xos_handle(self)
The Network Interface Handle
 
__init__(self, element, name, type_, xoshandle)
Constructor of NetworkInterface class.
 
__str__(self)
The str() method returns the string representation of the NetworkInterface instance.
bool
__eq__(self, other)
Two interface Objects are equal if they have the same network interface unique id and have the same NetworkElement parent Object.
 
IANA_type(self)
IANA interface type corresponding to ONEP interface type
bool
equals(self, other)
Checks if two NetworkInterface Objects are equal or not.
InterfaceStatistics
get_statistics(self)
Returns the NetworkInterface Statistics after querying the router.
InterfaceProperty
get_property(self)
Gets the hardware property of the NetworkInterface.
InterfaceStatus
get_status(self)
Gets the snapshot status of the NetworkInterface.
InterfaceConfiguration
get_config(self)
Gets the configuration of the NetworkInterface.
dictionary
get_subinterface_list(self)
Gets all the sub-interfaces attached to this network interface if any.
NetworkInterface
get_parent(self)
Gets the parent NetworkInterface of this interface if this is a sub-interface, or None if it is a physical (non virtual) interface or has no parent.
 
set_vlan(self, param)
the parameter has key 'encap-type', 'vlan-tag1', and optional 'vlan-tag2'
 
remove_vlan(self)
 
set_mtu(self, mtu)
Sets MTU for an interface.
 
set_description(self, description)
Sets the interface description.
 
set_bw(self, bw)
Sets the interface Bandwidth.
 
set_encapsulation(self, encapsulation)
Sets the interface encapsulation
 
shut_down(self, shutdown)
Sets interface admin state to down or up.
 
clear_statistics(self)
Clears statistics for the given Interface.
 
get_location(self)
Gets a Location object associated with the network interface.
 
set_location(self, loc)
Sets location information for the network interface.
 
set_address(self, set, scope, addr, prefix_len)
Sets or Unset IP address on the interface.
 
set_iphelper(self, ipaddress, vrf=None, set=True)
Enable UDP forwarding to specified address
 
set_proxy_arp(self, set)
Turn on/off ARP proxy
 
set_ip_unreachable(self, set)
Turn on/off IP unreachable
 
set_ip_redirect(self, set)
Turn on/off IP redirect
 
set_ip_unicast_reverse_path(self, set, access_list=None)
Turn on/off IP Unicast Reverse Path
 
set_vrf_forwarding(self, vrf, set=True)
list
get_address_list(self)
Gets a list of IP addresses (IPv4 or IPv6) associated with this
list
get_prefix_list(self)
Gets a list of IP prefixes (IPv4 or IPv6 address and its mask) associated with this Interface.
NetworkInterface @return NetworkInterface class
get_sub_interface_by_id(self, sub_if_id)
Return a NetworkInterface class representing the sub-interface object matching the ID
int
add_state_listener(self, interface_state_listener, state_event_type, client_data)
Adds a Interface up/down state listener to NetworkElement Object.
 
remove_state_listener(self, event_handle)
Remove Interface up/down state listener from NetworkElement Object.
int
add_statistics_listener(self, interface_statistics_listener, filter, client_data)
Subscribes to Interface statistics change events.
 
remove_statistics_listener(self, event_handle)
Remove Interface statistics change events listeners.
int
add_cdp_listener(self, cdp_listener, filter, client_data)
Subscribes to CDP events.
 
remove_cdp_listener(self, event_handle)
Remove CDP events listeners.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Methods
 
get_interface_instance_by_type(self, element, name, type, xoshandle)
Return an instantiated Network Interface class according to type
NetworkInterface
get_empty_interface(cls)
Creates dummy interface that matches any interface to be used in Interface filter.
Class Variables
Enum InterfaceTypes = enum('ONEP_IF_TYPE_UNSUPPORTED', 'ONEP_IF_TYP...
Enumeration of the logical interface types supported.
  IANAType = {'ONEP_IF_IANA_TYPE_ANY': 0, 'ONEP_IF_IANA_TYPE_OTH...
IANAType...
  interfaceTypeMap = {InterfaceTypes.ONEP_IF_TYPE_NULL: IANAType...
  ONEP_IF_ALL_HANDLES = -1
  cdp_client = None
  doc_vlan = ...
  vlan = property(get_vlan, set_vlan, remove_vlan, doc_vlan)
Properties

Inherited from object: __class__

Method Details

name(self)

 
The name of the network Interface.
Decorators:
  • @property

interface_type(self)

 
The type of the network Interface
Decorators:
  • @property

network_element(self)

 
The source network element to which the interface belongs
Decorators:
  • @property

xos_handle(self)

 
The Network Interface Handle
Decorators:
  • @property

__init__(self, element, name, type_, xoshandle)
(Constructor)

 

Constructor of NetworkInterface class.

Overrides: object.__init__

__str__(self)
(Informal representation operator)

 

The str() method returns the string representation of the NetworkInterface instance.

Overrides: object.__str__

__eq__(self, other)
(Equality operator)

 

Two interface Objects are equal if they have the same network interface unique id and have the same NetworkElement parent Object.

Parameters:
Returns: bool

equals(self, other)

 

Checks if two NetworkInterface Objects are equal or not.

Two interface Objects are equal if they have the same network interface unique id and have the same NetworkElement parent Object.

Parameters:
Returns: bool
Raises:

get_statistics(self)

 

Returns the NetworkInterface Statistics after querying the router.

Returns: InterfaceStatistics
Raises:

get_property(self)

 

Gets the hardware property of the NetworkInterface.

The property is only retrieved once from the NetworkElement. It is hard property of the interface which do not change during life of the session.

Returns: InterfaceProperty
Raises:

get_status(self)

 

Gets the snapshot status of the NetworkInterface.

The status is a snapshot of the current condition of the NetworkInterface attributes. The status is retrieved on demand on every invocation.

Returns: InterfaceStatus
Raises:

get_config(self)

 

Gets the configuration of the NetworkInterface.

The software property comes from the configuration of the NetworkInterface, which might be changed during its session of life via configuration. The configuration is refreshed on every invocation.

Returns: InterfaceConfiguration
Raises:

get_subinterface_list(self)

 

Gets all the sub-interfaces attached to this network interface if any.

For instance eth0:1 will be a sub-interface to eth0. If no subinterfaces under the interface, the interface itself is returned.

Returns: dictionary
A dictionary with all the available sub-interfaces keyed by sub-interface name.
Raises:

get_parent(self)

 

Gets the parent NetworkInterface of this interface if this is a sub-interface, or None if it is a physical (non virtual) interface or has no parent.

Returns: NetworkInterface
The NetworkInterface this interface is attached to.
Raises:

get_empty_interface(cls)
Class Method

 

Creates dummy interface that matches any interface to be used in Interface filter.

This is equivalent of empty interface object.

Returns: NetworkInterface

set_mtu(self, mtu)

 

Sets MTU for an interface.

Parameters:
  • mtu (int) - The MTU value which should be set on the interface.Must be of integer type.
Raises:

set_description(self, description)

 

Sets the interface description.

Parameters:
  • description (str) - The interface description. Must be of string type.
Raises:

set_bw(self, bw)

 

Sets the interface Bandwidth.

Parameters:
  • bw (int) - The Bandwidth value which should be set on the interface.Must be of integer type.
Raises:

set_encapsulation(self, encapsulation)

 

Sets the interface encapsulation

Parameters:
  • encapsulation (InterfaceConfig.Encap) - The interface encapsulation
Raises:

shut_down(self, shutdown)

 

Sets interface admin state to down or up.

This method is equivalent of configuration command to shutdown an interface.

Applications can set the shutdown value to TRUE to administratively shutdown the interface.

Applications can set the shutdown value to FALSE to administratively bring the interface up.

Parameters:
  • shutdown (int) - Value indicating if it is a shutdown/bringup operation. 1 to shutdown the interface and 0 to bring up the interface
Raises:

clear_statistics(self)

 

Clears statistics for the given Interface.

Decorators:
  • @deprecated()
Raises:

Deprecated: Deprecated with SDK release 1.2.1

get_location(self)

 

Gets a Location object associated with the network interface. The Location object can be used to access all types of location information.

Returns:
The Location object for the network interface, or None if there is no location information available.
Raises:

set_location(self, loc)

 

Sets location information for the network interface.

Sets location information for the network interface with the information in the input Location parameter.

Parameters:
  • loc (Location) - The location information to be associated with the network interface.
Raises:

set_address(self, set, scope, addr, prefix_len)

 

Sets or Unset IP address on the interface.

This API can be used to set either an IPv4 or IPv6 address on the Interface. The API also allows one to specify the scope of the address being configured.

Following operations can be done with the API.

  1. Set IPv4 primary address (only one allowed on an interface). set_address(1, OnepAddressScopeType.ONEP_ADDRESS_IPv4_PRIMARY, addr, prefix).
  2. Set IPv4 secondary address (multiple allowed on an interface). set_address(1, OnepAddressScopeType.ONEP_ADDRESS_IPv4_SECONDARY, addr, prefix).
  3. Unset IPv4 primary address (the correct address must be specified). set_address(0, OnepAddressScopeType.ONEP_ADDRESS_IPv4_PRIMARY, addr, prefix).
  4. Unset IPv4 secondary address (the correct address must be specified). set_address(0, OnepAddressScopeType.ONEP_ADDRESS_IPv4_SECONDARY, addr, prefix).
  5. Unset IPv4 addresses (both primary and secondary). set_address(0, OnepAddressScopeType.ONEP_ADDRESS_IPv4_ALL, None, 0).
  6. Set IPv6 link-local address (only one allowed on an interface). set_address(1, OnepAddressScopeType.ONEP_ADDRESS_IPv6_LINK_LOCAL, addr, prefix).
  7. Set IPv6 address in EUI-64 format (multiple allowed on an interface). set_address(1, OnepAddressScopeType.ONEP_ADDRESS_IPv6_EUI64, addr, prefix).
  8. Set IPv6 uni-cast or site-local address (multiple allowed on an interface). set_address(1, OnepAddressScopeType.ONEP_ADDRESS_IPv6_GLOBAL, addr, prefix).
  9. Unset IPv6 link-local address (set default link-local). set_address(0, OnepAddressScopeType.ONEP_ADDRESS_IPv6_LINK_LOCAL, addr, 0).
  10. Unset IPv6 address of EUI-64 format. set_address(0, OnepAddressScopeType.ONEP_ADDRESS_IPv6_EUI64, addr, prefix).
  11. Unset IPv6 uni-cast or site-local address . set_address(0, OnepAddressScopeType.ONEP_ADDRESS_IPv6_GLOBAL, addr, prefix).
  12. Unset all IPv6 addresses. set_address(0, ONEP_ADDRESS_IPv6_ALL, None, 0).
Parameters:
  • set (int) - Integer value indicating if it is a set/unset operation. 1 to set the address adn 0 to unset the address
  • scope (OnepAddressScopeType) - Indicates the scope of the address.
  • addr (str) - The IP address to be set on the interface. This argument is ignored for unset operation for scope types ONEP_ADDRESS_V4_ALL, ONEP_ADDRESS_V6_ALL, and ONEP_ADDRESS_V4_PRIMARY.
  • prefix_len (int) - Value of prefix length (representing the mask) for the set/unset IP address operation. This argument is ignored for unset operation for scope types ONEP_ADDRESS_V4_ALL, ONEP_ADDRESS_V6_ALL and ONEP_ADDRESS_V4_PRIMARY.
Raises:

set_iphelper(self, ipaddress, vrf=None, set=True)

 

Enable UDP forwarding to specified address 

Throws on error
    OnepIllegalArgumentException - Invalid IP address 

Keyword arguments
ipaddress -- string  - IP address of host for forwarding operation
vrf       -- Vrf class - Virtual Route Forwarding
set       -- boolean - True = set forwarding, False = stop forwarding

set_proxy_arp(self, set)

 

Turn on/off ARP proxy

Keyword argument set -- boolean - True = turn on ARP proxy, False = turn off ARP proxy

set_ip_unreachable(self, set)

 

Turn on/off IP unreachable

Keyword argument set -- boolean - True = turn on IP unreachable, False = turn off IP unreachable

set_ip_redirect(self, set)

 

Turn on/off IP redirect

Keyword argument set -- boolean - True = turn on IP redirect, False = turn off IP redirect

set_ip_unicast_reverse_path(self, set, access_list=None)

 

Turn on/off IP Unicast Reverse Path

Keyword arguments set -- boolean - True = turn on IP reverse path, False = turn off IP reverse path access_list -- string - name of access list for reverse path

get_address_list(self)

 

Gets a list of IP addresses (IPv4 or IPv6) associated with this

Returns: list
A list of ip addresses as strings.
Raises:

get_prefix_list(self)

 

Gets a list of IP prefixes (IPv4 or IPv6 address and its mask) associated with this Interface.

The Interfaces IP prefixes are returned as list of NetworkPrefix objects. The NetworkPrefix object contains the InetAddress object representing the IPv4 or IPv6 address and an integer for the prefix length.

Returns: list
A list of NetworkPrefix objects.
Raises:

get_sub_interface_by_id(self, sub_if_id)

 

Return a NetworkInterface class representing the sub-interface object matching the ID

Parameters:
  • sub_if_id (InterfaceTypes) - sub-interface ID
Returns: NetworkInterface @return NetworkInterface class

add_state_listener(self, interface_state_listener, state_event_type, client_data)

 

Adds a Interface up/down state listener to NetworkElement Object.

Parameters:
  • interface_state_listener (InterfaceStateListener) - Instance of InterfaceStateListener class.
  • state_event_type (InterfaceStateEvent.) - Specify what type of event is of interest.
  • client_data - The client data associated with the listener. This client data will be part of input parameters when the handleEvent method in the listener is invoked.
Returns: int
event_handle, Numeric ID associated with this event registration. The event_handle is used to unregister the listener using the remove_state_listener method.
Raises:

remove_state_listener(self, event_handle)

 

Remove Interface up/down state listener from NetworkElement Object.

Parameters:
  • event_handle (int) - Numeric ID which was returned when listener was added to detect the event.
Raises:

add_statistics_listener(self, interface_statistics_listener, filter, client_data)

 

Subscribes to Interface statistics change events.

Parameters:
  • interface_statistics_listener (InterfaceStatisticsListener) - Instance of InterfaceStatisticsListener class.
  • filter (InterfaceStatisticsFilter) - Specify criteria of interesting interface statistics events.
  • client_data - The client data associated with the listener. This client data will be part of input parameters when the handleEvent method in the listener is invoked.
Returns: int
event_handle, Numeric ID associated with this event registration. The event_handle is used to unregister the listener using the remove_statistics_listener method.
Raises:

remove_statistics_listener(self, event_handle)

 

Remove Interface statistics change events listeners.

Parameters:
  • event_handle (int) - Numeric ID which was returned when listener was added to detect the event.
Raises:

add_cdp_listener(self, cdp_listener, filter, client_data)

 

Subscribes to CDP events.

Parameters:
  • cdp_listener (CDPListener) - Instance of CDPListener class.
  • filter (CDPFilter) - Specify criteria of interesting CDP events.
  • client_data - The client data associated with the listener. This client data will be part of input parameters when the handleEvent method in the listener is invoked.
Returns: int
event_handle, Numeric ID associated with this event registration. The event_handle is used to unregister the listener using the remove_cdp_listener method.
Raises:

remove_cdp_listener(self, event_handle)

 

Remove CDP events listeners.

Parameters:
  • event_handle (int) - Numeric ID which was returned when listener was added to detect the event.
Raises:

Class Variable Details

InterfaceTypes

Enumeration of the logical interface types supported.

ONEP_IF_TYPE_UNSUPPORTED: Reserved

ONEP_IF_TYPE_ANY: all types

ONEP_IF_TYPE_NULL: Null interface

ONEP_IF_TYPE_LOOPBACK: Loopback interface

ONEP_IF_TYPE_ETHERNET: Ethernet interface

ONEP_IF_TYPE_ETHER_CHANNEL: Ethernet channel interface.

ONEP_IF_TYPE_GIGABIT_ETHERNET: Gigabit ethernet interface. Deprecated. Use ONEP_IF_TYPE_ETHERNET instead.

ONEP_IF_TYPE_SERIAL: Serial interface.

ONEP_IF_TYPE_TUNNEL: Tunnel interface.

ONEP_IF_TYPE_P2P: Point to point interface

ONEP_IF_TYPE_MULTI_LINK: Multi-link interface

ONEP_IF_TYPE_TE: Traffic Engineering interface

ONEP_IF_TYPE_PSEUDOWIRE: Psuedowire interface

ONEP_IF_TYPE_WIRELESS: Wireless interface

ONEP_IF_TYPE_ATM: ATM interface

ONEP_IF_TYPE_FRAME_RELAY: Frame relay interface

ONEP_IF_TYPE_VLAN: VLAN interface

ONEP_IF_TYPE_PPP: PPP interface

ONEP_IF_TYPE_MLP_BUNDLE: MLP bundle interface

ONEP_IF_TYPE_POS: POS interface

ONEP_IF_TYPE_POS_CHANNEL: POS channel interface

ONEP_IF_TYPE_NATIVE_VLAN: Native VLAN interface

ONEP_IF_TYPE_HDLC: HDLC interface

ONEP_IF_TYPE_EFP: EFP interface

ONEP_IF_TYPE_BVI: BVI interface

ONEP_IF_TYPE_INTERFLEX_LEFT: InterflexLext interface

ONEP_IF_TYPE_INTERFLEX_RIGHT: InterflextRight interface

ONEP_IF_TYPE_PSEUDOWIRE_HE: Pseudowire interface

ONEP_IF_TYPE_SUB_INTERFACE: Sub interface

ONEP_IF_TYPE_MANAGEMENT: Management interface

Type:
Enum

Deprecated: ONEP_IF_TYPE_GIGABIT_ETHERNET

Value:
enum('ONEP_IF_TYPE_UNSUPPORTED', 'ONEP_IF_TYPE_ANY', 'ONEP_IF_TYPE_NUL\
L', 'ONEP_IF_TYPE_LOOPBACK', 'ONEP_IF_TYPE_ETHERNET', 'ONEP_IF_TYPE_ET\
HER_CHANNEL', 'ONEP_IF_TYPE_GIGABIT_ETHERNET', 'ONEP_IF_TYPE_SERIAL', \
'ONEP_IF_TYPE_TUNNEL', 'ONEP_IF_TYPE_P2P', 'ONEP_IF_TYPE_MULTI_LINK', \
'ONEP_IF_TYPE_TE', 'ONEP_IF_TYPE_PSEUDOWIRE', 'ONEP_IF_TYPE_WIRELESS',\
 'ONEP_IF_TYPE_ATM', 'ONEP_IF_TYPE_FRAME_RELAY', 'ONEP_IF_TYPE_VLAN', \
'ONEP_IF_TYPE_PPP', 'ONEP_IF_TYPE_MLP_BUNDLE', 'ONEP_IF_TYPE_POS', 'ON\
EP_IF_TYPE_POS_CHANNEL', 'ONEP_IF_TYPE_NATIVE_VLAN', 'ONEP_IF_TYPE_HDL\
...

IANAType


IANAType
    # all types 
    ONEP_IF_IANA_TYPE_ANY:0, 
    # unknown types 
    ONEP_IF_IANA_TYPE_OTHER:1,        
    # Loopback interface 
    ONEP_IF_IANA_TYPE_LOOPBACK:24,
    # Ethernet interface 
    ONEP_IF_IANA_TYPE_ETHERNET:6,
    # Ethernet channel interface 
    ONEP_IF_IANA_TYPE_ETHER_CHANNEL:161,
    # Gigabit ethernet interface 
    ONEP_IF_IANA_TYPE_GIGABIT_ETHERNET:6,
    # Serial interface 
    ONEP_IF_IANA_TYPE_SERIAL:22,
    # Tunnel interface 
    ONEP_IF_IANA_TYPE_TUNNEL:132,
    # Point to point interface 
    ONEP_IF_IANA_TYPE_P2P:23,
    # Multi-link interface 
    ONEP_IF_IANA_TYPE_MULTI_LINK:121,
    # Traffic Engineering interface 
    ONEP_IF_IANA_TYPE_TE:200,
    # Pseudo interface 
    ONEP_IF_IANA_TYPE_PSEUDOWIRE:246,
    # Wireless interface 
    ONEP_IF_IANA_TYPE_WIRELESS:157,
    # ATM interface 
    ONEP_IF_IANA_TYPE_ATM:37,
    # Frame relay interface 
    ONEP_IF_IANA_TYPE_FRAME_RELAY:32,
    # VLAN interface 
    ONEP_IF_IANA_TYPE_VLAN:136,
    # PPP interface 
    ONEP_IF_IANA_TYPE_PPP:23,
    # MLP bundle interface 
    ONEP_IF_IANA_TYPE_MLP_BUNDLE:121,
    # POS interface 
    ONEP_IF_IANA_TYPE_POS:171,
    # POS channel interface  
    ONEP_IF_IANA_TYPE_CHANNEL:70,
    # HDLC interface 
    ONEP_IF_IANA_TYPE_HDLC:118,
    # EFP interface 
    ONEP_IF_IANA_TYPE_EFP:135,
    # BVI interface 
    ONEP_IF_IANA_TYPE_BVI:209

Value:
{'ONEP_IF_IANA_TYPE_ANY': 0, 'ONEP_IF_IANA_TYPE_OTHER': 1, 'ONEP_IF_IA\
NA_TYPE_LOOPBACK': 24, 'ONEP_IF_IANA_TYPE_ETHERNET': 6, 'ONEP_IF_IANA_\
TYPE_ETHER_CHANNEL': 161, 'ONEP_IF_IANA_TYPE_GIGABIT_ETHERNET': 6, 'ON\
EP_IF_IANA_TYPE_SERIAL': 22, 'ONEP_IF_IANA_TYPE_TUNNEL': 132, 'ONEP_IF\
_IANA_TYPE_P2P': 23, 'ONEP_IF_IANA_TYPE_MULTI_LINK': 121, 'ONEP_IF_IAN\
A_TYPE_TE': 200, 'ONEP_IF_IANA_TYPE_PSEUDOWIRE': 246, 'ONEP_IF_IANA_TY\
PE_WIRELESS': 157, 'ONEP_IF_IANA_TYPE_ATM': 37, 'ONEP_IF_IANA_TYPE_FRA\
ME_RELAY': 32, 'ONEP_IF_IANA_TYPE_VLAN': 136, 'ONEP_IF_IANA_TYPE_PPP':\
...

interfaceTypeMap

Value:
{InterfaceTypes.ONEP_IF_TYPE_NULL: IANAType ['ONEP_IF_IANA_TYPE_OTHER'\
], InterfaceTypes.ONEP_IF_TYPE_LOOPBACK: IANAType ['ONEP_IF_IANA_TYPE_\
LOOPBACK'], InterfaceTypes.ONEP_IF_TYPE_ETHERNET: IANAType ['ONEP_IF_I\
ANA_TYPE_ETHERNET'], InterfaceTypes.ONEP_IF_TYPE_ETHER_CHANNEL: IANATy\
pe ['ONEP_IF_IANA_TYPE_ETHER_CHANNEL'], InterfaceTypes.ONEP_IF_TYPE_GI\
GABIT_ETHERNET: IANAType ['ONEP_IF_IANA_TYPE_ETHERNET'], InterfaceType\
s.ONEP_IF_TYPE_SERIAL: IANAType ['ONEP_IF_IANA_TYPE_SERIAL'], Interfac\
eTypes.ONEP_IF_TYPE_TUNNEL: IANAType ['ONEP_IF_IANA_TYPE_TUNNEL'], Int\
...

doc_vlan

Value:
'''
        subinterface dot1q vlan tag
        '''