Ticket #1843 (closed defect: fixed)

Opened 16 months ago

Last modified 6 weeks ago

zendisc doesn't work on networks with children

Reported by: cluther Owned by: cluther
Priority: 1 - Blocker Milestone: zenoss-2.1
Component: DataCollector Version: 2.0.2
Severity: low Keywords: zendisc network not found
Cc: Documentation: Not required
Installer: Reviewed: yes

Description

zendisc fails to find the requested --net= network when the network specified has children, but no child that contains the IP specified.

An example network structure:

  • 10.0.0.0/8
    • 10.1.0.0/16
      • 10.1.2.0/24
        • 10.1.2.4/30

zendisc run --net=10.1.2.0 will fail because 10.1.2.0 has children, but no child that contains 10.1.2.0.

Proposed fix:

Index: DataCollector/zendisc.py
===================================================================
--- DataCollector/zendisc.py    (revision 5999)
+++ DataCollector/zendisc.py    (working copy)
@@ -195,8 +195,7 @@
         if self.options.net:
             for net in self.options.net:
                 try:
-                    #netobj = self.dmd.Networks._getNet(net) 
-                    netobj = self.dmd.Networks.getSubNetwork(net)
+                    netobj = self.dmd.Networks._getNet(net) 
                     if not netobj:
                         raise SystemExit("network %s not found in dmd" % net)
                     for ip in self.discoverIps((netobj,)):
Index: ZenModel/IpNetwork.py
===================================================================
--- ZenModel/IpNetwork.py       (revision 5999)
+++ ZenModel/IpNetwork.py       (working copy)
@@ -173,7 +173,11 @@
         for net in self.children():
             if net.hasIp(ip):
                 if len(net.children()):
-                    return net._getNet(ip)
+                    subnet = net._getNet(ip)
+                    if subnet:
+                        return subnet
+                    else:
+                                                                                                        return net
                 else:
                     return net

Change History

Changed 16 months ago by cluther

The previous fix didn't account for scanning networks that did have children properly. It would scan the entire 10.1.2.0/24 network instead of only scanning the defined network within it.

Updated proposed fix:

Index: DataCollector/zendisc.py
===================================================================
--- DataCollector/zendisc.py    (revision 5999)
+++ DataCollector/zendisc.py    (working copy)
@@ -65,6 +65,7 @@
             nets = self.dmd.Networks.getSubNetworks()
         goodCount = 0
         for net in nets:
+            if len(net.children()) > 0: continue
             if not getattr(net, "zAutoDiscover", False): 
                 self.log.warn("skipping network %s zAutoDiscover is False"
                                 % net.id)
@@ -195,11 +196,15 @@
         if self.options.net:
             for net in self.options.net:
                 try:
-                    #netobj = self.dmd.Networks._getNet(net) 
-                    netobj = self.dmd.Networks.getSubNetwork(net)
+                    nets = []
+                    netobj = self.dmd.Networks._getNet(net) 
                     if not netobj:
                         raise SystemExit("network %s not found in dmd" % net)
-                    for ip in self.discoverIps((netobj,)):
+                    if len(netobj.children()) == 0:
+                        nets.append(netobj)
+                    else:
+                        nets.extend(netobj.getSubNetworks())
+                    for ip in self.discoverIps(nets):
                         self.dmd._p_jar.sync()
                         if not self.options.nosnmp: 
                             self.discoverDevice(ip, self.options.deviceclass,
Index: ZenModel/IpNetwork.py
===================================================================
--- ZenModel/IpNetwork.py       (revision 5999)
+++ ZenModel/IpNetwork.py       (working copy)
@@ -173,7 +173,11 @@
         for net in self.children():
             if net.hasIp(ip):
                 if len(net.children()):
-                    return net._getNet(ip)
+                    subnet = net._getNet(ip)
+                    if subnet:
+                        return subnet
+                    else:
+                        return net
                 else:
                     return net

Changed 15 months ago by cluther

  • priority changed from medium to high

Changed 15 months ago by edahl

  • owner changed from chris to cluther
  • priority changed from high to blocker

We need to make it an option to recurse down the network tree using only existing networks.

Changed 14 months ago by cluther

  • status changed from new to closed
  • resolution set to fixed

(In [6980]) * Fixes #1843. Adds --subnets option to zendisc.

Changed 6 weeks ago by bbibeault

  • documentation set to Not required
  • reviewed set
Note: See TracTickets for help on using tickets.