I get the following error:
Traceback (most recent call last):
File "./ryuLinearTopo.py", line 6, in
class LinearTopo(Topo):
File "./ryuLinearTopo.py", line 32, in LinearTopo
simpleTest()
File "./ryuLinearTopo.py", line 21, in simpleTest
topo = LinearTopo(k=4)
NameError: global name 'LinearTopo' is not defined
When I run the following code:
#!/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()