2016-03-09 125 views
2

我收到以下錯誤:Mininet腳本錯誤:對象類型 'OVSSwitch' 沒有屬性 'OVSVersion'

File "build/bdist.linux-x86_64/egg/mininet/node.py", line 1162, in start 
    File "build/bdist.linux-x86_64/egg/mininet/node.py", line 1163, in <genexpr> 
    File "build/bdist.linux-x86_64/egg/mininet/node.py", line 1129, in intfOpts 
    File "build/bdist.linux-x86_64/egg/mininet/node.py", line 1072, in isOldOVS 
AttributeError: type object 'OVSSwitch' has no attribute 'OVSVersion' 

而我跑以下Mininet腳本:

#!/usr/bin/python 

from mininet.net import Mininet 
from mininet.node import Controller, RemoteController, OVSController 
from mininet.node import CPULimitedHost, Host, Node 
from mininet.node import OVSKernelSwitch, UserSwitch 
from mininet.node import IVSSwitch 
from mininet.cli import CLI 
from mininet.log import setLogLevel, info 
from mininet.link import TCLink, Intf 
from subprocess import call 

def myNetwork(): 

    net = Mininet(topo=None, 
        build=False, 
        ipBase='10.0.0.0/8') 

    info('*** Adding controller\n') 
    c0=net.addController(name='c0', 
         controller=Controller, 
         protocol='tcp', 
         port=6633) 

    info('*** Add switches\n') 
    r1 = net.addHost('r1', cls=Node, ip='0.0.0.0') 
    r1.cmd('sysctl -w net.ipv4.ip_forward=1') 
    s3 = net.addSwitch('s3', cls=OVSKernelSwitch) 
    r2 = net.addHost('r2', cls=Node, ip='0.0.0.0') 
    r2.cmd('sysctl -w net.ipv4.ip_forward=1') 
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch) 

    info('*** Add hosts\n') 
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None) 
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None) 
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) 
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) 

    info('*** Add links\n') 
    net.addLink(h1, s3) 
    net.addLink(h2, s3) 
    net.addLink(r1, s3) 
    net.addLink(s3, r2) 
    net.addLink(h3, s5) 
    net.addLink(h4, s5) 
    net.addLink(s5, r1) 
    net.addLink(s5, r2) 

    info('*** Starting network\n') 
    net.build() 
    info('*** Starting controllers\n') 
    for controller in net.controllers: 
     controller.start() 

    info('*** Starting switches\n') 
    net.get('s3').start([c0]) 
    net.get('s5').start([c0]) 

    info('*** Post configure switches and hosts\n') 

    CLI(net) 
    net.stop() 

if __name__ == '__main__': 
    setLogLevel('info') 
    myNetwork() 

通過miniedit產生的.py。行號爲1070的代碼在node.py似乎很好。

回答

0

這工作我不知道爲什麼:

#!/usr/bin/python 

from mininet.net import Mininet 
from mininet.node import Controller, RemoteController, OVSController 
from mininet.node import CPULimitedHost, Host, Node 
from mininet.node import OVSKernelSwitch, UserSwitch 
from mininet.node import IVSSwitch 
from mininet.cli import CLI 
from mininet.log import setLogLevel, info 
from mininet.link import TCLink, Intf 
from subprocess import call 

def myNetwork(): 

    net = Mininet(topo=None, 
        build=False, 
        ipBase='10.0.0.0/8') 

    info('*** Adding controller\n') 
    c0=net.addController(name='c0', 
         controller=RemoteController, 
         ip='127.0.0.1', 
         protocol='tcp', 
         port=6633) 

    info('*** Add switches\n') 
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch) 
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch) 
    r3 = net.addHost('r3', cls=Node, ip='0.0.0.0') 
    r3.cmd('sysctl -w net.ipv4.ip_forward=1') 
    r4 = net.addHost('r4', cls=Node, ip='0.0.0.0') 
    r4.cmd('sysctl -w net.ipv4.ip_forward=1') 

    info('*** Add hosts\n') 
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None) 
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None) 
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None) 
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None) 

    info('*** Add links\n') 
    net.addLink(h1, s1) 
    net.addLink(h2, s1) 
    net.addLink(h3, s2) 
    net.addLink(h4, s2) 
    net.addLink(s1, r3) 
    net.addLink(s1, r4) 
    net.addLink(s2, r3) 
    net.addLink(s2, r4) 

    info('*** Starting network\n') 
    net.build() 
    info('*** Starting controllers\n') 
    for controller in net.controllers: 
     controller.start() 

    info('*** Starting switches\n') 
    net.get('s1').start([c0]) 
    net.get('s2').start([c0]) 

    info('*** Post configure switches and hosts\n') 

    CLI(net) 
    net.stop() 

if __name__ == '__main__': 
    setLogLevel('info') 
    myNetwork() 
0

在原來的版本中,你不得不

net.addLink(r1, s3) 

,你需要有

net.addLink(s3, r1) 

你似乎有在重構變量名稱時無意中修復了它。

相關問題