File: rename-vlan.py

package info (click to toggle)
snimpy 1.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 584 kB
  • sloc: python: 4,141; makefile: 21
file content (22 lines) | stat: -rw-r--r-- 585 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/snimpy

import os
import sys

load("SNMPv2-MIB")
load(os.path.expanduser("~/.snmp/mibs/RAPID-CITY-MIB"))
load(os.path.expanduser("~/.snmp/mibs/RC-VLAN-MIB"))

vlanNumber = int(sys.argv[3])
newName = sys.argv[4]
s = M(host=sys.argv[1], community=sys.argv[2])


try:
    cur = s.rcVlanName[vlanNumber]
except snmp.SNMPException:
    print("%s is not a Nortel switch or does not have VLAN %d" % (sys.argv[1], vlanNumber))
    sys.exit(1)
if cur != newName:
    s.rcVlanName[vlanNumber] = newName
print("Setting VLAN %d of %s as %s: done." % (vlanNumber, sys.argv[1], newName))