예제 #1
0
파일: p4_mininet.py 프로젝트: p4lang/switch
    def __init__( self, name, target_name = 'p4dockerswitch',
                  thrift_port = None, target_dir = 'single_device',
                  sai_port = None,
                  swapi_port = None,
                  pcap_dump = False,
                  verbose = False,
                  start_program = '/p4factory/tools/start.sh',
                  config_fs = None,
                  pps = 0,
                  qdepth = 0,
                  **kwargs ):

        self.verbose = verbose
        self.pcap_dump = pcap_dump
        self.start_program = start_program
        self.config_fs = config_fs
        self.target_name = target_name
        self.target_dir = target_dir
        self.thrift_port = thrift_port
        self.sai_port = sai_port
        self.swapi_port = swapi_port
        self.pps = pps
        self.qdepth = qdepth
        Switch.__init__( self, name, **kwargs )
        self.inNamespace = True
예제 #2
0
 def __init__(self, name, thriftPort=None, deviceId=None, debugger=False,
              loglevel="warn", elogger=False, persistent=True, **kwargs):
     Switch.__init__(self, name, **kwargs)
     self.swPath = environ['BMV2_EXE']
     self.jsonPath = environ['BMV2_JSON']
     if thriftPort:
         self.thriftPort = thriftPort
     else:
         self.thriftPort = ONOSBmv2Switch.pickUnusedPort()
     if not deviceId:
         if self.dpid:
             self.deviceId = int(self.dpid, 0 if 'x' in self.dpid else 16)
         else:
             self.deviceId = ONOSBmv2Switch.deviceId
             ONOSBmv2Switch.deviceId += 1
     else:
         self.deviceId = deviceId
         ONOSBmv2Switch.deviceId = max(deviceId, ONOSBmv2Switch.deviceId)
     self.debugger = debugger
     self.loglevel = loglevel
     self.logfile = '/tmp/bmv2-%d.log' % self.deviceId
     self.output = open(self.logfile, 'w')
     self.elogger = elogger
     self.persistent = persistent
     if persistent:
         self.exectoken = "/tmp/bmv2-%d-exec-token" % self.deviceId
         self.cmd("touch %s" % self.exectoken)
     # Store thrift port for future uses.
     self.cmd("echo %d > /tmp/bmv2-%d-thrift-port" % (self.thriftPort, self.deviceId))
예제 #3
0
 def __init__(self, name, sw_path = None, json_path = None,
              thrift_port = None,
              pcap_dump = False,
              log_console = False,
              verbose = False,
              device_id = None,
              enable_debugger = False,
              **kwargs):
     Switch.__init__(self, name, **kwargs)
     assert(sw_path)
     assert(json_path)
     # make sure that the provided sw_path is valid
     pathCheck(sw_path)
     # make sure that the provided JSON file exists
     if not os.path.isfile(json_path):
         error("Invalid JSON file.\n")
         exit(1)
     self.sw_path = sw_path
     self.json_path = json_path
     self.verbose = verbose
     logfile = "/tmp/p4s.{}.log".format(self.name)
     self.output = open(logfile, 'w')
     self.thrift_port = thrift_port
     self.pcap_dump = pcap_dump
     self.enable_debugger = enable_debugger
     self.log_console = log_console
     if device_id is not None:
         self.device_id = device_id
         P4Switch.device_id = max(P4Switch.device_id, device_id)
     else:
         self.device_id = P4Switch.device_id
         P4Switch.device_id += 1
     self.nanomsg = "ipc:///tmp/bm-{}-log.ipc".format(self.device_id)
예제 #4
0
 def __init__( self, name, dpid=None, allowed=True,
               switchType='ROADM', annotations={}, **params ):
     params[ 'inNamespace' ] = False
     Switch.__init__( self, name, dpid=dpid, **params )
     self.name = name
     self.annotations = annotations
     self.allowed = allowed
     self.switchType = switchType
     self.configDict = {} # dictionary that holds all of the JSON configuration data
 def __init__( self, name, bw=100000000, **kwargs ): #100mbps
     """Init.
        name: name for the switch
        bw: interface maximum bandwidth"""
     
     Switch.__init__( self, name, **kwargs )
     self.bandwidth = bw
     pathCheck( 'ofdatapath', 'ofprotocol', moduleName='QoSFlow 0.1 datapath')
     if self.listenPort: # dpctl
         self.opts += ' --listen=ptcp:%i ' % self.listenPort
예제 #6
0
파일: nodelib.py 프로젝트: GregsHub/mininet
 def __init__( self, name, stp=False, prio=None, **kwargs ):
     """stp: use spanning tree protocol? (default False)
        prio: optional explicit bridge priority for STP"""
     self.stp = stp
     if prio:
         self.prio = prio
     else:
         self.prio = LinuxBridge.nextPrio
         LinuxBridge.nextPrio += 1
     Switch.__init__( self, name, **kwargs )
예제 #7
0
 def __init__( self, name, sw_path = "dc_full",
               thrift_port = None,
               pcap_dump = False,
               verbose = False, **kwargs ):
     Switch.__init__( self, name, **kwargs )
     self.sw_path = sw_path
     self.verbose = verbose
     logfile = '/tmp/p4ns.%s.log' % self.name
     self.output = open(logfile, 'w')
     self.thrift_port = thrift_port
     self.pcap_dump = pcap_dump
