我想在Mininet設置中的每臺主機上運行Quagga實例。正如下面的代碼所實現的,我能夠爲每個主機安裝/tmp/<host>/etc/quagga
作爲/etc/quagga
,將每個主機(私有目錄)的目錄內的配置文件隔離。但是當我在每個主機上啓動Quagga服務時(最後一行在ipconf
文件中),它們都共享相同的PID號碼,儘管每個主機都有自己的Quagga配置文件,但它們都有效地爲所有主機創建相同的進程。Mininet中進程具有不同PID空間的主機
我想擁有單獨的Quagga實例,每個實例都有自己的PID。我怎樣才能做到這一點?
自定義拓撲文件my_topo.py
:
from mininet.topo import Topo
class my_topo(Topo):
"My custom topology settings"
def __init__(self, enable_all=True):
"Create custom topo."
Topo.__init__(self)
private_dirs = [("/etc/quagga", "/tmp/%(name)s/etc/quagga")]
h1 = self.addHost("h1",
ip="172.31.1.100/24",
privateDirs=private_dirs)
h2 = self.addHost("h2",
ip="172.31.2.100/24",
privateDirs=private_dirs)
h3 = self.addHost("h3",
ip="172.31.3.100/24",
privateDirs=private_dirs)
h4 = self.addHost("h4",
ip="172.31.4.100/24",
privateDirs=private_dirs)
h5 = self.addHost("h5",
ip="172.32.1.2/30",
privateDirs=private_dirs)
sA = self.addSwitch("s5")
sB = self.addSwitch("s6")
sC = self.addSwitch("s7")
sD = self.addSwitch("s8")
self.addLink(h1, sA)
self.addLink(h2, sB)
self.addLink(h3, sC)
self.addLink(h4, sD)
self.addLink(sA, sB)
self.addLink(sB, sD)
self.addLink(sD, sC)
self.addLink(sC, sA)
self.addLink(sA, sD)
self.addLink(h2, h5, 1, 0)
self.addLink(h4, h5, 1, 1)
topos = { "my_topo": (lambda: my_topo()) }
命令文件ipconf
:
h1 /etc/init.d/quagga restart
h2 /etc/init.d/quagga restart
h3 /etc/init.d/quagga restart
h4 /etc/init.d/quagga restart
h5 /etc/init.d/quagga restart
命令來運行Mininet:
sudo mn --custom mininet/custom/my_topo.py --topo=my_topo --controller=remote,ip=192.168.56.101,port=6633 --pre=ipconf