示例#1
0
        def __init__(self, *opts, **kwargs):

            #if prog.version == 14:
            #switch_path = config.simple_switch_path
            #enable_grpc = False
            #elif prog.version == 16:
            #switch_path = config.simple_switch_grpc_path
            #enable_grpc = True
            #else:
            #raise Exception("Switch does not support P4 version " + str(prog.version))
            #kwargs2 = dict(
            #enable_grpc=enable_grpc,
            #cli_path=config.simple_switch_cli_path,
            #sw_path=switch_path,
            #log_console=config.bmv2_log,
            #program=prog,
            #pcap_dump=config.pcap_dump,
            #)

            kwargs2 = dict(
                enable_grpc=False,
                cli_path=config.simple_switch_cli_path,
                sw_path=config.simple_switch_path,
                log_console=config.bmv2_log,
                program=prog,
            )
            kwargs2.update(switch_args)
            kwargs2.update(kwargs)

            P4RuntimeSwitch.__init__(self, *opts, **kwargs2)
示例#2
0
    def __init__(self, *opts, **kwargs):
        self.controller = None

        prog = kwargs.get('prog')
        if prog is None:
            raise Exception('Must specify p4 program')
        prog = P4Program(prog)

        if prog.version == 14:
            sw_path = 'simple_switch'
            enable_grpc = False
        elif prog.version == 16:
            sw_path = 'simple_switch_grpc'
            enable_grpc = True
        else:
            raise Exception('Switch does not support P4 version %s' %
                            prog.version)

        self.ctrl_args = dict()
        if 'ctrl_args' in kwargs:
            self.ctrl_args = kwargs['ctrl_args']
            del kwargs['ctrl_args']

        kwargs.update({
            'enable_grpc': enable_grpc,
            'cli_path': 'simple_switch_CLI',
            'sw_path': sw_path,
            'program': prog,
            'start_controller': True,
        })

        P4RuntimeSwitch.__init__(self, *opts, **kwargs)
示例#3
0
    def __init__(self,
                 name,
                 router_id='1.1.1.1',
                 area_id='0.0.0.0',
                 lsunit=30,
                 startup_config=dict(),
                 *opts,
                 **kwargs):
        """
        Each router must therefore define the following values:

        32 bit router ID
        32 bit area ID
        16 bit lsuint    - interval in seconds between link state update broadcasts
        List of router interfaces
        """
        self.router_id = str(router_id)
        self.area_id = str(area_id)
        self.lsunit = lsunit
        self.data_ports = dict()
        self.static_routes = dict()
        self.pwospf_table = dict()
        self.pending_pwospf_table = dict()
        self.commands = dict()

        self.controller = None

        prog = kwargs.get('prog')
        if prog is None:
            raise Exception('Must specify p4 program')
        prog = P4Program(prog)

        if prog.version == 14:
            sw_path = 'simple_switch'
            enable_grpc = False
        elif prog.version == 16:
            sw_path = 'simple_switch_grpc'
            enable_grpc = True
        else:
            raise Exception('Switch does not support P4 version %s' %
                            prog.version)

        self.ctrl_args = dict()
        if 'ctrl_args' in kwargs:
            self.ctrl_args = kwargs['ctrl_args']
            del kwargs['ctrl_args']
        self.ctrl_port = self.ctrl_args.get('ctrl_port', 1)

        self.startup_config = startup_config

        kwargs.update({
            'enable_grpc': enable_grpc,
            'cli_path': 'simple_switch_CLI',
            'sw_path': sw_path,
            'program': prog,
            'start_controller': True,
        })

        P4RuntimeSwitch.__init__(self, name, *opts, **kwargs)
 def __init__(self, *opts, **kwargs):
     kwargs.update(switch_args)
     P4RuntimeSwitch.__init__(self, *opts, **kwargs)