예제 #8
0
파일: routed.py 프로젝트: jvimal/eyeq-tests
    def __init__(self, name, **kwargs):
        kwargs['inNamespace'] = True
        Switch.__init__(self, name, **kwargs)
        print "Switch %s %s" % (name, self.inNamespace)
        Routed.ID += 1
        self.switch_id = Routed.ID
        self.kind = kwargs.get('kind')

        self.num_leafs = kwargs.get('num_leafs')
        self.num_spines = kwargs.get('num_spines')
        self.hosts_per_leaf = kwargs.get('hosts_per_leaf')
예제 #9
0
파일: optical.py 프로젝트: vmehmeri/sfc-lab
    def __init__(self, name, dpid=None, config_path=None,
                 controller=None, **params):
        """Initialize this LINC-Switch.

        Most of the parameters will be passed on to the standard Mininet Link
        constructor, except for the LINC-specific attributes, such as config
        filepath.
        """
        params['inNamespace'] = False
        Switch.__init__(self, name, dpid=dpid, **params)
        self.config_path = LINC_CONFIG if config_path is None else config_path
        self.controller = controller
예제 #10
0
 def __init__( self, name, configPath=None, dp=None, **kwargs ):
     """Init.
        name: name for switch
        dp: netlink id (0, 1, 2, ...)
        defaultMAC: default MAC as unsigned int; random value if None"""
     Switch.__init__( self, name, **kwargs )
     self.dp = 'dp%i' % dp
     self.intf = self.dp
     # Create a copy of the config for renaming
     if not configPath:
         configPath = os.path.join(os.getcwd(), "test.click")
     self.configPath = configPath + ".intf"
     shutil.copy(configPath, self.configPath)
예제 #11
0
 def __init__( self, name, sw_path = None, json_path = None,
               thrift_port = None,
               pcap_dump = False,
               verbose = False, **kwargs ):
     Switch.__init__( self, name, **kwargs )
     assert(sw_path)
     assert(json_path)
     self.sw_path = sw_path
     self.json_path = json_path
     self.verbose = verbose
     logfile = '/tmp/bfns.%s.log' % self.name
     self.output = open(logfile, 'w')
     self.thrift_port = thrift_port
     self.pcap_dump = pcap_dump
예제 #12
0
 def __init__(self, name, dpid=None, allowed=True,
               switchType='ROADM', topo=None, annotations={}, controller=None, **params):
     params[ 'inNamespace' ] = False
     Switch.__init__(self, name, dpid=dpid, **params)
     self.name = name
     self.annotations = annotations
     self.allowed = allowed
     self.switchType = switchType
     self.configDict = {}  # dictionary that holds all of the JSON configuration data
     self.crossConnects = []
     self.deletedCrossConnects = []
     self.controller = controller
     self.lincId = self._get_linc_id()  # use to communicate with LINC
     self.lincStarted = False
예제 #13
0
파일: node.py 프로젝트: NetASM/PyDatapath
    def __init__(self, name, **kwargs):
        """

        :param name:
        :param kwargs:
        :return:
        """

        Switch.__init__(self, name, **kwargs)

        # Check if 'pydatapath' is running.
        try:
            output = subprocess.check_output('netstat -lnp | grep ' + str(ProgSwitch.CTL_PORT), shell=True).strip()
        except:
            error(
                "*** error: 'pydatapath' is not running at " + ProgSwitch.CTL_ADDRESS + "::" + str(ProgSwitch.CTL_PORT) + "\n")
            exit(1)
예제 #14
0
    def __init__( self, name, target_name = 'p4dockerswitch',
                  thrift_port = None,
                  sai_port = None,
                  pcap_dump = False,
                  verbose = False,
                  start_program = '/p4factory/tools/start.sh',
                  config_fs = None,
                  **kwargs ):

        self.verbose = verbose
        self.pcap_dump = pcap_dump
        self.start_program = start_program
        self.config_fs = config_fs
        self.target_name = target_name
        self.thrift_port = thrift_port
        self.sai_port = sai_port
        Switch.__init__( self, name, **kwargs )
        self.inNamespace = True
예제 #15
0
    def __init__( self, name, config_path = None,
		 # json_path = None,
                 # thrift_port = None,
                 # pcap_dump = False,
                 # verbose = False,
                  device_id = None,
                  **kwargs ):
        Switch.__init__( self, name, **kwargs )
	#self.parseConfig( config_path )
        logfile = '/tmp/p4s.%s.log' % self.name
        self.output = open(logfile, 'w')
        if device_id is not None:
            self.device_id = device_id
            P4Switch.device_id = max(P4Switch.device_id, device_id)
        else:
            self.device_id = P4Switch.device_id
            P4Switch.device_id += 1
        self.nanomsg = "ipc:///tmp/bm-%d-log.ipc" % self.device_id
예제 #16
0
 def __init__(self,
              name,
              sw_path=None,
              json_path=None,
              log_file=None,
              thrift_port=None,
              pcap_dump=False,
              log_console=False,
              verbose=False,
              device_id=None,
              enable_debugger=False,
              **kwargs):
     Switch.__init__(self, name, **kwargs)
     assert (sw_path)
     assert (json_path)
     # make sure that the provided sw_path is valid
     pathCheck(sw_path)
     # make sure that the provided JSON file exists
     if not os.path.isfile(json_path):
         error("Invalid JSON file.\n")
         exit(1)
     self.sw_path = sw_path
     self.json_path = json_path
     self.verbose = verbose
     self.log_file = log_file
     if self.log_file is None:
         self.log_file = "/tmp/p4s.{}.log".format(self.name)
     self.output = open(self.log_file, 'w')
     self.thrift_port = thrift_port
     self.pcap_dump = pcap_dump
     self.enable_debugger = enable_debugger
     self.log_console = log_console
     if device_id is not None:
         self.device_id = device_id
         P4Switch.device_id = max(P4Switch.device_id, device_id)
     else:
         self.device_id = P4Switch.device_id
         P4Switch.device_id += 1
     self.nanomsg = "ipc:///tmp/bm-{}-log.ipc".format(self.device_id)
