Difference between revisions of "ZENDMD Tip - Delete Networks"

From Zenoss Wiki
Jump to: navigation, search
(zendmd script to delete most networks)
 
Line 1: Line 1:
If you delete lots of devices, the networks doscovered that were associated with them never get cleaned up.
+
If you delete lots of devices, the networks discovered that were associated with them never get cleaned up.
  
 
I wanted to delete all networks except 192.168.10.0.  
 
I wanted to delete all networks except 192.168.10.0.  
Line 25: Line 25:
  
 
Make it executable and run it as the zenoss user.  
 
Make it executable and run it as the zenoss user.  
 +
 +
--Jcurry
  
 
[[Category:Tips]]
 
[[Category:Tips]]

Revision as of 18:50, 7 August 2013

If you delete lots of devices, the networks discovered that were associated with them never get cleaned up.

I wanted to delete all networks except 192.168.10.0.

Create delete_networks with:

#!/usr/bin/env zendmd
for netid in dmd.Networks.objectIds(spec="IpNetwork"):
    try:
        print "Deleting network %s" % netid
        if netid == '192.168.10.0':
            print 'Dont delete %s' % (netid)
            continue
        dmd.Networks._delObject(netid)
        commit()
    except Exception, e:
        print "%s: %s" % (netid, str(e))
 
dmd.Networks.reIndex()

To test, comment out the dmd.Networks._delObject(netid) line.

Make it executable and run it as the zenoss user.

--Jcurry