本文整理汇总了Python中mininet.net.Mininet.publishNet方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.publishNet方法的具体用法?Python Mininet.publishNet怎么用?Python Mininet.publishNet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.net.Mininet
的用法示例。
在下文中一共展示了Mininet.publishNet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startLocalMininet
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import publishNet [as 别名]
def startLocalMininet(data, infect=False):
config = Config()
ip = filter(lambda ip: config.isInControlNetwork(ip[1]), util.getIPs())[0][1]
setLogLevel('debug')
net = Mininet(topo=None, build=False, host=CPULimitedHost, link=TCLink)
net.addController(RemoteController('c0', ip=config.getControlIP()))
for h in data['nodes']:
print "-- add host: %s (%s)" % (h['name'], h['ip'])
net.addHost(h['name'], ip=h['ip'])
for s in data['switches']:
print "-- add switch: %s (%s)" % (s['name'], h['ip'])
net.addSwitch(s['name'], ip=h['ip'])
for l in data['links']:
if l['source'] == 'backbone' or l['target'] == 'backbone':
continue
opts = { k: l[k] for k in ['bw', 'delay', 'loss'] if k in l }
if 'bw' in opts:
opts['bw'] = int(opts['bw'])
if 'loss' in opts:
opts['loss'] = int(opts['loss'])
print "-- add link: %s <-> %s %s" % (l['source'], l['target'], repr(opts))
net.addLink(net.get(l['source']), net.get(l['target']), **opts)
rootSwitch = findRootSwitch(net, data)
iface = filter(lambda ip: config.isInMininetNetwork(ip[1]), util.getIPs())[0][0]
Intf(iface, node=rootSwitch)
net.start()
rootSwitch.cmd("ovs-vsctl add-port %s %s" % (rootSwitch.name, iface))
# This allows infected Mininet instances to lookup nodes via Pyro4.
if infect:
from onenet.inject import infect
print "** Publishing network"
net.publishNet(ip, data['nodes'][0]['pno'])