Advertisement
cyid

SNMP Rename

Mar 20th, 2014
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. GO = True
  2. log = open('/tmp/Title_rename.txt', "w")
  3. for d in dmd.Devices.getSubDevices():
  4.     if d.id != d.snmpSysName:
  5.         newid = d.snmpSysName
  6.         print >>log, "Device ID: " + d.id
  7.             print >>log, "Device Title: " + d.title
  8.         print >>log, "Device SysName: " + d.snmpSysName
  9.             print >>log, "Device IP: " + d.manageIp
  10.         print >>log, "New Device Info: " + newid
  11.         if GO == True:
  12.             if d.id == newid and d.title == newid:
  13.                 print >>log, "Change not needed."
  14.             elif len(newid) > 0:
  15.                 d.setTitle(newid)
  16.                 print >>log, "Changed Title to: " + newid
  17.                 d.renameDevice(newid)
  18.                 print >>log, "Changed ID to: " + newid
  19.                 commit()
  20.             else:
  21.                 print >>log, "SysName not set. No changes made."
  22.         print >>log, '-'*40
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement