本文整理汇总了Python中mininet.net.Mininet.switches方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.switches方法的具体用法?Python Mininet.switches怎么用?Python Mininet.switches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.net.Mininet
的用法示例。
在下文中一共展示了Mininet.switches方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import switches [as 别名]
def setup(argv):
domains = []
ctlsets = sys.argv[1:]
# the controllers for the optical domain
d0 = OpticalDomain()
domains.append(d0)
ctls = ctlsets[0].split(',')
for i in range (len(ctls)):
d0.addController('c0%s' % i, controller=RemoteController, ip=ctls[i])
# the fabric domains - position 1 for domain 1, 2 for 2 ...
for i in range (1,len(ctlsets)):
f = FabricDomain(i)
domains.append(f)
ctls = ctlsets[i].split(',')
for j in range (len(ctls)):
f.addController('c%s%s' % (i,j), controller=RemoteController, ip=ctls[j])
# make/setup Mininet object
net = Mininet()
for d in domains:
d.build()
d.injectInto(net)
# connect COs to core - sort of hard-wired at this moment
for i in range(1,len(domains)):
an = { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" }
net.addLink(domains[i].getTether(), d0.getSwitches('OE%s' % i),
port1=OVS_AP, port2=OE_AP, speed=10000, annotations=an, cls=LINCLink)
# fire everything up
net.build()
map(lambda x: x.start(), domains)
# create a minimal copy of the network for configuring LINC.
cfgnet = Mininet()
cfgnet.switches = net.switches
cfgnet.links = net.links
cfgnet.controllers = d0.getControllers()
LINCSwitch.bootOE(cfgnet, d0.getSwitches())
CLI(net)
net.stop()
LINCSwitch.shutdownOE()
示例2: setup
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import switches [as 别名]
def setup(argv):
domains = []
ctlsets = sys.argv[1:]
# the controllers for the optical domain
d0 = OpticalDomain()
domains.append(d0)
ctls = ctlsets[0].split(',')
for i in range (len(ctls)):
d0.addController('c0%s' % i, controller=RemoteController, ip=ctls[i])
# the fabric domains - position 1 for domain 1, 2 for 2 ...
for i in range (1,len(ctlsets)):
f = FabricDomain(i)
domains.append(f)
ctls = ctlsets[i].split(',')
for j in range (len(ctls)):
f.addController('c%s%s' % (i,j), controller=RemoteController, ip=ctls[j])
# netcfg for each domains
# Note: Separate netcfg for domain0 is created in opticalUtils
domainCfgs = []
for i in range (0,len(ctlsets)):
cfg = {}
cfg['devices'] = {}
cfg['ports'] = {}
cfg['links'] = {}
domainCfgs.append(cfg)
# make/setup Mininet object
net = Mininet()
for d in domains:
d.build()
d.injectInto(net)
# connect COs to core - sort of hard-wired at this moment
# adding cross-connect links
for i in range(1,len(domains)):
# add 10 cross-connect links between domains
xcPortNo=2
ochPortNo=10
for j in range(0, 10):
an = { "bandwidth": 10, "durable": "true" }
net.addLink(domains[i].getTether(), d0.getSwitches('OE%s' % i),
port1=xcPortNo+j, port2=ochPortNo+j, speed=10000, annotations=an, cls=LINCLink)
xcId = 'of:' + domains[i].getSwitches(name=domains[i].getTether()).dpid + '/' + str(xcPortNo+j)
ochId = 'of:' + d0.getSwitches('OE%s' % i).dpid + '/' + str(ochPortNo+j)
domainCfgs[i]['ports'][xcId] = {'cross-connect': {'remote': ochId}}
# fire everything up
net.build()
map(lambda x: x.start(), domains)
# create a minimal copy of the network for configuring LINC.
cfgnet = Mininet()
cfgnet.switches = net.switches
cfgnet.links = net.links
cfgnet.controllers = d0.getControllers()
LINCSwitch.bootOE(cfgnet, d0.getSwitches())
# send netcfg json to each CO-ONOS
for i in range(1,len(domains)):
info('*** Pushing Topology.json to CO-ONOS %d\n' % i)
filename = 'Topology%d.json' % i
with open(filename, 'w') as outfile:
json.dump(domainCfgs[i], outfile, indent=4, separators=(',', ': '))
output = quietRun('%s/tools/test/bin/onos-netcfg %s %s &'\
% (LINCSwitch.onosDir,
domains[i].getControllers()[0].ip,
filename), shell=True)
# successful output contains the two characters '{}'
# if there is more output than this, there is an issue
if output.strip('{}'):
warn('***WARNING: Could not push topology file to ONOS: %s\n' % output)
CLI(net)
net.stop()
LINCSwitch.shutdownOE()