예제 #17
0
 def __init__(self,
              name,
              sw_path=None,
              pcap_dump=False,
              verbose=False,
              device_id=None,
              cpu_port=None,
              **kwargs):
     Switch.__init__(self, name, **kwargs)
     assert (sw_path)
     self.sw_path = sw_path
     self.verbose = verbose
     logfile = '/tmp/p4s.{}.log'.format(self.name)
     self.output = open(logfile, 'w')
     self.pcap_dump = pcap_dump
     self.cpu_port = cpu_port
     if device_id is not None:
         self.device_id = device_id
         P4Switch.device_id = max(P4Switch.device_id, device_id)
     else:
         self.device_id = P4Switch.device_id
         P4Switch.device_id += 1
예제 #18
0
 def __init__(self,
              name,
              dpid=None,
              allowed=True,
              switchType='ROADM',
              topo=None,
              annotations={},
              controller=None,
              **params):
     params['inNamespace'] = False
     Switch.__init__(self, name, dpid=dpid, **params)
     self.name = name
     self.annotations = annotations
     self.allowed = allowed
     self.switchType = switchType
     self.configDict = {
     }  # dictionary that holds all of the JSON configuration data
     self.crossConnects = []
     self.deletedCrossConnects = []
     self.controller = controller
     self.lincId = self._get_linc_id()  # use to communicate with LINC
     self.lincStarted = False
예제 #19
0
    def __init__(self, name, json=None, debugger=False, loglevel="warn",
                 elogger=False, grpcport=None, cpuport=255, notifications=False,
                 thriftport=None, netcfg=True, dryrun=False, pipeconf="",
                 pktdump=False, valgrind=False, gnmi=False,
                 portcfg=True, onosdevid=None, **kwargs):
        Switch.__init__(self, name, **kwargs)
        self.grpcPort = grpcport
        self.thriftPort = thriftport
        self.cpuPort = cpuport
        self.json = json
        self.debugger = parseBoolean(debugger)
        self.notifications = parseBoolean(notifications)
        self.loglevel = loglevel
        # Important: Mininet removes all /tmp/*.log files in case of exceptions.
        # We want to be able to see the bmv2 log if anything goes wrong, hence
        # avoid the .log extension.
        self.logfile = '/tmp/bmv2-%s-log' % self.name
        self.elogger = parseBoolean(elogger)
        self.pktdump = parseBoolean(pktdump)
        self.netcfg = parseBoolean(netcfg)
        self.dryrun = parseBoolean(dryrun)
        self.valgrind = parseBoolean(valgrind)
        self.netcfgfile = '/tmp/bmv2-%s-netcfg.json' % self.name
        self.pipeconfId = pipeconf
        self.injectPorts = parseBoolean(portcfg)
        self.withGnmi = parseBoolean(gnmi)
        self.longitude = kwargs['longitude'] if 'longitude' in kwargs else None
        self.latitude = kwargs['latitude'] if 'latitude' in kwargs else None
        if onosdevid is not None and len(onosdevid) > 0:
            self.onosDeviceId = onosdevid
        else:
            self.onosDeviceId = "device:bmv2:%s" % self.name
        self.logfd = None
        self.bmv2popen = None
        self.stopped = False

        # Remove files from previous executions
        self.cleanupTmpFiles()
예제 #20
0
    def __init__(self,
                 name,
                 switch_path='softswitch',
                 dpid=None,
                 controller=None,
                 address=None,
                 type='SW',
                 **kwargs):
        Switch.__init__(self, name, **kwargs)

        self.switch_path = switch_path
        # print 'This is the path ' + self.switch_path

        if dpid:
            self.dpid = dpid
            eBPFSwitch.dpid = max(eBPFSwitch.dpid, dpid)
        else:
            self.dpid = eBPFSwitch.dpid
            eBPFSwitch.dpid += 1

        self.type = type
        self.controller = controller
        self.address = address
