Esempio n. 1
0
 def updateHostList(self):
     """
     Fetches all netboxes from the NAVdb, and updates
     internal data structures.
     """
     LOGGER.debug("Getting hosts from database...")
     hosts = self.db.hosts_to_ping()
     netboxmap = {}
     self.ipToNetboxid = {}
     for host in hosts:
         netboxid, sysname, ip, up = host
         netbox = Netbox(netboxid, sysname, ip, up)
         if not self.netboxmap.has_key(netbox.netboxid):
             # new netbox. Be sure to get it's state
             if netbox.up != 'y':
                 LOGGER.debug(
                     "Got new netbox, %s, currently "
                     "marked down in navDB", netbox.ip)
                 self.down.append(netbox.netboxid)
         if not self.replies.has_key(netbox.netboxid):
             self.replies[netbox.netboxid] = circbuf.CircBuf()
             if netbox.up != 'y':
                 buf = self.replies[netbox.netboxid]
                 # This genious line marks all-down for the whole buf
                 map(buf.push, [-1] * len(buf))
         netboxmap[netbox.netboxid] = netbox
         self.ipToNetboxid[netbox.ip] = netbox.netboxid
     # Update netboxmap
     self.netboxmap = netboxmap
     LOGGER.debug("We now got %i hosts in our list to ping",
                  len(self.netboxmap))
     # then update our pinger object
     self.pinger.set_hosts(self.ipToNetboxid.keys())
Esempio n. 2
0
 def update_host_list(self):
     """
     Fetches all netboxes from the NAVdb, and updates
     internal data structures.
     """
     _logger.debug("Getting hosts from database...")
     netbox_included_groups = self.config.get("groups_included", "").split()
     netbox_excluded_groups = self.config.get("groups_excluded", "").split()
     hosts = self.db.hosts_to_ping(netbox_included_groups, netbox_excluded_groups)
     netboxmap = {}
     self.ip_to_netboxid = {}
     for host in hosts:
         netboxid, sysname, ip, up = host
         netbox = Netbox(netboxid, sysname, ip, up)
         if netbox.netboxid not in self.netboxmap:
             # new netbox. Be sure to get it's state
             if netbox.up != 'y':
                 _logger.debug(
                     "Got new netbox, %s, currently " "marked down in navDB",
                     netbox.ip,
                 )
                 self.down.append(netbox.netboxid)
         if netbox.netboxid not in self.replies:
             self.replies[netbox.netboxid] = circbuf.CircBuf(self._nrping)
             if netbox.up != 'y':
                 self.replies[netbox.netboxid].reset_all_to(-1)
         netboxmap[netbox.netboxid] = netbox
         self.ip_to_netboxid[netbox.ip] = netbox.netboxid
     # Update netboxmap
     self.netboxmap = netboxmap
     _logger.debug("We now got %i hosts in our list to ping", len(self.netboxmap))
     # then update our pinger object
     self.pinger.set_hosts(self.ip_to_netboxid.keys())