本文整理汇总了Python中mininet.node.Switch类的典型用法代码示例。如果您正苦于以下问题:Python Switch类的具体用法?Python Switch怎么用?Python Switch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Switch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:
示例16: __init__
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
开发者ID:CS236340,项目名称:Early-DDoS-Detection-on-Stateless-Device,代码行数:23,代码来源:p4_mininet.py
示例17: __init__
def __init__(self, name, blocking=False, **params):
Switch.__init__(self, name, **params)
self.block = blocking
开发者ID:OysterKing,项目名称:Final-Year-Project,代码行数:3,代码来源:bridge_switch.py
示例18: __init__
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
开发者ID:eternia478,项目名称:mininetcetera_public,代码行数:73,代码来源:mininet_node_patch.py
示例19: __init__
def __init__(self, name, **kwargs):
kwargs['inNamespace'] = True
Switch.__init__(self, name, **kwargs)
Router.ID += 1
self.switch_id = Router.ID
开发者ID:edwinsc,项目名称:mininet_ospf_bgp,代码行数:5,代码来源:start.py
示例20: __init__
def __init__(self, name, **kwargs):
Switch.__init__(self, name, **kwargs)
self.policy = ''
开发者ID:NetASM,项目名称:NetASM-python,代码行数:3,代码来源:node.py
注:本文中的mininet.node.Switch类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论