예제 #21
0
파일: bmv2.py 프로젝트: xiaoxiang1/onos
 def __init__(self, name, json=None, debugger=False, loglevel="warn", elogger=False,
              persistent=False, grpcPort=None, thriftPort=None, netcfg=True, **kwargs):
     Switch.__init__(self, name, **kwargs)
     self.grpcPort = ONOSBmv2Switch.pickUnusedPort() if not grpcPort else grpcPort
     self.thriftPort = ONOSBmv2Switch.pickUnusedPort() if not thriftPort else thriftPort
     if self.dpid:
         self.deviceId = int(self.dpid, 0 if 'x' in self.dpid else 16)
     else:
         self.deviceId = ONOSBmv2Switch.deviceId
         ONOSBmv2Switch.deviceId += 1
     self.json = json
     self.debugger = debugger
     self.loglevel = loglevel
     self.logfile = '/tmp/bmv2-%d.log' % self.deviceId
     self.elogger = elogger
     self.persistent = persistent
     self.netcfg = netcfg
     self.netcfgfile = '/tmp/bmv2-%d-netcfg.json' % self.deviceId
     if persistent:
         self.exectoken = "/tmp/bmv2-%d-exec-token" % self.deviceId
         self.cmd("touch %s" % self.exectoken)
     # Store thrift port for future uses.
     self.cmd("echo %d > /tmp/bmv2-%d-grpc-port" % (self.grpcPort, self.deviceId))
 def __init__( self, name, sw_path = None, json_path = None,
               thrift_port = None,
               pcap_dump = False,
               verbose = False,
               device_id = None,
               **kwargs ):
     Switch.__init__( self, name, **kwargs )
     assert(sw_path)
     assert(json_path)
     self.sw_path = sw_path
     self.json_path = json_path
     self.verbose = verbose
     logfile = '/tmp/p4s.%s.log' % self.name
     self.output = open(logfile, 'w')
     self.thrift_port = thrift_port
     self.pcap_dump = pcap_dump
     if device_id is not None:
         self.device_id = device_id
         P4Switch.device_id = max(P4Switch.device_id, device_id)
     else:
         self.device_id = P4Switch.device_id
         P4Switch.device_id += 1
     self.nanomsg = "ipc:///tmp/bm-%d-log.ipc" % self.device_id
예제 #23
0
 def __init__( self, name, sw_path = None, json_path = None,
               thrift_port = None,
               pcap_dump = False,
               verbose = False,
               device_id = None,
               **kwargs ):
     Switch.__init__( self, name, **kwargs )
     assert(sw_path)
     assert(json_path)
     self.sw_path = sw_path
     self.json_path = json_path
     self.verbose = verbose
     logfile = '/tmp/p4s.%s.log' % self.name
     self.output = open(logfile, 'w')
     self.thrift_port = thrift_port
     self.pcap_dump = pcap_dump
     if device_id is not None:
         self.device_id = device_id
         P4Switch.device_id = max(P4Switch.device_id, device_id)
     else:
         self.device_id = P4Switch.device_id
         P4Switch.device_id += 1
     self.nanomsg = "ipc:///tmp/bm-%d-log.ipc" % self.device_id
예제 #24
0
    def __init__(self,
                 name,
                 json=STRATUM_INIT_PIPELINE,
                 loglevel="warn",
                 cpuport=DEFAULT_CPU_PORT,
                 pipeconf=DEFAULT_PIPECONF,
                 onosdevid=None,
                 **kwargs):
        Switch.__init__(self, name, **kwargs)
        self.grpcPort = StratumBmv2Switch.nextGrpcPort
        StratumBmv2Switch.nextGrpcPort += 1
        self.cpuPort = cpuport
        self.json = json
        self.loglevel = loglevel
        self.tmpDir = '/tmp/%s' % self.name
        self.logfile = '%s/stratum_bmv2.log' % self.tmpDir
        self.netcfgFile = '%s/onos-netcfg.json' % self.tmpDir
        self.chassisConfigFile = '%s/chassis-config.txt' % self.tmpDir
        self.pipeconfId = pipeconf
        self.longitude = kwargs['longitude'] if 'longitude' in kwargs else None
        self.latitude = kwargs['latitude'] if 'latitude' in kwargs else None
        if onosdevid is not None and len(onosdevid) > 0:
            self.onosDeviceId = onosdevid
        else:
            # The "device:" prefix is required by ONOS.
            self.onosDeviceId = "device:%s" % self.name
        self.nodeId = DEFAULT_NODE_ID
        self.logfd = None
        self.bmv2popen = None
        self.stopped = True
        # In case of exceptions, mininet removes *.out files from /tmp. We use
        # this as a signal to terminate the switch instance (if active).
        self.keepaliveFile = '/tmp/%s-watchdog.out' % self.name

        # Remove files from previous executions
        self.cleanupTmpFiles()
        os.mkdir(self.tmpDir)
예제 #25
0
파일: bmv2.py 프로젝트: LRH93/onos-p4-dev-1
 def __init__(self,
              name,
              thriftPort=None,
              deviceId=None,
              debugger=False,
              loglevel="warn",
              elogger=False,
              persistent=True,
              **kwargs):
     Switch.__init__(self, name, **kwargs)
     self.swPath = environ['BMV2_EXE']
     self.jsonPath = environ['BMV2_JSON']
     if thriftPort:
         self.thriftPort = thriftPort
     else:
         self.thriftPort = ONOSBmv2Switch.pickUnusedPort()
     if not deviceId:
         if self.dpid:
             self.deviceId = int(self.dpid, 0 if 'x' in self.dpid else 16)
         else:
             self.deviceId = ONOSBmv2Switch.deviceId
             ONOSBmv2Switch.deviceId += 1
     else:
         self.deviceId = deviceId
         ONOSBmv2Switch.deviceId = max(deviceId, ONOSBmv2Switch.deviceId)
     self.debugger = debugger
     self.loglevel = loglevel
     self.logfile = '/tmp/bmv2-%d.log' % self.deviceId
     self.output = open(self.logfile, 'w')
     self.elogger = elogger
     self.persistent = persistent
     if persistent:
         self.exectoken = "/tmp/bmv2-%d-exec-token" % self.deviceId
         self.cmd("touch %s" % self.exectoken)
     # Store thrift port for future uses.
     self.cmd("echo %d > /tmp/bmv2-%d-thrift-port" %
              (self.thriftPort, self.deviceId))
