Esempio n. 1
0
def main():

    # without this line, no events would be fired, no topology discovered and no entries computed
    Event.activate()

    # base controller
    controller = BaseController(p4info_file_path=Configuration.get('p4info'),
                                bmv2_path=Configuration.get('bmv2_json'),
                                prog_name=Configuration.get('prog_name'),
                                bin_path=Configuration.get('bin_path'),
                                cxt_json_path=Configuration.get('cxt_path'))

    # register event for new switch connections, this will add switches to device list
    Event.on('new_switch_connection', TopologyManager.add_device)

    # register events for static classes
    Event.on("packet_in",
             MessageInHandler.message_in)  # handles generic packet in
    Event.on("topology_to_controller", GlobalConnection.send_topology_packet
             )  # triggers the send routine to server
    Event.on("igmp_packet_to_controller", GlobalConnection.send_group_packet
             )  # triggers the send routine to server
    Event.on(
        "port_msg_to_controller",
        GlobalConnection.send_port_info)  # triggers the send routine to server

    topology = TopologyController(controller)

    # Create instances of sub controller
    mac = MacController(controller)
    port = PortController(controller=controller)

    pd = PDSetup()
    mc = MulticastController(pd=pd, base=controller)

    # start connection procedure
    init_switches(controller=controller, topology_controller=topology, pd=pd)

    bier = BierController(controller)

    # start grpc server for connection to main controller
    grpc_server = GRPCServer(listen_port=Configuration.get('listen_port'))

    # set controller in local server for table entry
    LocalServer.controller = controller

    # start grpc server
    grpc_server.start()

    # start port monitor
    #threading.Thread(target=port.monitor_messages()).start()

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        pd.end()
        Log.info("Shutting down")
        os._exit(0)
Esempio n. 2
0
def main():

    # without this line, no events would be fired, no topology discovered and no entries computed
    Event.activate()

    # base controller
    controller = BaseController(Configuration.get('p4info'),
                                Configuration.get('bmv2_json'))

    # register event for new switch connections, this will add switches to device list
    Event.on('new_switch_connection', TopologyManager.add_device)

    # register events for static classes
    Event.on("packet_in",
             MessageInHandler.message_in)  # handles generic packet in
    Event.on("topology_to_controller", GlobalConnection.send_topology_packet
             )  # triggers the send routine to server
    Event.on("igmp_packet_to_controller", GlobalConnection.send_group_packet
             )  # triggers the send routine to server
    Event.on(
        "port_msg_to_controller",
        GlobalConnection.send_port_info)  # triggers the send routine to server

    topology = TopologyController(controller)

    # Create instances of sub controller
    mac = MacController(controller)
    port = PortController(
        controller=controller,
        notification_socket=Configuration.get('notification_socket'))
    group = GroupController(thrift_port=Configuration.get('thrift_port'),
                            base=controller)

    # start connection procedure
    init_switches(controller=controller,
                  topology_controller=topology,
                  group_controller=group)

    # start grpc server for connection to main controller
    grpc_server = GRPCServer(listen_port=Configuration.get('listen_port'))

    # set controller in local server for table entry
    LocalServer.controller = controller

    # start grpc server
    grpc_server.start()

    # start port monitor
    threading.Thread(target=port.monitor_messages()).start()
Esempio n. 3
0
def main():
    Configuration.set('system_done', False)

    # without this line, no events would be fired, no topology discovered and no entries computed
    Event.activate()

    # register event for new switch connections, this will add switches to device list
    Event.on('new_switch_connection', TopologyManager.add_device)

    # base controller
    controller = BaseController()

    # register events for static classes
    Event.on("igmp_packet_in", GroupManager.handle_packet_in)  # handles (un-)sub requests
    Event.on("port_message", TopologyManager.react_to_port_change)
    Event.on("topology_change", TopologyManager.build_domain)

    topology = TopologyController(controller)

    # Create instances of sub controller for CLI
    ipv4 = IPv4Controller(controller)
    bier = BierController(controller)
    #tunnel = TunnelController(controller)

    # add some cli commands for static classes without init
    CLI.add_command("plot_topology", TopologyManager.plot, "Plot topology")
    CLI.add_command("describe_topology", TopologyManager.describe, "Describe topology")
    CLI.add_command("describe_groups", GroupManager.describe, "Describe groups")
    CLI.add_command("show_configuration", Configuration.show_all, "Show all configurations")
    CLI.add_command("table_manager", TableEntryManager.handle_cli_command, "show_tables <controller name>")

    CLI.add_command("load_static_rules", load_static_rules, "Load static rules", ipv4)

    # start global grpc control server
    GRPCServer(listen_port=Configuration.get('listen_port')).start()

    # start connection procedure in thread, so that cli will get initialized and logs can be printed
    threading.Timer(2, connect_to_switches, kwargs={'controller': controller}).start()

    CLI.start_cli()