本文整理汇总了Python中mininet.log.warn函数的典型用法代码示例。如果您正苦于以下问题:Python warn函数的具体用法?Python warn怎么用?Python warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warn函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: delete
def delete( self ):
"Delete interface"
if self.nsInstalled:
warn( "You can not delete once installed ns-3 device, "
"run mininet.ns3.clear() to delete all ns-3 devices\n" )
else:
Intf.delete( self )
开发者ID:rascov,项目名称:OpenNet,代码行数:7,代码来源:ns3.py
示例2: __init__
def __init__( self, name, n=1, reactive=True, runAsRoot=False, **params):
"""n: number of ONOS instances to run (1)
reactive: run in reactive mode (True)
runAsRoot: run ONOS as root (False)"""
self.check()
self.count = n
self.reactive = reactive
self.runAsRoot = runAsRoot
self.ids = range( 0, self.count )
Controller.__init__( self, name, **params )
self.proxies = []
# We don't need to run as root, and it can interfere
# with starting Zookeeper manually
self.user = None
if not self.runAsRoot:
try:
self.user = quietRun( 'who am i' ).split()[ 0 ]
self.sendCmd( 'su', self.user )
self.waiting = False
except:
warn( '__init__: failed to drop privileges\n' )
self.cmd( 'mkdir -p', self.logDir )
# Need to run commands from ONOS dir
self.cmd( 'cd', self.onosDir )
self.cmd( 'export PATH=$PATH:%s' % self.onosDir )
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:25,代码来源:onos.py
示例3: defaultIntf
def defaultIntf(self):
"Return interface for lowest port"
ports = self.intfs.keys()
if ports:
return self.intfs[min(ports)]
else:
warn("*** defaultIntf: warning:", self.name, "has no interfaces\n")
开发者ID:sjas,项目名称:mininet,代码行数:7,代码来源:node.py
示例4: validatePort
def validatePort( self, intf ):
"Validate intf's OF port number"
ofport = int( self.cmd( 'ovs-vsctl get Interface', intf,
'ofport' ) )
if ofport != self.ports[ intf ]:
warn( 'WARNING: ofport for', intf, 'is actually', ofport,
'\n' )
开发者ID:DeepnessLab,项目名称:moly,代码行数:7,代码来源:mobility.py
示例5: removeLink
def removeLink( self, node, intf_name ):
if self.debug_flag1:
args = (node, intf_name)
print "EXEC: removeLink(%s, %s):" % args
assert isinstance(node, Host) #Node)
assert intf_name in node.nameToIntf
dummy = self.nameToNode.get("dummy", None)
if dummy is None:
error('dummy node does not exist\n')
return
assert isinstance(dummy, Dummy)
# Special case: Node already connected to dummy.
intf = node.nameToIntf[intf_name]
assert intf.link != None
assert intf.link.intf1 == intf or intf.link.intf2 == intf
assert intf.node != dummy
if intf.link.intf1.node == dummy or intf.link.intf2.node == dummy:
warn('intf %s of %s already removed\n' % (intf_name, node.name))
return
unused = dummy.nameToUnusedPorts
if len(unused) == 0:
dummy_intf_port = dummy.newPort()
dummy_intf_name = 'dummy-eth' + str(dummy_intf_port)
unused[dummy_intf_name] = dummy_intf_port
else:
dummy_intf_name = min(unused, key=unused.get)
self.moveLink(node, dummy, intf_name, dummy_intf_name)
开发者ID:guoluyi,项目名称:Mininet,代码行数:31,代码来源:net.py
示例6: start
def start():
""" Start the simulator thread in background.
It should be called after configuration of all ns-3 objects
(TBintfs, Segments and Links).
Attempt of adding an ns-3 object when simulator thread is
running may result in segfault. You should stop it first."""
global thread
if 'thread' in globals() and thread.isAlive():
warn( "NS-3 simulator thread already running." )
return
# Install all TapBridge ns-3 devices not installed yet.
for intf in allTBIntfs:
if not intf.nsInstalled:
intf.nsInstall()
# Set up the simulator thread.
thread = threading.Thread( target = runthread )
thread.daemon = True
# Start the simulator thread (this is where fork happens).
# FORK!
thread.start()
# FORK:PARENT
# Code below is executed in the parent thread.
# Move all tap interfaces not moved yet to the right namespace.
for intf in allTBIntfs:
if not intf.inRightNamespace:
intf.namespaceMove()
return
开发者ID:EliseuTorres,项目名称:OpenNet,代码行数:27,代码来源:ns3.py
示例7: checkListening
def checkListening( self ):
"Warn if remote controller is not accessible"
listening = self.cmd( "echo A | telnet -e A %s %d" %
( self.ip, self.port ) )
if 'Unable' in listening:
warn( "Unable to contact the remote controller"
" at %s:%d\n" % ( self.ip, self.port ) )
开发者ID:RimHaw,项目名称:mn-ccnx,代码行数:7,代码来源:node.py
示例8: addAp
def addAp( self, node, channelNumber, ssid=None, enableQos=False, port=None, intfName=None, **attrs):
if ssid is None:
ssid = self.baseSsid + str(len (self.aps) + 1)
if channelNumber <= 0 or channelNumber > self.maxChannelNumber:
channelNumber = random.randint (1, self.maxChannelNumber)
warn("illegal channel number, choose a random channel number %s.\n", channelNumber)
phyHelper = ns.wifi.YansWifiPhyHelper().Default()
phyHelper.Set ("ChannelNumber", ns.core.UintegerValue(channelNumber))
if enableQos:
macHelper = ns.wifi.QosWifiMacHelper.Default()
else:
macHelper = ns.wifi.NqosWifiMacHelper.Default()
setAttributes (macHelper.SetType, "ns3::ApWifiMac", attrs)
tb = self.add (node, phyHelper, macHelper, port, intfName)
if type( ssid ) is str:
wifissid = ns.wifi.Ssid (ssid)
else:
wifissid = ssid
try:
tb.nsDevice.GetMac ().SetAttribute ("Ssid", ns.wifi.SsidValue (wifissid))
except:
warn("the type of wifissid isn't ssidvalue.\n")
wifissid = ns.wifi.Ssid (self.baseSsid + str(len (self.aps) + 1))
tb.nsDevice.GetMac ().SetAttribute ("Ssid", ns.wifi.SsidValue (wifissid))
self.aps.append(tb)
return tb
开发者ID:rascov,项目名称:OpenNet,代码行数:27,代码来源:ns3.py
示例9: setPosition
def setPosition( node, x, y, z ):
""" Set the ns-3 (x, y, z) position of a Mininet node.
Coordinates are in the 3D Cartesian system.
The unit is meters.
node: Mininet node
x: integer or float x coordinate
y: integer or float y coordinate
z: integer or float z coordinate"""
# Check if this Mininet node has assigned the underlying ns-3 node.
if hasattr( node, 'nsNode' ) and node.nsNode is not None:
# If it is assigned, go ahead.
pass
else:
# If not, create new ns-3 node and assign it to this Mininet node.
node.nsNode = ns.network.Node()
allNodes.append( node )
try:
mm = node.nsNode.GetObject( ns.mobility.MobilityModel.GetTypeId() )
if x is None:
x = 0.0
if y is None:
y = 0.0
if z is None:
z = 0.0
# Set postion coordinates in the ns-3 node
pos = mm.SetPosition( ns.core.Vector( x, y, z ) )
except AttributeError:
warn( "ns-3 mobility model not found, not setting position\n" )
开发者ID:EliseuTorres,项目名称:OpenNet,代码行数:28,代码来源:ns3.py
示例10: fixLimits
def fixLimits():
"Fix ridiculously small resource limits."
debug( "*** Setting resource limits\n" )
try:
rlimitTestAndSet( RLIMIT_NPROC, 8192 )
rlimitTestAndSet( RLIMIT_NOFILE, 16384 )
#Increase open file limit
sysctlTestAndSet( 'fs.file-max', 10000 )
#Increase network buffer space
sysctlTestAndSet( 'net.core.wmem_max', 16777216 )
sysctlTestAndSet( 'net.core.rmem_max', 16777216 )
sysctlTestAndSet( 'net.ipv4.tcp_rmem', '10240 87380 16777216' )
sysctlTestAndSet( 'net.ipv4.tcp_wmem', '10240 87380 16777216' )
sysctlTestAndSet( 'net.core.netdev_max_backlog', 5000 )
#Increase arp cache size
sysctlTestAndSet( 'net.ipv4.neigh.default.gc_thresh1', 4096 )
sysctlTestAndSet( 'net.ipv4.neigh.default.gc_thresh2', 8192 )
sysctlTestAndSet( 'net.ipv4.neigh.default.gc_thresh3', 16384 )
#Increase routing table size
sysctlTestAndSet( 'net.ipv4.route.max_size', 32768 )
#Increase number of PTYs for nodes
sysctlTestAndSet( 'kernel.pty.max', 20000 )
except:
warn( "*** Error setting resource limits. "
"Mininet's performance may be affected.\n" )
开发者ID:Mo-hammad,项目名称:mininet,代码行数:25,代码来源:util.py
示例11: addSta
def addSta( self, node, channelNumber, ssid=None, enableQos=False, enableScan = True, port=None, intfName=None, **attrs):
if ssid is None:
ssid = ""
if channelNumber <= 0 or channelNumber > self.maxChannelNumber:
channelNumber = random.randint (1, self.maxChannelNumber)
warn("illegal channel number, choose a random channel number %s.\n", channelNumber)
phyHelper = ns.wifi.YansWifiPhyHelper().Default()
phyHelper.Set ("ChannelNumber", ns.core.UintegerValue(channelNumber))
if enableQos:
macHelper = ns.wifi.QosWifiMacHelper.Default()
else:
macHelper = ns.wifi.NqosWifiMacHelper.Default()
setAttributes (macHelper.SetType, "ns3::StaWifiMac", attrs)
tb = self.add (node, phyHelper, macHelper, port, intfName)
if type( ssid ) is str:
wifissid = ns.wifi.Ssid (ssid)
else:
wifissid = ssid
try:
tb.nsDevice.GetMac ().SetAttribute ("Ssid", ns.wifi.SsidValue (wifissid))
except:
warn("the type of wifissid isn't ssidvalue.\n")
tb.nsDevice.GetMac ().SetAttribute ("Ssid", ns.wifi.SsidValue (""))
if enableScan:
tb.nsDevice.GetMac ().SetAttribute ("ScanType", ns.core.EnumValue (ns.wifi.StaWifiMac.ACTIVE))
tb.nsDevice.GetMac ().SetAttribute ("MaxScanningChannelNumber", ns.core.UintegerValue(self.maxChannelNumber))
else:
tb.nsDevice.GetMac ().SetAttribute ("ScanType", ns.core.EnumValue (ns.wifi.StaWifiMac.NOTSUPPORT))
self.stas.append(tb)
return tb
开发者ID:rascov,项目名称:OpenNet,代码行数:30,代码来源:ns3.py
示例12: waitConnected
def waitConnected(self, timeout=None, delay=0.5):
"""wait for each switch to connect to a controller,
up to 5 seconds
timeout: time to wait, or None to wait indefinitely
delay: seconds to sleep per iteration
returns: True if all switches are connected"""
info("*** Waiting for switches to connect\n")
time = 0
remaining = list(self.switches)
while True:
for switch in tuple(remaining):
if switch.connected():
info("%s " % switch)
remaining.remove(switch)
if not remaining:
info("\n")
return True
if time > timeout and timeout is not None:
break
sleep(delay)
time += delay
warn("Timed out after %d seconds\n" % time)
for switch in remaining:
if not switch.connected():
warn("Warning: %s is not connected to a controller\n" % switch.name)
else:
remaining.remove(switch)
return not remaining
开发者ID:ruifcardoso,项目名称:mininet,代码行数:28,代码来源:net.py
示例13: check_net_config
def check_net_config( self ):
"Check for any previous CMSnet configurations and adjust if necessary."
try:
with open(self.config_folder+"/cn.config_cmsnet", "r") as f:
config_raw = f.read()
config = {}
if config_raw:
config, l = defaultDecoder.raw_decode(config_raw)
for attr in config:
if attr.startswith("topo"): # Handle separately.
pass
elif attr == "net_cls":
cls = getattr(mininet.net, config[attr])
setattr(self, attr, cls)
elif attr.endswith("cls"):
cls = getattr(cmsnet.cms_comp, config[attr])
setattr(self, attr, cls)
elif isinstance(config[attr], basestring):
setattr(self, attr, str(config[attr]))
else:
setattr(self, attr, config[attr])
topo_cls_name = config.get("topo_cls")
if topo_cls_name:
topo_cls = getattr(cmsnet.cms_topo, topo_cls_name)
topo_opts = config.get("topo_opts", {})
topo = topo_cls(**topo_opts)
self.params.update({'topo': topo})
else:
warn("\nNo topology exists for CMSnet\n")
f.close()
except IOError as e:
info("\nNo config exists for CMSnet\n")
开发者ID:eternia478,项目名称:mininetcetera_public,代码行数:32,代码来源:cms_net.py
示例14: _run_pox_switch
def _run_pox_switch( self ):
if self.pox_pid is not None:
warn( "Killing old pox switch to restart new one." )
self._kill_pox_switch()
self._build_cmd_args()
self.cmd( self.command, printPid=True )
self.pox_pid = self.lastPid
print "MY POX PIDDDDDDDDDD: "+str(self.pox_pid)
self.started_switch = True
return
"Run the POX switch"
# @GLY
print "running !"
if self.pox_pid is not None:
print "poxid is not none"
warn( "Killing old pox switch to restart new one." )
self.lastPid = self.pox_pid
self._kill_pox_switch()
self.pox_pid = self.lastPid
else:
self.pox_pid = 1
print "yyyyyyyyyyyyyyyy"
self._build_cmd_args()
self.cmd( self.command, printPid=True )
self.started_switch = True
开发者ID:eternia478,项目名称:mininetcetera_public,代码行数:26,代码来源:mininet_node_patch.py
示例15: do_arp
def do_arp( self, line ):
"Send gratuitous arps from all data network hosts"
startTime = time.time()
try:
count = int( line )
except:
count = 1
# Technically this check should be on the host
if '-U' not in quietRun( 'arping -h', shell=True ):
warn( 'Please install iputils-arping.\n' )
return
# This is much faster if we do it in parallel
for host in self.mn.net.hosts:
intf = host.defaultIntf()
# -b: keep using broadcasts; -f: quit after 1 reply
# -U: gratuitous ARP update
host.sendCmd( 'arping -bf -c', count, '-U -I',
intf.name, intf.IP() )
for host in self.mn.net.hosts:
# We could check the output here if desired
host.waitOutput()
info( '.' )
info( '\n' )
elapsed = time.time() - startTime
debug( 'Completed in %.2f seconds\n' % elapsed )
开发者ID:Shashikanth-Huawei,项目名称:bmp,代码行数:25,代码来源:onos.py
示例16: start
def start( self, controllers ):
"Start up a new POX OpenFlow switch"
if self.poxCoreDir is not None:
self.cmd( 'cd ' + self.poxCoreDir )
# We should probably call config instead, but this
# requires some rethinking...
self.cmd( 'ifconfig lo up' )
# Annoyingly, --if-exists option seems not to work
for intf in self.intfList(): #nameToIntf #self.intfNames
if not intf.IP():
self.attach( intf )
# Add controllers.
# NOTE: This case is currently impossible and inaccessible.
if not self.controller_ip or not self.controller_port:
warn( 'warning: bad input controller ip and port' )
if len(controllers) == 1:
c = controllers[0]
self.controller_ip = c.IP()
self.controller_port = c.port
else:
raise Exception('Cannot find unique controller to connect to')
self._run_pox_switch()
开发者ID:eternia478,项目名称:mininetcetera_public,代码行数:26,代码来源:mininet_node_patch.py
示例17: getGatewayIntf
def getGatewayIntf( self ):
routes = self.cmd( 'ip route show' )
match = re.search('default via \S+ dev (\S+)', routes )
if match:
return match.group( 1 )
else:
warn( 'There is no default route set. Using eth0 as gateway interface...\n' )
return 'eth0'
开发者ID:Willoczy,项目名称:mininet,代码行数:8,代码来源:nodelib.py
示例18: validatePort
def validatePort(switch, intf):
"Validate intf's OF port number"
ofport = int(switch.cmd("ovs-vsctl get Interface", intf, "ofport"))
if ofport != switch.ports[intf]:
warn("WARNING: ofport for", intf, "is actually", ofport, "\n")
return 0
else:
return 1
开发者ID:XianliangJ,项目名称:Mininet-WiFi,代码行数:8,代码来源:numberedports.py
示例19: isListening
def isListening( self, ip, port ):
"Check if a remote controller is listening at a specific ip and port"
listening = self.cmd( "echo A | telnet -e A %s %d" % ( ip, port ) )
if 'Connected' not in listening:
warn( "Unable to contact the remote controller"
" at %s:%d\n" % ( ip, port ) )
return False
else:
return True
开发者ID:chesteve,项目名称:mn-ccnx,代码行数:9,代码来源:node.py
示例20: customized
def customized(name, *args, **params):
"Customized constructor, useful for Node, Link, and other classes"
params = params.copy()
params.update(kwargs)
if not newargs:
return constructor(name, *args, **params)
if args:
warn("warning: %s replacing %s with %s\n" % (constructor, args, newargs))
return constructor(name, *newargs, **params)
开发者ID:adferguson,项目名称:mininet,代码行数:9,代码来源:util.py
注:本文中的mininet.log.warn函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论