Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (41 sloc) 2 KB
# OneP script to shutdown an interface found by searching for an IP address
# Usage:
# python [ip_address] [username] [password] [ip_to_shutdown] [1/0]
# This script uses the module
from onep_connect import connect
from onep.interfaces import InterfaceFilter
import sys
if len(sys.argv) < 5:
print 'Usage: python [ip_address] [username] [password] [ip_to_shutdown] [1/0]'
# Connect using passed in connection values
# (will raise a ValueError if bad IP address or credentials)
ne = connect(sys.argv[1], sys.argv[2], sys.argv[3])
#Create Interface Filter and find interface by IP
if_filter = InterfaceFilter(interface_type=1)
for interface in ne.get_interface_list(if_filter):
if sys.argv[4] in interface.get_address_list():
# Use passed in shutdown command, or just shutdown
if int(sys.argv[5]) == 1:
print '%s has been shutdown.' %
elif int(sys.argv[5]) == 0:
print '%s has been re-enabled.' %
except IndexError, ValueError:
print '%s has been shutdown.' %
# Finally have the application disconnect from the Network Element
## Output:
# thePacketGeek$ python admin admin 1
# Loopback0 has been shutdown.
## Logging on IOS Device
# *Nov 11 20:04:21.030: %ONEP_BASE-6-CONNECT: [Element]: ONEP session Application:noname Host: ID:1439 User:admin has connected.
# *Nov 11 20:04:21.038: %SYS-5-CONFIG_I: Configured from by admin on onePK Application: noname ID: 1439
# *Nov 11 20:04:21.045: %ONEP_BASE-6-DISCONNECT: [Element]: ONEP session Application:noname Host: ID:1439 User:admin has disconnected.
# *Nov 11 20:04:23.038: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to down
# *Nov 11 20:04:23.038: %LINK-5-CHANGED: Interface Loopback0, changed state to administratively down
You can’t perform that action at this time.