RYU软件定义网络中的回溯(最近呼叫最后一次)错误

时间:2017-04-20 13:41:33

标签: python traceback sdn topology ryu

我收到以下错误:

追踪(最近一次呼叫最后一次):

文件" ./ ryuLinearTopo.py",第6行,

class LinearTopo(Topo):

File" ./ ryuLinearTopo.py",第32行,在LinearTopo中

SimpleTest的()

文件" ./ ryuLinearTopo.py",第21行,在simpleTest中

topo = LinearTopo(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()

0 个答案:

没有答案