当前位置: 首页>>代码示例>>Python>>正文


Python node.Switch类代码示例

本文整理汇总了Python中mininet.node.Switch的典型用法代码示例。如果您正苦于以下问题:Python Switch类的具体用法?Python Switch怎么用?Python Switch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Switch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 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))
开发者ID:Shashikanth-Huawei,项目名称:bmp,代码行数:29,代码来源:bmv2.py

示例2: __init__

 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)
开发者ID:wysamuel,项目名称:behavioral-model,代码行数:33,代码来源:p4_mininet.py

示例3: __init__

    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
开发者ID:p4lang,项目名称:switch,代码行数:25,代码来源:p4_mininet.py

示例4: __init__

 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
开发者ID:Ehsan70,项目名称:Mininet_LINC_script,代码行数:9,代码来源:opticalUtils.py

示例5: __init__

 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
开发者ID:josecastillolema,项目名称:smart-OF-controller,代码行数:10,代码来源:qosflownet.py

示例6: __init__

 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 )
开发者ID:GregsHub,项目名称:mininet,代码行数:10,代码来源:nodelib.py

示例7: __init__

 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
开发者ID:unixcore,项目名称:p4factory,代码行数:11,代码来源:p4_mininet.py

示例8: __init__

    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')
开发者ID:jvimal,项目名称:eyeq-tests,代码行数:11,代码来源:routed.py

示例9: __init__

    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
开发者ID:vmehmeri,项目名称:sfc-lab,代码行数:12,代码来源:optical.py

示例10: __init__

 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)
开发者ID:basus,项目名称:click-mininet,代码行数:13,代码来源:click.py

示例11: __init__

 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
开发者ID:hanw,项目名称:behavioral-model,代码行数:14,代码来源:bfn_mininet.py

示例12: __init__

 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
开发者ID:java66liu,项目名称:onos,代码行数:14,代码来源:opticalUtils.py

示例13: __init__

    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)
开发者ID:NetASM,项目名称:PyDatapath,代码行数:17,代码来源:node.py

示例14: __init__

    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
开发者ID:signorello,项目名称:NDN.p4,代码行数:18,代码来源:p4_mininet.py

示例15: __init__

    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()
开发者ID:,项目名称:,代码行数:38,代码来源:


注:本文中的mininet.node.Switch类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。