def debug_check_route (self): # we are not really running the program, just want to .... if environment.settings().debug.route: from exabgp.configuration.check import check_message if check_message(self.neighbors,environment.settings().debug.route): sys.exit(0) sys.exit(1)
def _reload (self): # taking the first configuration available (FIFO buffer) fname = self._configurations.pop(0) self.process.configuration(fname) self._configurations.append(fname) # storing the routes associated with each peer so we can find what changed backup_changes = {} for neighbor in self._neighbors: backup_changes[neighbor] = self._neighbors[neighbor].changes # clearing the current configuration to be able to re-parse it self._clear() if not self.tokens.set_file(fname): return False # parsing the configurtion r = False while not self.tokens.finished: r = self._dispatch( self._scope,'configuration', ['group','neighbor'], [] ) if r is False: break # handling possible parsing errors if r not in [True,None]: return self.error.set("\nsyntax error in section %s\nline %d: %s\n\n%s" % (self._location[-1],self.tokens.number,' '.join(self.tokens.line),self.error)) # parsing was sucessful, assigning the result self.neighbors = self._neighbors # installing in the neighbor what was its previous routes so we can # add/withdraw what need to be for neighbor in self.neighbors: self.neighbors[neighbor].backup_changes = backup_changes.get(neighbor,[]) # we are not really running the program, just want to .... if environment.settings().debug.route: from exabgp.configuration.check import check_message if check_message(self.neighbors,environment.settings().debug.route): sys.exit(0) sys.exit(1) # we are not really running the program, just want check the configuration validity if environment.settings().debug.selfcheck: from exabgp.configuration.check import check_neighbor if check_neighbor(self.neighbors): sys.exit(0) sys.exit(1) return True
def check(self, route): from exabgp.configuration.check import check_message if not self.reload(): return 1 neighbors = self.configuration.neighbors for neighbor in neighbors.values(): if not check_message(neighbor, route): return 1 return 0