Use the methods in the interface module to manage interfaces on the switch.
Interface Class
class Interface()
Example:
>>> from cisco.interface import *
>>> intf127 = Interface('Ethernet1/27')
interfaces
Note: a class method
interfaces(cls, refresh=False)
Example:
>>> from cisco.interface import *
>>> Interface.interfaces()
['mgmt0', 'Ethernet1/1', 'Ethernet1/2', 'Ethernet1/3', ...
Arguments:
- refresh:
Returns: A list of interfaces on the switch.
normalize
Note: a class method
normalize(cls, intf)
parsed_if
Note: a class method
parsed_if(cls, intf)
apply_config
apply_config(self)
Example:
>>> intf3.apply_config()
config
config(self, refresh=False)
Example:
>>> intf3.config()
set_description
set_description(self, d=None)
Example:
>>> intf3.set_description("Interface 3")
Arguments:
- d: A string. Description of the interface.
Returns: True on success
set_ipaddress
Sets the IP address of the interface
set_ipaddress(self, ip_address=None, mask=None, secondary=None, delete=None)
Examples:
>>> intf3.set_ipaddress("192.0.2.123")
>>> intf3.set_ipaddress("192.0.2.123/24", delete=True)
>>> intf3.set_ipaddress(ip_address="192.0.2.123", mask=24)
Arguments:
- ip_address:
- mask:
- secondary:
- delete:
Returns: True on success
set_mode
Sets the switchport mode
set_mode(self, mode='access')
Example:
>>> intf3.set_mode(mode="access")
Arguments:
- mode: Can be either 'access' or 'trunk'
Returns: True on success
set_state
set_state(self, s='up')
Example:
>>> intf3.set_state(s="no shut")
Arguments:
- s: Desired state of the interface. If s is 'up', 'no shut', or 'noshut', the interface is enabled. Otherwise it is disabled.
Returns: True on success
set_switchport
set_switchport(self, **kwargs)
Example:
>>> intf3.set_switchport()
Returns: True on success
show
show(self, key=None)
Example:
>>> intf3.show()