本文整理汇总了Python中mininet.node.Switch.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Switch.__init__方法的具体用法?Python Switch.__init__怎么用?Python Switch.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.node.Switch
的用法示例。
在下文中一共展示了Switch.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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))
示例2: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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)
示例3: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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
示例4: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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
示例5: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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
示例15: __init__
# 需要导入模块: from mininet.node import Switch [as 别名]
# 或者: from mininet.node.Switch import __init__ [as 别名]
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()