예제 #26
0
파일: bmv2.py 프로젝트: magiclamp2/onos
    def __init__(self, name, json=None, debugger=False, loglevel="warn",
                 elogger=False, grpcport=None, cpuport=255,
                 thriftport=None, netcfg=True, dryrun=False, pipeconf="",
                 pktdump=False, valgrind=False, gnmi=False,
                 portcfg=True, onosdevid=None, **kwargs):
        Switch.__init__(self, name, **kwargs)
        self.grpcPort = grpcport
        self.thriftPort = thriftport
        self.cpuPort = cpuport
        self.json = json
        self.debugger = parseBoolean(debugger)
        self.loglevel = loglevel
        # Important: Mininet removes all /tmp/*.log files in case of exceptions.
        # We want to be able to see the bmv2 log if anything goes wrong, hence
        # avoid the .log extension.
        self.logfile = '/tmp/bmv2-%s-log' % self.name
        self.elogger = parseBoolean(elogger)
        self.pktdump = parseBoolean(pktdump)
        self.netcfg = parseBoolean(netcfg)
        self.dryrun = parseBoolean(dryrun)
        self.valgrind = parseBoolean(valgrind)
        self.netcfgfile = '/tmp/bmv2-%s-netcfg.json' % self.name
        self.pipeconfId = pipeconf
        self.injectPorts = parseBoolean(portcfg)
        self.withGnmi = parseBoolean(gnmi)
        self.longitude = kwargs['longitude'] if 'longitude' in kwargs else None
        self.latitude = kwargs['latitude'] if 'latitude' in kwargs else None
        if onosdevid is not None and len(onosdevid) > 0:
            self.onosDeviceId = onosdevid
        else:
            self.onosDeviceId = "device:bmv2:%s" % self.name
        self.logfd = None
        self.bmv2popen = None
        self.stopped = False

        # Remove files from previous executions
        self.cleanupTmpFiles()
    def __init__( self, name, control_flag=False, control_type="",
                  address="127.0.0.1", port=6633, ports="", dpid=None,
                  max_retry_delay=16, extra="", listenPort=None, **params):
        """Init.
           name: name for switch
           control_flag: spawn personal controller?
           control_type: personal controller type
           address: IP address to listen to (and personal controller address)
           port: TCP port to listen to (and personal controller port)
           ports: network interfaces to connect
           dpid: dpid for switch (or None to derive from name, e.g. s1 -> 1)
           max_retry_delay: max time between retries to connect to controller
           extra: extra parameters
           listenPort: port to listen on for dpctl connections
           params: Node parameters (see config() for details)"""
        Switch.__init__(self, name, dpid, listenPort=listenPort, **params)

        self.print_personal_debug = False
        print "iiiiiiiiiiiiiiiiiiii"
        ps = "Args: "
        ps += "\n  name           \t"      + str(name)
        ps += "\n  control_flag   \t"      + str(control_flag)
        ps += "\n  control_type   \t"      + str(control_type)
        ps += "\n  address        \t"      + str(address)
        ps += "\n  port           \t"      + str(port)
        ps += "\n  ports          \t"      + str(ports)
        ps += "\n  dpid           \t"      + str(dpid)
        ps += "\n  max_retry_delay\t"      + str(max_retry_delay)
        ps += "\n  extra          \t"      + str(extra)
        ps += "\n  listenPort     \t"      + str(listenPort)
        ps += "\n  params         \t"      + str(params)
        if self.print_personal_debug: print ps

        if 'POX_CORE_DIR' not in os.environ:
            #exit( 'exiting; please set missing POX_CORE_DIR env var' )
            self.poxCoreDir = "/home/mininet/pox"
        else:
            self.poxCoreDir = os.environ[ 'POX_CORE_DIR' ]

        self.use_remote_controller = (not control_flag)
        self.controller_type = control_type
        self.controller_ip = address if address else "127.0.0.1"
        self.controller_port = int(port) if port else 6633
        self.input_intf_ports = ports.split(";") if ports else []
        self.max_retry_delay = max_retry_delay if max_retry_delay else 16
        self.extra = format_pox_extra(extra).split(";") if extra else []

        # NOTE: In case these are needed elsewhere...
        self.run_file = ""
        self.ctrl_args = ""
        self.cmd_args = ""
        self.cmd_log = ""
        self.cmd_tail = ""
        self.command = ""
        self.intf_ports = []
        self.pox_pid = None
        # @GLY
        self.lastPid = None
        self.started_switch = False

        ps = "Input to POXSwitch.__init__(): "
        ps += "\n  poxCoreDir      \t"      + str(self.poxCoreDir)
        ps += "\n  switch_name     \t"      + str(self.name)
        ps += "\n  use_remote_controller\t" + str(self.use_remote_controller)
        ps += "\n  controller_type \t"      + str(self.controller_type)
        ps += "\n  controller_ip   \t"      + str(self.controller_ip)
        ps += "\n  controller_port \t"      + str(self.controller_port)
        ps += "\n  input_intf_ports\t"      + str(self.input_intf_ports)
        ps += "\n  switch_dpid     \t"      + str(self.dpid)
        ps += "\n  max_retry_delay \t"      + str(self.max_retry_delay)
        ps += "\n  extra_parameters\t"      + str(self.extra)
        ps += "\n  listenPort      \t"      + str(self.listenPort)
        if self.print_personal_debug: print ps
