嗨:)我是openflow和mininet上的新手。
我尝试网络。然后我使用mininet建立了虚拟网络。
sudo mn
在这个现有的网络上,我想再添加一个控制器。 听说了
mininet> py net.addController('c1')
以上代码使我的愿望成真。但是失败了
'list' object is not callable
其他类似的方法也可以正常工作,例如py net.addHost('h3')。
是否有解决方案来解决我的问题,或者是否有其他方法可以在现有小型网上动态添加控制器?
答案 0 :(得分:0)
运行mn
命令时,应该定义控制器。试试这个
sudo mn --controller remote,ip=127.0.0.1
您编写的命令适用于以python编写的自定义拓扑。对于example,您有topo.py
文件
from mininet.cli import CLI
from mininet.log import setLogLevel
from mininet.net import Mininet
from mininet.topo import Topo
from mininet.node import RemoteController, OVSSwitch
class MinimalTopo( Topo ):
"Minimal topology with a single switch and two hosts"
def build( self ):
# Create two hosts.
h1 = self.addHost( 'h1' )
h2 = self.addHost( 'h2' )
# Create a switch
s1 = self.addSwitch( 's1' )
# Add links between the switch and each host
self.addLink( s1, h1 )
self.addLink( s1, h2 )
def runMinimalTopo():
"Bootstrap a Mininet network using the Minimal Topology"
# Create an instance of our topology
topo = MinimalTopo()
# Create a network based on the topology using OVS and controlled by
# a remote controller.
net = Mininet(
topo=topo,
controller=lambda name: RemoteController( name, ip='127.0.0.1' ),
switch=OVSSwitch,
autoSetMacs=True )
# Actually start the network
net.start()
# Drop the user in to a CLI so user can run commands.
CLI( net )
# After the user exits the CLI, shutdown the network.
net.stop()
if __name__ == '__main__':
# This runs if this file is executed directly
setLogLevel( 'info' )
runMinimalTopo()
# Allows the file to be imported using `mn --custom <filename> --topo minimal`
topos = {
'minimal': MinimalTopo
}
您可以这样运行
sudo mn --custom topo.py --topo minimal