本文整理汇总了Python中mininet.util.netParse函数的典型用法代码示例。如果您正苦于以下问题:Python netParse函数的具体用法?Python netParse怎么用?Python netParse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了netParse函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: build
def build( self ):
print "Build network based on our topology."
net = Mininet( topo=None, build=False, link=TCLink, ipBase=self.minieditIpBase )
net.controllers = self.addControllers()
# Make nodes
print "Getting Hosts and Switches."
for widget in self.widgetToItem:
name = widget[ 'text' ]
tags = self.canvas.gettags( self.widgetToItem[ widget ] )
nodeNum = int( name[ 1: ] )
if 'Switch' in tags:
net.addSwitch( name )
elif 'Host' in tags:
ipBaseNum, prefixLen = netParse( self.minieditIpBase )
ip = ipAdd(i=nodeNum, prefixLen=prefixLen, ipBaseNum=ipBaseNum)
net.addHost( name, ip=ip )
else:
raise Exception( "Cannot create mystery node: " + name )
# Make links
print "Getting Links."
for link in self.links.values():
( src, dst, linkopts ) = link
srcName, dstName = src[ 'text' ], dst[ 'text' ]
src, dst = net.nameToNode[ srcName ], net.nameToNode[ dstName ]
net.addLink(src, dst, **linkopts)
self.printInfo()
# Build network (we have to do this separately at the moment )
net.build()
return net
开发者ID:Phi-Ho,项目名称:pyretic,代码行数:35,代码来源:miniedit-2.0.0.3.1.py
示例2: __init__
def __init__( self, topo=None, switch=OVSKernelSwitch, host=Host,
controller=DefaultController, link=Link, intf=Intf,
build=True, xterms=False, cleanup=False, ipBase='10.0.0.0/8',
inNamespace=False,
autoSetMacs=False, autoStaticArp=False, autoPinCpus=False,
listenPort=None, waitConnected=False ):
"""Create Mininet object.
topo: Topo (topology) object or None
switch: default Switch class
host: default Host class/constructor
controller: default Controller class/constructor
link: default Link class/constructor
intf: default Intf class/constructor
ipBase: base IP address for hosts,
build: build now from topo?
xterms: if build now, spawn xterms?
cleanup: if build now, cleanup before creating?
inNamespace: spawn switches and controller in net namespaces?
autoSetMacs: set MAC addrs automatically like IP addresses?
autoStaticArp: set all-pairs static MAC addrs?
autoPinCpus: pin hosts to (real) cores (requires CPULimitedHost)?
listenPort: base listening port to open; will be incremented for
each additional switch in the net if inNamespace=False"""
self.topo = topo
self.switch = switch
self.host = host
self.controller = controller
self.link = link
self.intf = intf
self.ipBase = ipBase
self.ipBaseNum, self.prefixLen = netParse( self.ipBase )
hostIP = ( 0xffffffff >> self.prefixLen ) & self.ipBaseNum
# Start for address allocation
self.nextIP = hostIP if hostIP > 0 else 1
self.inNamespace = inNamespace
self.xterms = xterms
self.cleanup = cleanup
self.autoSetMacs = autoSetMacs
self.autoStaticArp = autoStaticArp
self.autoPinCpus = autoPinCpus
self.numCores = numCores()
self.nextCore = 0 # next core for pinning hosts to CPUs
self.listenPort = listenPort
self.waitConn = waitConnected
self.hosts = []
self.switches = []
self.controllers = []
self.links = []
self.nameToNode = {} # name to Node (Host/Switch) objects
self.terms = [] # list of spawned xterm processes
Mininet.init() # Initialize Mininet if necessary
self.built = False
if topo and build:
self.build()
开发者ID:cihatcetinkaya,项目名称:mininet,代码行数:59,代码来源:net.py
示例3: create
def create(self, topology):
super(ONOSHostSdnipCluster, self).create(topology)
cs1 = topology.addSwitch('cs1', cls=L2OVSSwitch)
dataIp, dataPrefixLen = netParse(self.dataSubnet)
for i in range(1, len(self.instances) + 1):
c = self.instances[i-1]
strDataIp = '%s/%i' % (ipStr(dataIp + i), dataPrefixLen)
topology.addLink(c, cs1, params1={ 'ip' : strDataIp })
return cs1
开发者ID:onfsdn,项目名称:atrium-docs,代码行数:12,代码来源:sdnip.py
示例4: printInfo
def printInfo( self ):
"print nodes and links."
for widget in self.widgetToItem:
name = widget[ 'text' ]
tags = self.canvas.gettags( self.widgetToItem[ widget ] )
x1, y1 = self.canvas.coords( self.widgetToItem[ widget ] )
nodeNum = int( name[ 1: ] )
if 'Switch' in tags:
print "Switch "+name+" at "+str(x1)+"/"+str(y1)+"."
elif 'Host' in tags:
ipBaseNum, prefixLen = netParse( self.minieditIpBase )
print 'ipBaseNum='+str(ipBaseNum)
print 'prefixLen='+str(prefixLen)
ip = ipAdd(i=nodeNum, prefixLen=prefixLen, ipBaseNum=ipBaseNum)
print "Host "+name+" with IP "+ip+" at "+str(x1)+"/"+str(y1)+"."
else:
raise Exception( "Cannot create mystery node: " + name )
for link in self.links.values():
( src, dst, linkopts ) = link
srcName, dstName = src[ 'text' ], dst[ 'text' ]
print "Link from "+srcName+" to "+dstName+"."
开发者ID:Phi-Ho,项目名称:pyretic,代码行数:22,代码来源:miniedit-2.0.0.3.1.py
示例5: __init__
def __init__( self, topo=None, switch=OVSKernelSwitch,
legacySwitch=LegacySwitch, hostInterface=HostInterface,
legacyRouter=QuaggaRouter,
transitPortalRouter=TransitPortalRouter,
host=Host, controller=Controller, link=Link, intf=Intf,
build=True, xterms=False, cleanup=False, ipBase='10.0.0.0/8',
inNamespace=False,
autoSetMacs=False, autoStaticArp=False, autoPinCpus=False,
listenPort=None, bridgeNum=0, defaultHostInterfaceBind='eth0'):
"""Create Mininet object.
topo: Topo (topology) object or None
switch: default Switch class
host: default Host class/constructor
controller: default Controller class/constructor
link: default Link class/constructor
intf: default Intf class/constructor
ipBase: base IP address for hosts,
build: build now from topo?
xterms: if build now, spawn xterms?
cleanup: if build now, cleanup before creating?
inNamespace: spawn switches and controller in net namespaces?
autoSetMacs: set MAC addrs automatically like IP addresses?
autoStaticArp: set all-pairs static MAC addrs?
autoPinCpus: pin hosts to (real) cores (requires CPULimitedHost)?
listenPort: base listening port to open; will be incremented for
each additional switch in the net if inNamespace=False"""
self.topo = topo
self.switch = switch
self.legacySwitch = legacySwitch
self.hostInterface = hostInterface
self.legacyRouter = legacyRouter
self.transitPortalRouter = transitPortalRouter
self.host = host
self.controller = controller
self.link = link
self.intf = intf
self.ipBase = ipBase
self.ipBaseNum, self.prefixLen = netParse( self.ipBase )
self.nextIP = 1 # start for address allocation
self.inNamespace = inNamespace
self.xterms = xterms
self.cleanup = cleanup
self.autoSetMacs = autoSetMacs
self.autoStaticArp = autoStaticArp
self.autoPinCpus = autoPinCpus
self.numCores = numCores()
self.nextCore = 0 # next core for pinning hosts to CPUs
self.listenPort = listenPort
self.bridgeNum = bridgeNum
self.defaultHostInterfaceBind = defaultHostInterfaceBind
self.hosts = []
self.switches = []
self.legacySwitches = []
self.hostInterfaces = []
self.legacyRouters = []
self.transitPortalRouters = []
self.controllers = []
self.nameToNode = {} # name to Node (Host/Switch/hostInterface/legacy(Router,Switch)) objects
self.physicalAdaptersBridged = [] # physical adapters connected to a (any) bridge
self.bridgeInterfaces = [] # instantiated bridges
self.terms = [] # list of spawned xterm processes
Mininet.init() # Initialize Mininet if necessary
self.built = False
if topo and build:
self.build()
开发者ID:aimonb,项目名称:miniNeXT,代码行数:70,代码来源:net.py
注:本文中的mininet.util.netParse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论