我收到以下错误:
回溯(最近一次通话最后):
文件“./ryuLinearTopo.py”,第 6 行,在
类线性拓扑(拓扑):
LinearTopo 中的文件“./ryuLinearTopo.py”,第 32 行
简单测试()
文件“./ryuLinearTopo.py”,第 21 行,在 simpleTest
拓扑 = 线性拓扑(k=4)
NameError:未定义全局名称“LinearTopo”
当我运行以下代码时:
#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.util import irange,dumpNodeConnections
from mininet.log import setLogLevel
class LinearTopo(Topo):
def __init__(self, k=2, **opts):
super(LinearTopo, self).__init__(**opts)
self.k = k
lastSwitch = None
for i in irange(1, k):
host = self.addHost('h%s' % i)
switch = self.addSwitch('s%s' % i)
self.addLink( host, switch)
if lastSwitch:
self.addLink( switch, lastSwitch)
lastSwitch = switch
def simpleTest():
topo = LinearTopo(k=4)
net = Mininet(topo)
net.start()
print "Dumping host connections"
dumpNodeConnections(net.hosts)
print "Testing network connectivity"
net.pingAll()
net.stop()
if __name__ == '__main__':
# Tell mininet to print useful information
setLogLevel('info')
simpleTest()