예제 #28
0
    def __init__(self,
                 name,
                 sw_path=None,
                 json_path=None,
                 grpc_port=None,
                 thrift_port=None,
                 pcap_dump=False,
                 log_console=False,
                 verbose=False,
                 device_id=None,
                 enable_debugger=False,
                 log_file=None,
                 **kwargs):
        Switch.__init__(self, name, **kwargs)
        assert (sw_path)
        self.sw_path = sw_path
        # make sure that the provided sw_path is valid
        pathCheck(sw_path)

        if json_path is not None:
            # make sure that the provided JSON file exists
            if not os.path.isfile(json_path):
                error("Invalid JSON file.\n")
                exit(1)
            self.json_path = json_path
        else:
            self.json_path = None

        if grpc_port is not None:
            self.grpc_port = grpc_port
        else:
            self.grpc_port = P4RuntimeSwitch.next_grpc_port
            P4RuntimeSwitch.next_grpc_port += 1

        if thrift_port is not None:
            self.thrift_port = thrift_port
        else:
            self.thrift_port = P4RuntimeSwitch.next_thrift_port
            P4RuntimeSwitch.next_thrift_port += 1

        if check_listening_on_port(self.grpc_port):
            error(
                '%s cannot bind port %d because it is bound by another process\n'
                % (self.name, self.grpc_port))
            exit(1)

        self.verbose = verbose
        self.pcap_dump = pcap_dump
        self.enable_debugger = enable_debugger
        self.log_console = log_console
        if log_file is not None:
            self.log_file = log_file
        else:
            self.log_file = "/tmp/p4s.{}.log".format(self.name)
        self.output = open(self.log_file, 'w')

        if device_id is not None:
            self.device_id = device_id
            P4Switch.device_id = max(P4Switch.device_id, device_id)
        else:
            self.device_id = P4Switch.device_id
            P4Switch.device_id += 1

        self.nanomsg = "ipc:///tmp/bm-{}-log.ipc".format(self.device_id)
예제 #29
0
 def __init__(self, name, **kwargs):
     kwargs['inNamespace'] = True
     Switch.__init__(self, name, **kwargs)
     Router.ID += 1
     self.switch_id = Router.ID
예제 #30
0
    def __init__(self,
                 name,
                 json=None,
                 debugger=False,
                 loglevel="info",
                 elogger=False,
                 grpcport=None,
                 cpuport=255,
                 notifications=False,
                 thriftport=None,
                 netcfg=False,
                 dryrun=False,
                 inNamespace=False,
                 inband=False,
                 pipeconf=DEFAULT_PIPECONF,
                 pktdump=False,
                 valgrind=False,
                 gnmi=False,
                 portcfg=True,
                 onosdevid=None,
                 stratum=False,
                 switch_config=None,
                 timeout=SWITCH_START_TIMEOUT,
                 **kwargs):
        Switch.__init__(self, name, inNamespace=inNamespace, **kwargs)
        self.grpcPort = grpcport
        self.grpcPortInternal = None  # Needed for Stratum (local_hercules_url)
        self.thriftPort = thriftport
        self.cpuPort = cpuport
        self.inNamespace = inNamespace
        self.inband = inband
        self.useStratum = parseBoolean(stratum)
        self.debugger = parseBoolean(debugger)
        self.notifications = parseBoolean(notifications)
        self.loglevel = loglevel
        # Important: Mininet removes all /tmp/*.log files in case of exceptions.
        # We want to be able to see the bmv2 log if anything goes wrong, hence
        # avoid the .log extension.
        self.logfile = '/tmp/bmv2-%s-log' % self.name
        self.elogger = parseBoolean(elogger)
        self.pktdump = parseBoolean(pktdump)
        self.netcfg = parseBoolean(netcfg)
        self.dryrun = parseBoolean(dryrun)
        self.valgrind = parseBoolean(valgrind)
        self.netcfgfile = '/tmp/bmv2-%s-netcfg.json' % self.name
        self.chassisConfigFile = '/tmp/bmv2-%s-chassis-config.txt' % self.name
        self.pipeconfId = pipeconf
        self.injectPorts = parseBoolean(portcfg)
        self.withGnmi = parseBoolean(gnmi)
        self.longitude = kwargs['longitude'] if 'longitude' in kwargs else None
        self.latitude = kwargs['latitude'] if 'latitude' in kwargs else None
        if onosdevid is not None and len(onosdevid) > 0:
            self.onosDeviceId = onosdevid
        else:
            self.onosDeviceId = "device:bmv2:%s" % self.name
        nums = re.findall(r'\d+', name)
        self.p4DeviceId = int(nums[0])
        self.logfd = None
        self.bmv2popen = None
        self.stopped = True
        self.sip = None
        # In case of exceptions, mininet removes *.out files from /tmp. We use
        # this as a signal to terminate the switch instance (if active).
        self.keepaliveFile = '/tmp/bmv2-%s-watchdog.out' % self.name
        self.targetName = STRATUM_BMV2 if self.useStratum else SIMPLE_SWITCH_GRPC
        self.controllers = None
        self.switch_config = switch_config
        self.timeout = timeout

        path = os.path.dirname(
            os.path.abspath(__file__)) + '/examples/p4/ap-runtime.json'
        self.json = path if not json else json

        # Remove files from previous executions
        self.cleanupTmpFiles()
예제 #31
0
 def __init__(self, name, config_file, log_file='/dev/null', **params):
     Switch.__init__(self, name, **params)
     self.config_file = config_file
     self.log_file = log_file
예제 #32
0
 def __init__(self, name, blocking=False, **params):
     Switch.__init__(self, name, **params)
     self.block = blocking
