Ejemplo n.º 1
0
def main():
    """main function
    """
    try:
        handler = TopoHandler()
        prepare_service(handler=handler)
    except Exception as e:
        print(e)
Ejemplo n.º 2
0
def main():
    try:
        cli_handler = CliHandler()
        prepare_service(handler=cli_handler)
    except Exception as e:
        print(e)
Ejemplo n.º 3
0
def yabgp(routerid, asn, peerip, peeras):
    import tempfile
    from yabgp.agent import prepare_service
    from yabgp.handler import BaseHandler

    class BGPHandler(BaseHandler):
        def __init__(self):
            super(BGPHandler, self).__init__()

        def init(self):
            pass

        def on_update_error(self, peer, timestamp, msg):
            log.error('[-] UPDATE ERROR: %s: %s', str(peer), str(msg))
            #return super(BGPHandler, self).on_update_error(peer, timestamp, msg)

        def route_refresh_received(self, peer, msg, msg_type):
            log.info('[+] ROUTE_REFRESH received %s %s %s', str(peer),
                     str(msg), str(msg_type))
            #return super(BGPHandler, self).route_refresh_received(peer, msg, msg_type)

        # def keepalive_received(self, peer, timestamp):
        #     print('[+] KEEPALIVE received')

        def open_received(self, peer, timestamp, result):
            log.info('[+] OPEN received: %s: %s', str(peer), str(result))

        def update_received(self, peer, timestamp, msg):
            log.info('[+] UPDATE received %s: %s', str(peer), str(msg))

        def notification_received(self, peer, msg):
            log.error('[-] NOTIFICATION received %s: %s', str(peer), str(msg))
            #return super(BGPHandler, self).notification_received(peer, msg)

        def on_connection_lost(self, peer):
            log.error('[-] CONNECTION lost: %s', str(peer))
            #return super(BGPHandler, self).on_connection_lost(peer)

        def on_connection_failed(self, peer, msg):
            log.error('[-] CONNECTION failed %s: %s', str(peer), str(msg))
            #return super(BGPHandler, self).on_connection_failed(peer, mg)

    from yabgp.config import CONF

    # args = "--bgp-local_as={} --bgp-remote_addr={} --bgp-remote_as={} --bgp-afi_safi=ipv4,ipv6".format(
    #     asn, peerip, peeras)
    conffile = tempfile.NamedTemporaryFile(mode='w')
    conffile.write("""
[DEFAULT]
verbose=False
[message]
write_disk = False
[bgp]
local_as={}
remote_addr={}
remote_as={}
afi_safi=ipv4
four_bytes_as = True
route_refresh = False
cisco_route_refresh = False
graceful_restart = False
cisco_multi_session = False
enhanced_route_refresh = False
""".format(asn, peerip, peeras))
    conffile.flush()

    try:
        bgp_handler = BGPHandler()
        prepare_service(
            args=["--config-file=" + conffile.name], handler=bgp_handler)
    except Exception as e:
        print(e)
Ejemplo n.º 4
0
Archivo: cmd.py Proyecto: xinwu/yabgp
def main():
    try:
        prepare_service()
    except Exception as e:
        print e
Ejemplo n.º 5
0
def main():
    prepare_service()
Ejemplo n.º 6
0
def main():
    try:
        prepare_service()
    except Exception as e:
        print e