This Python script creates the links in a network that includes a router, three workstations, a bridge, and a tunnel.
Note
Because vSLX configuration is persistent, this script is not needed for a single vSLX virtual lab. But it might be useful for setting up multiple networks to run multiple tests.from vsh import
statement.
from vsh import m, cmdparser # The function "m" defines a command executable in vShell.
def demo(): m("create link RT3 1/1 host6 1") m("create link RT3 1/2 -b BR1") m("create link RT3 1/5 T2 1") m("create link RT3 1/6 T2 2") m("create link -b BR1 host7 1") m("create link -b BR1 host30 1")
cmdparser(<target-function>, <syntax>, <msg>)
command that calls the target function.
cmdparser(demo, "demo_01", "Configures network of router, three workstations, bridge, and tunnel.") # The demo target function does not require any parameters.
~/.vsh
directory.
bash$ cp net_demo_01.py ~/.vsh
$ vsh For help anytime, type '?' When you're done, type '^D' (vsh)
(vsh) ? clear Clear connect Connect console create Provisioning demo_01 Configures network of router, three workstations, bridge, and tunnel. delete Destroy exit Exit shell help Get help list Show running devices poweroff Power off device poweron Power on device show Show info start Power on and connect system Bridge daemon control
(vsh) demo_01
Note
The command you created will load every time you log in to this instance of vShell.(vsh) show link Name Port Name Port State ..................................................................... RT3 1/1 <--> host6 0/1 Up RT3 1/2 <--> BR1 [bridge] Up RT3 1/5 <--> T2 0/1 Up RT3 1/6 <--> T2 0/2 Up host30 0/1 <--> BR1 [bridge] Up host7 0/1 <--> BR1 [bridge] Up