예제 #33
0
    def __init__(self,
                 name,
                 sw_path=None,
                 json_path=None,
                 grpc_port=None,
                 thrift_port=None,
                 pcap_dump=False,
                 log_console=False,
                 verbose=False,
                 device_id=None,
                 enable_debugger=False,
                 log_dir=None,
                 log_file=None,
                 log_level=None,
                 log_flush=True,
                 cpu_port=None,
                 **kwargs):
        Switch.__init__(self, name, **kwargs)
        assert (sw_path)
        self.sw_path = sw_path
        # make sure that the provided sw_path is valid
        pathCheck(sw_path)

        #do not upload any json:
        self.json_path = None
        self.log_level = log_level
        self.log_flush = log_flush

        if grpc_port is not None:
            self.grpc_port = grpc_port
        else:

            self.grpc_port = P4RuntimeSwitch.next_grpc_port
            P4RuntimeSwitch.next_grpc_port += 1

        if thrift_port is not None:
            self.thrift_port = thrift_port
        else:
            self.thrift_port = P4RuntimeSwitch.next_thrift_port
            P4RuntimeSwitch.next_thrift_port += 1

        if cpu_port is not None:
            self.cpu_port = cpu_port
        else:
            self.cpu_port = P4RuntimeSwitch.next_cpu_port

        if check_listening_on_port(self.grpc_port):
            error(
                '%s cannot bind port %d because it is bound by another process\n'
                % (self.name, self.grpc_port))
            exit(1)

        self.verbose = verbose

        #logfile = "/tmp/p4s.{}.log".format(self.name)
        #self.output = open(logfile, 'w')

        self.enable_debugger = enable_debugger
        self.log_console = log_console
        if log_dir is not None:
            self.log_file = str(log_dir) + '/' + str(self.name)

        # if log_file is not None:
        #     self.log_file = log_file
        # else:
        #     self.log_file = "/tmp/p4s.{}.log".format(self.name)
        if device_id is not None:
            self.device_id = device_id
            P4Switch.device_id = max(P4Switch.device_id, device_id)
        else:
            self.device_id = P4Switch.device_id
            P4Switch.device_id += 1

        self.pcap_dump = pcap_dump
        self.nanomsg = "ipc:///tmp/bm-{}-log.ipc".format(self.device_id)
예제 #34
0
 def __init__(self, name, **kwargs):
     Switch.__init__(self, name, **kwargs)
     self.policy = ''
 def __init__( self, name, dataPathOptions='--no-slicing', **kwargs ):
     Switch.__init__( self, name, **kwargs )
     self.packetQueue  = Queue()
     self.CustomSwitchLogger = self.get_logger("CustomSwitch")
예제 #36
0
 def __init__(self, name, **kwargs):
     kwargs['inNamespace'] = True
     Switch.__init__(self, name, **kwargs)
     Router.ID += 1
     self.switch_id = Router.ID
예제 #37
0
파일: network.py 프로젝트: PerseusW/Mininet
 def __init__(self, name, **kwargs):
     kwargs['inNamespace'] = True
     Switch.__init__(self, name, **kwargs)
예제 #38
0
    def __init__(self, name, sw_path = None, json_path = None,
                 grpc_port = None,
                 thrift_port = None,
                 pcap_dump = False,
                 log_console = False,
                 verbose = False,
                 device_id = None,
                 enable_debugger = False,
                 log_file = None,
                 **kwargs):
        Switch.__init__(self, name, **kwargs)
        assert (sw_path)
        self.sw_path = sw_path
        # make sure that the provided sw_path is valid
        pathCheck(sw_path)

        if json_path is not None:
            # make sure that the provided JSON file exists
            if not os.path.isfile(json_path):
                error("Invalid JSON file.\n")
                exit(1)
            self.json_path = json_path
        else:
            self.json_path = None

        if grpc_port is not None:
            self.grpc_port = grpc_port
        else:
            self.grpc_port = P4RuntimeSwitch.next_grpc_port
            P4RuntimeSwitch.next_grpc_port += 1

        if thrift_port is not None:
            self.thrift_port = thrift_port
        else:
            # Note(rachit): Assumes that the switch names are of the form 's\d+'
            # and that each name is distinct. The number is used to create the
            # thrift port.
            switch_regex = re.compile(r"^s(\d+)$")
            s_num = int(switch_regex.search(name).group(1))
            self.thrift_port = 9090 + s_num

        print "Binding", name, "to thrift port", self.thrift_port

        if check_listening_on_port(self.grpc_port):
            error('%s cannot bind port %d because it is bound by another process\n' % (self.name, self.grpc_port))
            exit(1)

        self.verbose = verbose
        logfile = "/tmp/p4s.{}.log".format(self.name)
        self.output = open(logfile, 'w')
        self.pcap_dump = pcap_dump
        self.enable_debugger = enable_debugger
        self.log_console = log_console
        if log_file is not None:
            self.log_file = log_file
        else:
            self.log_file = "/tmp/p4s.{}.log".format(self.name)
        if device_id is not None:
            self.device_id = device_id
            P4Switch.device_id = max(P4Switch.device_id, device_id)
        else:
            self.device_id = P4Switch.device_id
            P4Switch.device_id += 1
        self.nanomsg = "ipc:///tmp/bm-{}-log.ipc".format(self.device_id)
