Difference between revisions of "ZenDMD Tip - Change Interface Speed"

From Zenoss Wiki
Jump to: navigation, search
(Updated script and warning)
(create page, helpful zendmd script)
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
The following is a zendmd script to set the speed for an interface of a device. Sometimes after a device is modeled the interface speed can be incorrect.
+
The following is a zendmd script to set the speed for an interface of a device.
  
'''WARNING:''' Be careful and remember to take a backup and/or snapshot before running the below script! The options to set the speed and commit the changes have been commented out for your protection.
+
Sometimes after a device is modeled the interface speed can be incorrect.
  
https://github.com/hydruid/zenoss/blob/master/zendmd/interface_speed.zendmd
 
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
#!/usr/bin/env zendmd
+
d = dmd.Devices.findDevice('xensvr02')
 
+
DEVICE = 'xensvr02'
+
INTERFACE = 'eth0'
+
SPEED10Mb = '100000000'
+
SPEED100Mb = '100000000'
+
SPEED1Gb = '1000000000'
+
SPEED10Gb = '10000000000'
+
SPEED = SPEED10Gb
+
 
+
d = dmd.Devices.findDevice(DEVICE)
+
 
for dev in d.Devices.getSubDevices():
 
for dev in d.Devices.getSubDevices():
     if dev == d:
+
     value = d.getProperty(dev)
        value = d.getProperty(dev)
+
    for interface in d.os.interfaces():
        for interface in d.os.interfaces():
+
        if interface.id.startswith('xenbr4'):
            if interface.id.startswith(INTERFACE):
+
            interface.speed = ('1000000000')
                print interface.id
+
            commit ()
                print interface.speed
+
#                interface.speed = (SPEED)
+
#                commit ()
+
  
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Don't forget to lock the interface from updates, or once it's remodeled the change will be lost!
 
  
 
http://hydruid-blog.com/?p=675
 
http://hydruid-blog.com/?p=675

Revision as of 20:08, 7 January 2014

The following is a zendmd script to set the speed for an interface of a device.

Sometimes after a device is modeled the interface speed can be incorrect.

d = dmd.Devices.findDevice('xensvr02')
for dev in d.Devices.getSubDevices():
    value = d.getProperty(dev)
    for interface in d.os.interfaces():
        if interface.id.startswith('xenbr4'):
            interface.speed = ('1000000000')
            commit ()

http://hydruid-blog.com/?p=675