JosefJezek
11/22/2013 - 1:33 PM

Zenoss: Setting IP interface speed using a script

Zenoss: Setting IP interface speed using a script

#!/usr/bin/env python
# Usage: ./script.py cisco Fast 100000000
# For setting speed to 100Mbps on all FastEthernet interfaces on ALL devices that begin with cisco (like cisco-002.net.myorg.com).
# http://pro-blog.chitambira.com/2009/11/zenoss-setting-ip-interface-speed-using.html
import sys
import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from transaction import commit

dmd = ZenScriptBase(connect=True).dmd

for dev in dmd.Devices.getSubDevices():
  if dev.id.startswith(sys.argv[1]):
   for interface in dev.os.interfaces():
    if interface.id.startswith(sys.argv[2]):
     interface.speed = float(sys.argv[3])
     interface.lockFromUpdates()
commit()