예제 #39
0
    def __init__(self,
                 name,
                 sw_path=None,
                 enable_grpc=True,
                 grpc_port=None,
                 thrift_port=None,
                 pcap_dump=False,
                 log_console=False,
                 start_controller=True,
                 program=None,
                 verbose=False,
                 device_id=None,
                 enable_debugger=False,
                 cli_path=None,
                 log_file=None,
                 **kwargs):
        Switch.__init__(self, name, **kwargs)
        assert (sw_path)
        self.sw_path = sw_path
        # make sure that the provided sw_path is valid
        pathCheck(sw_path)

        self.cli_path = cli_path
        self.program = program
        self.enable_grpc = enable_grpc
        json_path = None
        p4info_path = None
        if self.program:
            json_path = self.program.json()
            if self.program.p4info():
                p4info_path = self.program.p4info()

        if json_path is not None:
            # make sure that the provided JSON file exists
            if not os.path.isfile(json_path):
                error("Invalid JSON file.\n")
                exit(1)
            self.json_path = json_path
        else:
            self.json_path = None

        if p4info_path is not None:
            if not os.path.isfile(p4info_path):
                error("Invalid P4Info file.\n")
                exit(1)
            self.p4info_path = p4info_path
        else:
            self.p4info_path = None

        self.grpc_port = grpc_port
        if self.enable_grpc and grpc_port is None:
            self.grpc_port = P4RuntimeSwitch.next_grpc_port
            P4RuntimeSwitch.next_grpc_port += 1

        if thrift_port is not None:
            self.thrift_port = thrift_port
        else:
            self.thrift_port = P4RuntimeSwitch.next_thrift_port
            P4RuntimeSwitch.next_thrift_port += 1

        if enable_grpc and check_listening_on_port(self.grpc_port):
            error(
                '%s cannot bind port %d because it is bound by another process\n'
                % (self.name, self.grpc_port))
            exit(1)

        self.verbose = verbose
        logfile = "/tmp/p4app-logs/p4s.{}.log".format(self.name)
        self.output = open(logfile, 'w')
        self.pcap_dump = pcap_dump
        self.enable_debugger = enable_debugger
        self.log_console = log_console
        self.start_controller = start_controller
        if not self.program.supportsP4Runtime():
            self.start_controller = False
        self.sw_conn = None
        if log_file is not None:
            self.log_file = log_file
        else:
            self.log_file = logfile
        if device_id is not None:
            self.device_id = device_id
            P4Switch.device_id = max(P4Switch.device_id, device_id)
        else:
            self.device_id = P4Switch.device_id
            P4Switch.device_id += 1
        self.nanomsg = "ipc:///tmp/bm-{}-log.ipc".format(self.device_id)
예제 #40
0
 def __init__(self, name, **kwargs):
     Switch.__init__(self, name, **kwargs)
예제 #41
0
    def __init__(self,
                 name,
                 json=None,
                 debugger=False,
                 loglevel="warn",
                 elogger=False,
                 grpcport=None,
                 cpuport=255,
                 notifications=False,
                 thriftport=None,
                 netcfg=True,
                 dryrun=False,
                 pipeconf=DEFAULT_PIPECONF,
                 pktdump=False,
                 valgrind=False,
                 gnmi=False,
                 portcfg=True,
                 onosdevid=None,
                 stratum=False,
                 **kwargs):
        Switch.__init__(self, name, **kwargs)
        self.grpcPort = grpcport
        self.grpcPortInternal = None  # Needed for Stratum (local_hercules_url)
        self.thriftPort = thriftport
        self.cpuPort = cpuport
        self.json = json
        self.useStratum = parseBoolean(stratum)
        self.debugger = parseBoolean(debugger)
        self.notifications = parseBoolean(notifications)
        self.loglevel = loglevel
        # Important: Mininet removes all /tmp/*.log files in case of exceptions.
        # We want to be able to see the bmv2 log if anything goes wrong, hence
        # avoid the .log extension.
        self.logfile = '/tmp/bmv2-%s-log' % self.name
        self.elogger = parseBoolean(elogger)
        self.pktdump = parseBoolean(pktdump)
        self.netcfg = parseBoolean(netcfg)
        self.dryrun = parseBoolean(dryrun)
        self.valgrind = parseBoolean(valgrind)
        self.netcfgfile = '/tmp/bmv2-%s-netcfg.json' % self.name
        self.chassisConfigFile = '/tmp/bmv2-%s-chassis-config.txt' % self.name
        self.pipeconfId = pipeconf
        self.injectPorts = parseBoolean(portcfg)
        self.withGnmi = parseBoolean(gnmi)
        self.longitude = kwargs['longitude'] if 'longitude' in kwargs else None
        self.latitude = kwargs['latitude'] if 'latitude' in kwargs else None
        if onosdevid is not None and len(onosdevid) > 0:
            self.onosDeviceId = "device:bmv2:%s" % onosdevid
        else:
            self.onosDeviceId = "device:bmv2:%s" % self.name
        self.p4DeviceId = BMV2_DEFAULT_DEVICE_ID
        self.logfd = None
        self.bmv2popen = None
        self.stopped = True
        # In case of exceptions, mininet removes *.out files from /tmp. We use
        # this as a signal to terminate the switch instance (if active).
        self.keepaliveFile = '/tmp/bmv2-%s-watchdog.out' % self.name
        self.targetName = STRATUM_BMV2 if self.useStratum else SIMPLE_SWITCH_GRPC

        # Remove files from previous executions
        self.cleanupTmpFiles()
예제 #42
0
파일: bridge.py 프로젝트: jvimal/eyeq-tests
 def __init__(self, name, **kwargs):
     Switch.__init__(self, name, **kwargs)