def discoverRanges(self, driver): """ Ping all IPs in the range and create devices for the ones that come back. @param ranges: list of ranges to discover @type ranges: list """ if isinstance(self.options.range, basestring): self.options.range = [self.options.range] # in case someone uses 10.0.0.0-5,192.168.0.1-5 instead of # --range 10.0.0.0-5 --range 192.168.0.1-5 if (isinstance(self.options.range, list) and self.options.range[0].find(",") > -1): self.options.range = [n.strip() for n in self.options.range[0].split(',')] ips = [] goodCount = 0 for iprange in self.options.range: # Parse to find ips included ips.extend(parse_iprange(iprange)) yield NJobs(self.options.chunkSize, self.ping, ips).start() results = driver.next() goodips = [v.ipaddr for v in results if not isinstance(v, Failure)] badips = [v.value.ipaddr for v in results if isinstance(v, Failure)] goodCount += len(goodips) self.log.debug("Got %d good IPs and %d bad IPs", len(goodips), len(badips)) yield self.discoverDevices(goodips) yield succeed("Discovered %d active IPs" % goodCount) driver.next()
def discoverRanges(self, driver): """ Ping all IPs in the range and create devices for the ones that come back. @param ranges: list of ranges to discover @type ranges: list """ if isinstance(self.options.range, basestring): self.options.range = [self.options.range] # in case someone uses 10.0.0.0-5,192.168.0.1-5 instead of # --range 10.0.0.0-5 --range 192.168.0.1-5 if (isinstance(self.options.range, list) and self.options.range[0].find(",") > -1): self.options.range = [ n.strip() for n in self.options.range[0].split(',') ] ips = [] goodCount = 0 for iprange in self.options.range: # Parse to find ips included ips.extend(parse_iprange(iprange)) yield NJobs(self.options.chunkSize, self.ping, ips).start() results = driver.next() goodips = [v.ipaddr for v in results if not isinstance(v, Failure)] badips = [v.value.ipaddr for v in results if isinstance(v, Failure)] goodCount += len(goodips) self.log.debug("Got %d good IPs and %d bad IPs", len(goodips), len(badips)) yield self.discoverDevices(goodips) yield succeed("Discovered %d active IPs" % goodCount) driver.next()
def discoverRanges(self): """ Ping all IPs in the range and create devices for the ones that come back. """ iprange = self.options.range if isinstance(iprange, basestring): iprange = [iprange] # in case someone uses 10.0.0.0-5,192.168.0.1-5 instead of # --range 10.0.0.0-5 --range 192.168.0.1-5 if isinstance(iprange, list) and iprange[0].find(",") > -1: iprange = [n.strip() for n in iprange[0].split(',')] ips = [] for rangelimit in iprange: # Parse to find ips included ips.extend(parse_iprange(rangelimit)) results = yield self.pingMany(ips) goodips, badips = _partitionPingResults(results) self.log.debug("Found %d good IPs and %d bad IPs", len(goodips), len(badips)) devices = yield self.discoverDevices(goodips) self.log.info("Discovered %d active IPs", len(goodips)) defer.returnValue(devices)
def discoverRanges(self): """ Ping all IPs in the range and create devices for the ones that come back. """ iprange = self.options.range if isinstance(iprange, basestring): iprange = [iprange] # in case someone uses 10.0.0.0-5,192.168.0.1-5 instead of # --range 10.0.0.0-5 --range 192.168.0.1-5 if isinstance(iprange, list) and iprange[0].find(",") > -1: iprange = [n.strip() for n in iprange[0].split(',')] ips = [] for rangelimit in iprange: # Parse to find ips included ips.extend(parse_iprange(rangelimit)) results = yield self.pingMany(ips) goodips, badips = _partitionPingResults(results) self.log.debug( "Found %d good IPs and %d bad IPs", len(goodips), len(badips)) devices = yield self.discoverDevices(goodips) self.log.info("Discovered %d active IPs", len(goodips)) defer.returnValue(devices)