我無法正確理解如何使用類。在沒有腳本的情況下調用類構造函數會自動以交互模式運行CLI。因此,您需要手動退出交互模式以獲取類實例。只有這樣你才能使用所述實例調用類方法。這似乎很奇怪。Mininet Python API - CLI類
我想要做的是編寫一個配置網絡的程序,然後在單獨的節點上打開幾個xterm窗口並在其中啓動一個應用程序。這可能嗎?
編輯:
比如像下面這樣:
#!/usr/bin/python
from mininet.net import Mininet
from mininet.log import setLogLevel
from mininet.cli import CLI
from mininet.topolib import TreeTopo
def test():
"Create and test a simple network"
net = Mininet(TreeTopo(depth=2,fanout=2))
net.start()
cli = CLI(net)
CLI.do_xterm(cli, "h1 h2")
net.stop()
if __name__ == '__main__':
setLogLevel('info')
test()
調用CLI類的構造函數,以獲得類實例自動啓動mininet在交互模式。在對類實例調用do_xterm方法之前,需要手動退出。
你能給出一個更具體的例子你的問題?也許有些代碼。 –