I'd like to automate the process of setting up a Mininet virtual machine, SSHing into the VM, starting Mininet within the VM, and initializing a topology. I need the session to remain open so I can issue commands to Mininet using the created network. Everything works, including initializing the network, but once the bash script ends, Mininet tears down the topology and exits the virtual machine. The relevant parts of my code are as follows:
vboxmanage startvm "Mininet-VM_1" --type=headless
ssh -t -Y -l mininet -p 2222 localhost << HERPDERP
# Start the network
sudo mn --controller=remote,ip=$ip --custom /home/mininet/sf_mininet_vm/mininet/topo_basic.py --topo clos_tree --switch ovsk --link tc
HERPDERP
Things I've tried:
s0 bash
;s0 $SHELL
;(1) and (2) exited Mininet and left me with a prompt in the VM, but for some reason I can't issue commands from it. (3) does nothing.
答案 0 :(得分:0)
如果你在文件中有python topo,你只需使用
就可以运行toposudo -E python <nameofthefile>
例如,如果您的文件Pkt_Topo_with_loop.py中有topo,则可以使用sudo -E python Pkt_Topo_with_loop.py
启动mininet。因此,您可以在bash脚本中使用该行进行自动化。