Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
configurations = []
# check the file only once that we have parsed all the command line options and allowed them to run
if options[""]:
for f in options[""]:
normalised = os.path.realpath(os.path.normpath(f))
if os.path.isfile(normalised):
configurations.append(normalised)
continue
if f.startswith('etc/exabgp'):
normalised = os.path.join(folder,f[11:])
if os.path.isfile(normalised):
configurations.append(normalised)
continue
from exabgp.logger import Logger
logger = Logger()
logger.configuration('one of the arguments passed as configuration is not a file (%s)' % f,'error')
sys.exit(1)
else:
print(usage)
print 'Environment values are:\n' + '\n'.join(' - %s' % _ for _ in environment.default())
print '\nno configuration file provided'
sys.exit(1)
from exabgp.bgp.message.update.attribute.attribute import Attribute
Attribute.caching = env.cache.attributes
if env.debug.rotate or len(configurations) == 1:
run(env,comment,configurations)
if not (env.log.destination in ('syslog','stdout','stderr') or env.log.destination.startswith('host:')):
def run (env, comment, configurations, pid=0):
cwd = os.getcwd()
from exabgp.logger import Logger
logger = Logger()
if comment:
logger.configuration(comment)
if not env.profile.enable:
reactor = Reactor(configurations)
reactor.run()
__exit(env.debug.memory, reactor.exit_code)
try:
import cProfile as profile
except ImportError:
import profile
if env.profile.file == 'stdout':
reactor = Reactor(configurations)
def __init__ (self):
self.processes = {}
self.neighbors = {}
self.logger = Logger ()
def __init__ (self, backlog=200):
self._backlog = backlog
self.serving = False
self._sockets = {}
self.logger = Logger()
def __init__ (self, reactor):
self.pid = environment.settings().daemon.pid
self.user = environment.settings().daemon.user
self.daemonize = environment.settings().daemon.daemonize
self.logger = Logger()
self.reactor = reactor
os.chdir('/')
# os.umask(0)
os.umask(0137)
def __init__ (self):
self.logger = Logger()
self.clean()
self.silence = False
self._buffer = {}
self._configuration = {}
self.respawn_number = 5 if environment.settings().api.respawn else 0
self.terminate_on_error = environment.settings().api.terminate
self.ack = environment.settings().api.ack
def bug_report (dtype, value, trace):
print(PANIC)
import traceback
print("-- Traceback\n\n")
traceback.print_exception(dtype,value,trace)
from exabgp.logger import Logger
logger = Logger()
print("\n\n-- Configuration\n\n")
print(logger.config())
print("\n\n-- Logging History\n\n")
print(logger.history())
print("\n\n\n")
print(FOOTER)
def __init__ (self, configurations, text=False):
self.debug = environment.settings().debug.configuration
self.api_encoder = environment.settings().api.encoder
self.cli_socket = environment.settings().api.socket
self.logger = Logger()
self._text = text
self._configurations = configurations
self._dispatch_route_cfg = {
'origin': self._route_origin,
'as-path': self._route_aspath,
# For legacy with version 2.0.x
'as-sequence': self._route_aspath,
'med': self._route_med,
'aigp': self._route_aigp,
'next-hop': self._route_next_hop,
'local-preference': self._route_local_preference,
'atomic-aggregate': self._route_atomic_aggregate,
'aggregator': self._route_aggregator,
'path-information': self._route_path_information,
'originator-id': self._route_originator_id,
'cluster-list': self._route_cluster_list,
def check_neighbor (neighbors):
logger = Logger()
logger._option.parser = True
logger.parser('\ndecoding routes in configuration')
for name in neighbors.keys():
neighbor = neighbors[name]
path = {}
for f in NLRI.known_families():
if neighbor.add_path:
path[f] = neighbor.add_path
capa = Capabilities().new(neighbor,False)
if path:
capa[Capability.CODE.ADD_PATH] = path
capa[Capability.CODE.MULTIPROTOCOL] = neighbor.families()
def __init__ (self,reactor):
self.reactor = reactor
self.logger = Logger()
self.parser = Parser.Text(reactor)
try:
for name in self.functions:
self.callback['text'][name] = Command.Text.callback[name]
except KeyError:
raise RuntimeError('The code does not have an implementation for "%s", please code it !' % name)