2

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:

  1. Ending the here document with s0 bash;
  2. Ending it with s0 $SHELL;
  3. Removing the delimiter at the end of the here document (shot in the dark).

(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.

Toni
  • 131
  • 2
  • 11
  • Isn't a command for mininet `mn` ? – Ehsan Ab Jul 17 '15 at 20:37
  • Yes, that is the command to initialize the network, but I was referring to commands within Mininet (e.g., pingall). I found that initializing the network is best handled through the Python API, e.g.: topo = SingleSwitchTopo(n=4) net = Mininet(topo) net.start() CLI(net) # this line will start the Mininet CLI and leave it open to accept commands. – Toni Jul 23 '15 at 10:10
  • Ok, if you have that python topo in a file you can run the topo by just using `sudo -E python ` – Ehsan Ab Jul 23 '15 at 13:59
  • For example, if you have your topo in file [Pkt_Topo_with_loop.py](https://github.com/Ehsan70/RyuApps/blob/master/Pkt_Topo_with_loop.py), you could just use `sudo -E python Pkt_Topo_with_loop.py`. So you would have that line in your bash script. – Ehsan Ab Jul 23 '15 at 14:06

1 Answers1

0

if you have that python topo in a file you can run the topo by just using

sudo -E python <nameofthefile>

For example, If you have your topo in file Pkt_Topo_with_loop.py, you could just use sudo -E python Pkt_Topo_with_loop.py to start up the mininet. So you would have that line in your bash script for automation.

Ehsan Ab
  • 679
  • 5
  • 16