diff --git a/README.md b/README.md index 48aac2b..ec6ac5c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A collection of utilities for interacting with [Cisco Modeling Labs (CML)](https ## virl up / cml up -`virl` (or `cml`) is a devops style cli which supports the most common VIRL/CML operations. Adding new ones is easy... +`virl` (or `cml`) is a devops style cli which supports the most common VIRL/CML operations. Adding new ones is easy... ```sh Usage: cml [OPTIONS] COMMAND [ARGS]... @@ -64,36 +64,36 @@ Commands: 1.Clone this repo - ```sh - git clone https://github.com/CiscoDevNet/virlutils - cd virlutils - ``` +```sh +git clone https://github.com/CiscoDevNet/virlutils +cd virlutils +``` 2.Either (2a) use pip, or (2b) use setup.py - 2a. Use pip +2a. Use pip - ```sh - pip install cmlutils - ``` +```sh +pip install cmlutils +``` - Or +Or - ```sh - pip install virlutils - ``` +```sh +pip install virlutils +``` - 2b. Use setup.py +2b. Use setup.py - ```sh - python3 -m venv venv - source venv/bin/activate - python setup.py install - ``` +```sh +python3 -m venv venv +source venv/bin/activate +python setup.py install +``` ## Configuration -There really isn't much to configure, just set your CML credentials. There are a few different ways to accomplish this, pick whichever one works best for you. The options listed below are in the `preferred` order. +There really isn't much to configure, just set your CML credentials. There are a few different ways to accomplish this, pick whichever one works best for you. The options listed below are in the `preferred` order. ### .virlrc in working directory @@ -133,48 +133,48 @@ In addition to basic credentials, the following configuration options are suppor using any of the methods mentioned previously - `VIRL_TELNET_COMMAND` - allows the user to customize the telnet command that is called. - This command will be passed the host/ip information from the running simulation + This command will be passed the host/ip information from the running simulation - Example: + Example: - ```sh - export VIRL_TELNET_COMMAND="mytelnet {host}" - ``` + ```sh + export VIRL_TELNET_COMMAND="mytelnet {host}" + ``` - `VIRL_SSH_COMMAND` - allows the user to customize the ssh command that is called. - This command will be passed the host/ip as well as the username from the running simulation + This command will be passed the host/ip as well as the username from the running simulation - Example: + Example: - ```sh - export VIRL_SSH_COMMAND="myssh {username}@{host}" - ``` + ```sh + export VIRL_SSH_COMMAND="myssh {username}@{host}" + ``` -- `CML_VERIFY_CERT` - The path to a PEM-encoded certificate file to use to verify the CML controller VM's SSL certificate. If you do not wish to verify the certificate, set this to "False" +- `CML_VERIFY_CERT` - The path to a PEM-encoded certificate file to use to verify the CML controller VM's SSL certificate. If you do not wish to verify the certificate, set this to "False" - Example: + Example: - ```sh - export CML_VERIFY_CERT=/etc/certs/ca_bundle.pem - ``` + ```sh + export CML_VERIFY_CERT=/etc/certs/ca_bundle.pem + ``` - `CML_CONSOLE_COMMAND` - allows the user to customize the SSH command that is called. - This command will be passed the CML controller VM IP, the console path of the node, and the CML controller username (**note:** you may have to force a TTY allocation in your SSH command) + This command will be passed the CML controller VM IP, the console path of the node, and the CML controller username (**note:** you may have to force a TTY allocation in your SSH command) - Example: + Example: - ```sh - export CML_CONSOLE_COMMAND="myssh {user}@{host} {console}" - ``` + ```sh + export CML_CONSOLE_COMMAND="myssh {user}@{host} {console}" + ``` -- `CML_PLUGIN_PATH` - A delimiter-separated list of directories in which to find cmlutils plugins. See the [plugin documentation](examples/plugins/README.md) for more details. By default, the `plugins` directory in the current `.virl` directory will be searched. +- `CML_PLUGIN_PATH` - A delimiter-separated list of directories in which to find cmlutils plugins. See the [plugin documentation](examples/plugins/README.md) for more details. By default, the `plugins` directory in the current `.virl` directory will be searched. - Example: + Example: - ```sh - export CML_PLUGIN_PATH="~/cmlutils/plugins:/opt/cmlutils/plugins" - ``` + ```sh + export CML_PLUGIN_PATH="~/cmlutils/plugins:/opt/cmlutils/plugins" + ``` ### Why so many choices??!? @@ -205,27 +205,31 @@ This allows three major benefits. ```sh $ cml ls Labs on Server -╒════════╤════════════════════════════════╤═════════════════════════╤═════════════════╤═════════╤═════════╤══════════════╕ -│ ID │ Title │ Description │ Status │ Nodes │ Links │ Interfaces │ -╞════════╪════════════════════════════════╪═════════════════════════╪═════════════════╪═════════╪═════════╪══════════════╡ -| | | | | | | | -╘════════╧════════════════════════════════╧═════════════════════════╧═════════════════╧═════════╧═════════╧══════════════╛ +╒═══════════════╤════════════════════════╤═══════════════╤══════════╤══════════╤═════════╤═════════╤══════════════╕ +│ ID │ Title │ Description │ Owner │ Status │ Nodes │ Links │ Interfaces │ +╞═══════════════╪════════════════════════╪═══════════════╪══════════╪══════════╪═════════╪═════════╪══════════════╡ +│ │ │ │ │ │ │ │ │ +╘═══════════════╧════════════════════════╧═══════════════╧══════════╧══════════╧═════════╧═════════╧══════════════╛ $ cd ../test $ cml ls Labs on Server -╒════════╤════════════════════════════════╤═════════════════════════╤═════════════════╤═════════╤═════════╤══════════════╕ -│ ID │ Title │ Description │ Status │ Nodes │ Links │ Interfaces │ -╞════════╪════════════════════════════════╪═════════════════════════╪═════════════════╪═════════╪═════════╪══════════════╡ -│ 7c2cf3 │ Small Branch Test │ │ STARTED │ 9 │ 8 │ 23 │ -╘════════╧════════════════════════════════╧═════════════════════════╧═════════════════╧═════════╧═════════╧══════════════╛ +╒══════════════════════════════════════╤════════════════════════════════╤═════════════════════════════════════════╤══════════╤═════════════════╤═════════╤═════════╤══════════════╕ +│ ID │ Title │ Description │ Owner │ Status │ Nodes │ Links │ Interfaces │ +╞══════════════════════════════════════╪════════════════════════════════╪═════════════════════════════════════════╪══════════╪═════════════════╪═════════╪═════════╪══════════════╡ +│ f25b3881-0d19-4a6d-816f-36d1c663f930 │ Multi Platform Network │ A sample network built with IOS XE, NX- │ labuser │ STOPPED │ 14 │ 32 │ 101 │ +│ │ │ OS, IOS XR, and ASA devices. Includes │ │ │ │ │ │ +│ │ │ Linux hosts. │ │ │ │ │ │ +╘══════════════════════════════════════╧════════════════════════════════╧═════════════════════════════════════════╧══════════╧═════════════════╧═════════╧═════════╧══════════════╛ $ cd ../prod $ cml ls -Running Simulations -╒════════╤════════════════════════════════╤═════════════════════════╤═════════════════╤═════════╤═════════╤══════════════╕ -│ ID │ Title │ Description │ Status │ Nodes │ Links │ Interfaces │ -╞════════╪════════════════════════════════╪═════════════════════════╪═════════════════╪═════════╪═════════╪══════════════╡ -│ 7c2cf3 │ Small Branch Prod │ │ STARTED │ 9 │ 8 │ 23 │ -╘════════╧════════════════════════════════╧═════════════════════════╧═════════════════╧═════════╧═════════╧══════════════╛ +Labs on Server +╒══════════════════════════════════════╤════════════════════════════════╤═════════════════════════════════════════╤══════════╤═════════════════╤═════════╤═════════╤══════════════╕ +│ ID │ Title │ Description │ Owner │ Status │ Nodes │ Links │ Interfaces │ +╞══════════════════════════════════════╪════════════════════════════════╪═════════════════════════════════════════╪══════════╪═════════════════╪═════════╪═════════╪══════════════╡ +│ 0fdea012-83b4-4545-8747-c7b8037e5a96 │ Multi Platform Network │ A sample network built with IOS XE, NX- │ labuser │ STARTED │ 14 │ 32 │ 101 │ +│ │ │ OS, IOS XR, and ASA devices. Includes │ │ │ │ │ │ +│ │ │ Linux hosts. │ │ │ │ │ │ +╘══════════════════════════════════════╧════════════════════════════════╧═════════════════════════════════════════╧══════════╧═════════════════╧═════════╧═════════╧══════════════╛ ``` ## Usage / Workflows @@ -238,81 +242,76 @@ in the absence of better documentation, here's a sample workflow [venv]jclarke@jamahal:~/src/git/virlutils|cmlutils ⇒ cml ls Labs on Server -╒════════╤════════════════════════════════╤═════════════════════════╤═════════════════╤═════════╤═════════╤══════════════╕ -│ ID │ Title │ Description │ Status │ Nodes │ Links │ Interfaces │ -╞════════╪════════════════════════════════╪═════════════════════════╪═════════════════╪═════════╪═════════╪══════════════╡ -│ 02f6c6 │ CCIE Enterprise Infrastructure │ │ DEFINED_ON_CORE │ 54 │ 67 │ 216 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ 332eab │ Branch Test │ │ DEFINED_ON_CORE │ 6 │ 5 │ 15 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ 7c2cf3 │ Small Branch │ │ STOPPED │ 9 │ 8 │ 23 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ e5afaf │ Dynamic Split Tunnel │ │ STOPPED │ 10 │ 9 │ 36 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ 66defd │ Lab at Tue 14:45 PM │ │ STOPPED │ 2 │ 1 │ 6 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ bc518e │ Lab at Wed 21:39 PM │ │ STOPPED │ 9 │ 1 │ 26 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ 0e1bb2 │ DFN │ German Research Network │ DEFINED_ON_CORE │ 51 │ 80 │ 211 │ -╘════════╧════════════════════════════════╧═════════════════════════╧═════════════════╧═════════╧═════════╧══════════════╛ +╒══════════════════════════════════════╤════════════════════════════════╤═════════════════════════════════════════╤══════════╤═════════════════╤═════════╤═════════╤══════════════╕ +│ ID │ Title │ Description │ Owner │ Status │ Nodes │ Links │ Interfaces │ +╞══════════════════════════════════════╪════════════════════════════════╪═════════════════════════════════════════╪══════════╪═════════════════╪═════════╪═════════╪══════════════╡ +│ 35c5393b-6037-4c96-86d4-33f96e53a615 │ CCIE Enterprise Infrastructure │ │ labuser │ DEFINED_ON_CORE │ 54 │ 67 │ 216│ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ a5fa67e3-44b9-4b26-8a50-58d471766280 │ Branch Test │ │ labuser │ STOPPED │ 6 │ 5 │ 17 │ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ 931b20a1-f0be-4c9f-b7ef-4db96ee77135 │ Small Branch │ A small branch network built with CSR1kv│ labuser │ STOPPED │ 14 │ 32 │ 101 │ +│ │ │ IOSv, IOSvL2. The devices are managed by│ │ │ │ │ │ +│ │ │ NSO. │ │ │ │ │ │ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ 8e8047b6-faf8-4b0a-86ea-c05a0549e4fe │ Dynamic Split Tunnel │ │ labuser │ STOPPED │ 7 │ 9 │ 37 │ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ 86ef940d-58e8-49d9-b154-22ec714add62 │ Lab at Tue 14:45 PM │ │ labuser │ STOPPED │ 3 │ 2 │ 14 │ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ ba9a1282-048f-4914-a419-59c8027afa6a │ DFN │ German Research Network │ labuser │ STARTED │ 51 │ 80 │ 211 │ +╘══════════════════════════════════════╧════════════════════════════════╧═════════════════════════════════════════╧══════════╧═════════════════╧═════════╧═════════╧══════════════╛ + +[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils +⇒ cml use --lab-name "Small Branch" [venv]jclarke@jamahal:~/src/git/virlutils|cmlutils ⇒ cml id -Small Branch (ID: 7c2cf3) +Small Branch (ID: 931b20a1-f0be-4c9f-b7ef-4db96ee77135) [venv]jclarke@jamahal:~/src/git/virlutils|cmlutils ⇒ cml up -Lab Small Branch (ID: 7c2cf3) is already set as the current lab -Starting lab Small Branch (ID: 7c2cf3) +Lab Small Branch (ID: 931b20a1-f0be-4c9f-b7ef-4db96ee77135) is already set as the current lab +Starting lab Small Branch (ID: 931b20a1-f0be-4c9f-b7ef-4db96ee77135) [venv]jclarke@jamahal:~/src/git/virlutils|cmlutils ⇒ cml ls Labs on Server -╒════════╤════════════════════════════════╤═════════════════════════╤═════════════════╤═════════╤═════════╤══════════════╕ -│ ID │ Title │ Description │ Status │ Nodes │ Links │ Interfaces │ -╞════════╪════════════════════════════════╪═════════════════════════╪═════════════════╪═════════╪═════════╪══════════════╡ -│ 02f6c6 │ CCIE Enterprise Infrastructure │ │ DEFINED_ON_CORE │ 54 │ 67 │ 216 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ 332eab │ Branch Test │ │ DEFINED_ON_CORE │ 6 │ 5 │ 15 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ 7c2cf3 │ Small Branch │ │ STARTED │ 9 │ 8 │ 23 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ e5afaf │ Dynamic Split Tunnel │ │ STOPPED │ 10 │ 9 │ 36 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ 66defd │ Lab at Tue 14:45 PM │ │ STOPPED │ 2 │ 1 │ 6 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ bc518e │ Lab at Wed 21:39 PM │ │ STOPPED │ 9 │ 1 │ 26 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ 0e1bb2 │ DFN │ German Research Network │ DEFINED_ON_CORE │ 51 │ 80 │ 211 │ -╘════════╧════════════════════════════════╧═════════════════════════╧═════════════════╧═════════╧═════════╧══════════════╛ +╒══════════════════════════════════════╤════════════════════════════════╤═════════════════════════════════════════╤══════════╤═════════════════╤═════════╤═════════╤══════════════╕ +│ ID │ Title │ Description │ Owner │ Status │ Nodes │ Links │ Interfaces │ +╞══════════════════════════════════════╪════════════════════════════════╪═════════════════════════════════════════╪══════════╪═════════════════╪═════════╪═════════╪══════════════╡ +│ 35c5393b-6037-4c96-86d4-33f96e53a615 │ CCIE Enterprise Infrastructure │ │ labuser │ DEFINED_ON_CORE │ 54 │ 67 │ 216│ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ a5fa67e3-44b9-4b26-8a50-58d471766280 │ Branch Test │ │ labuser │ STOPPED │ 6 │ 5 │ 17 │ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ 931b20a1-f0be-4c9f-b7ef-4db96ee77135 │ Small Branch │ A small branch network built with CSR1kv│ labuser │ STARTED │ 14 │ 32 │ 101 │ +│ │ │ IOSv, IOSvL2. The devices are managed by│ │ │ │ │ │ +│ │ │ NSO. │ │ │ │ │ │ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ 8e8047b6-faf8-4b0a-86ea-c05a0549e4fe │ Dynamic Split Tunnel │ │ labuser │ STOPPED │ 7 │ 9 │ 37 │ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ 86ef940d-58e8-49d9-b154-22ec714add62 │ Lab at Tue 14:45 PM │ │ labuser │ STOPPED │ 3 │ 2 │ 14 │ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ ba9a1282-048f-4914-a419-59c8027afa6a │ DFN │ German Research Network │ labuser │ STARTED │ 51 │ 80 │ 211 │ +╘══════════════════════════════════════╧════════════════════════════════╧═════════════════════════════════════════╧══════════╧═════════════════╧═════════╧═════════╧══════════════╛ [venv]jclarke@jamahal:~/src/git/virlutils|cmlutils ⇒ cml nodes Here is a list of nodes in this lab -╒══════╤════════════════╤════════════════════╤═════════╤══════════╤══════════════════╕ -│ ID │ Label │ Type │ State │ Wiped? │ L3 Address(es) │ -╞══════╪════════════════╪════════════════════╪═════════╪══════════╪══════════════════╡ -│ n0 │ branch-rtr │ csr1000v │ BOOTED │ False │ 192.168.10.219 │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n1 │ Internet │ external_connector │ BOOTED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n2 │ branch-sw │ iosvl2 │ BOOTED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n3 │ client-desktop │ desktop │ BOOTED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n4 │ WAN Link 1 │ wan_emulator │ BOOTED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n5 │ rtr-2 │ iosv │ BOOTED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n8 │ ext-conn-1 │ external_connector │ BOOTED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n6 │ trex-0 │ trex │ BOOTED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n7 │ VLAN 10 │ external_connector │ BOOTED │ False │ │ -╘══════╧════════════════╧════════════════════╧═════════╧══════════╧══════════════════╛ - +╒══════════════════════════════════════╤════════════════════╤════════════════════╤════════════════╤═════════════════╤══════════╤══════════════════════════════════════╕ +│ ID │ Label │ Type │ Compute Node │ State │ Wiped? │ L3 Address(es) │ +╞══════════════════════════════════════╪════════════════════╪════════════════════╪════════════════╪═════════════════╪══════════╪══════════════════════════════════════╡ +│ 32135ea1-d6f4-4ae5-94cb-8dfa14c0b758 │ Internet │ external_connector │ compute-01 │ BOOTED │ False │ │ +├──────────────────────────────────────┼────────────────────┼────────────────────┼────────────────┼─────────────────┼──────────┼──────────────────────────────────────┤ +│ e6ed74ef-62bf-4f4c-8fe8-a44fb3bc74c4 │ branch-rtr │ csr1000v │ compute-01 │ BOOTED │ False │ 192.168.10.129 │ +├──────────────────────────────────────┼────────────────────┼────────────────────┼────────────────┼─────────────────┼──────────┼──────────────────────────────────────┤ +│ a01784b1-d11f-4c52-907b-b6ac92d3b8f1 │ branch-sw │ iosvl2 │ compute-01 │ BOOTED │ False │ 192.168.10.143 │ +├──────────────────────────────────────┼────────────────────┼────────────────────┼────────────────┼─────────────────┼──────────┼──────────────────────────────────────┤ +│ 84625ab4-53dd-4ff4-8cd1-2a2ef94edc02 │ nso-0 │ nso_ubuntu │ compute-01 │ BOOTED │ False │ 2001:db8:dead:beef:5054:ff:fe11:a168 │ +│ │ │ │ │ │ │ fe80::5054:ff:fe11:a168 │ +├──────────────────────────────────────┼────────────────────┼────────────────────┼────────────────┼─────────────────┼──────────┼──────────────────────────────────────┤ +│ 579a9e46-3433-4645-9bad-c84106d9cd54 │ remote-rtr │ iosv │ compute-01 │ BOOTED │ False │ 192.168.10.137 │ +╘══════════════════════════════════════╧════════════════════╧════════════════════╧════════════════╧═════════════════╧══════════╧══════════════════════════════════════╛ [venv]jclarke@jamahal:~/src/git/virlutils|cmlutils ⇒ cml console branch-rtr @@ -329,58 +328,47 @@ branch-rtr# [venv]jclarke@jamahal:~/src/git/virlutils|cmlutils ⇒ cml down -Shutting down lab Small Branch (ID: 7c2cf3)..... +Shutting down lab Small Branch (ID: 931b20a1-f0be-4c9f-b7ef-4db96ee77135)..... SUCCESS [venv]jclarke@jamahal:~/src/git/virlutils|cmlutils ⇒ cml ls Labs on Server -╒════════╤════════════════════════════════╤═════════════════════════╤═════════════════╤═════════╤═════════╤══════════════╕ -│ ID │ Title │ Description │ Status │ Nodes │ Links │ Interfaces │ -╞════════╪════════════════════════════════╪═════════════════════════╪═════════════════╪═════════╪═════════╪══════════════╡ -│ 02f6c6 │ CCIE Enterprise Infrastructure │ │ DEFINED_ON_CORE │ 54 │ 67 │ 216 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ 332eab │ Branch Test │ │ DEFINED_ON_CORE │ 6 │ 5 │ 15 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ 7c2cf3 │ Small Branch │ │ STOPPED │ 9 │ 8 │ 23 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ e5afaf │ Dynamic Split Tunnel │ │ STOPPED │ 10 │ 9 │ 36 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ 66defd │ Lab at Tue 14:45 PM │ │ STOPPED │ 2 │ 1 │ 6 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ bc518e │ Lab at Wed 21:39 PM │ │ STOPPED │ 9 │ 1 │ 26 │ -├────────┼────────────────────────────────┼─────────────────────────┼─────────────────┼─────────┼─────────┼──────────────┤ -│ 0e1bb2 │ DFN │ German Research Network │ DEFINED_ON_CORE │ 51 │ 80 │ 211 │ -╘════════╧════════════════════════════════╧═════════════════════════╧═════════════════╧═════════╧═════════╧══════════════╛ - -[venv]jclarke@jamahal:~/src/git/virlutils|cmlutils -⇒ cml use --lab-name "Small Branch" +╒══════════════════════════════════════╤════════════════════════════════╤═════════════════════════════════════════╤══════════╤═════════════════╤═════════╤═════════╤══════════════╕ +│ ID │ Title │ Description │ Owner │ Status │ Nodes │ Links │ Interfaces │ +╞══════════════════════════════════════╪════════════════════════════════╪═════════════════════════════════════════╪══════════╪═════════════════╪═════════╪═════════╪══════════════╡ +│ 35c5393b-6037-4c96-86d4-33f96e53a615 │ CCIE Enterprise Infrastructure │ │ labuser │ DEFINED_ON_CORE │ 54 │ 67 │ 216│ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ a5fa67e3-44b9-4b26-8a50-58d471766280 │ Branch Test │ │ labuser │ STOPPED │ 6 │ 5 │ 17 │ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ 931b20a1-f0be-4c9f-b7ef-4db96ee77135 │ Small Branch │ A small branch network built with CSR1kv│ labuser │ STOPPED │ 14 │ 32 │ 101 │ +│ │ │ IOSv, IOSvL2. The devices are managed by│ │ │ │ │ │ +│ │ │ NSO. │ │ │ │ │ │ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ 8e8047b6-faf8-4b0a-86ea-c05a0549e4fe │ Dynamic Split Tunnel │ │ labuser │ STOPPED │ 7 │ 9 │ 37 │ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ 86ef940d-58e8-49d9-b154-22ec714add62 │ Lab at Tue 14:45 PM │ │ labuser │ STOPPED │ 3 │ 2 │ 14 │ +├──────────────────────────────────────┼────────────────────────────────┼─────────────────────────────────────────┼──────────┼─────────────────┼─────────┼─────────┼──────────────┤ +│ ba9a1282-048f-4914-a419-59c8027afa6a │ DFN │ German Research Network │ labuser │ STARTED │ 51 │ 80 │ 211 │ +╘══════════════════════════════════════╧════════════════════════════════╧═════════════════════════════════════════╧══════════╧═════════════════╧═════════╧═════════╧══════════════╛ [venv]jclarke@jamahal:~/src/git/virlutils|cmlutils ⇒ cml nodes Here is a list of nodes in this lab -╒══════╤════════════════╤════════════════════╤═════════╤══════════╤══════════════════╕ -│ ID │ Label │ Type │ State │ Wiped? │ L3 Address(es) │ -╞══════╪════════════════╪════════════════════╪═════════╪══════════╪══════════════════╡ -│ n0 │ branch-rtr │ csr1000v │ STOPPED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n1 │ Internet │ external_connector │ STOPPED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n2 │ branch-sw │ iosvl2 │ STOPPED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n3 │ client-desktop │ desktop │ STOPPED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n4 │ WAN Link 1 │ wan_emulator │ STOPPED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n5 │ rtr-2 │ iosv │ STOPPED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n8 │ ext-conn-1 │ external_connector │ STOPPED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n6 │ trex-0 │ trex │ STOPPED │ False │ │ -├──────┼────────────────┼────────────────────┼─────────┼──────────┼──────────────────┤ -│ n7 │ VLAN 10 │ external_connector │ STOPPED │ False │ │ -╘══════╧════════════════╧════════════════════╧═════════╧══════════╧══════════════════╛ - +╒══════════════════════════════════════╤════════════════════╤════════════════════╤════════════════╤═════════════════╤══════════╤══════════════════════════════════════╕ +│ ID │ Label │ Type │ Compute Node │ State │ Wiped? │ L3 Address(es) │ +╞══════════════════════════════════════╪════════════════════╪════════════════════╪════════════════╪═════════════════╪══════════╪══════════════════════════════════════╡ +│ 32135ea1-d6f4-4ae5-94cb-8dfa14c0b758 │ Internet │ external_connector │ compute-01 │ STOPPED │ False │ │ +├──────────────────────────────────────┼────────────────────┼────────────────────┼────────────────┼─────────────────┼──────────┼──────────────────────────────────────┤ +│ e6ed74ef-62bf-4f4c-8fe8-a44fb3bc74c4 │ branch-rtr │ csr1000v │ compute-01 │ STOPPED │ False │ │ +├──────────────────────────────────────┼────────────────────┼────────────────────┼────────────────┼─────────────────┼──────────┼──────────────────────────────────────┤ +│ a01784b1-d11f-4c52-907b-b6ac92d3b8f1 │ branch-sw │ iosvl2 │ compute-01 │ STOPPED │ False │ │ +├──────────────────────────────────────┼────────────────────┼────────────────────┼────────────────┼─────────────────┼──────────┼──────────────────────────────────────┤ +│ 84625ab4-53dd-4ff4-8cd1-2a2ef94edc02 │ nso-0 │ nso_ubuntu │ compute-01 │ STOPPED │ False │ │ +│ │ │ │ │ │ │ │ +├──────────────────────────────────────┼────────────────────┼────────────────────┼────────────────┼─────────────────┼──────────┼──────────────────────────────────────┤ +│ 579a9e46-3433-4645-9bad-c84106d9cd54 │ remote-rtr │ iosv │ compute-01 │ STOPPED │ False │ │ +╘══════════════════════════════════════╧════════════════════╧════════════════════╧════════════════╧═════════════════╧══════════╧══════════════════════════════════════╛ ``` ### Console to All Nodes with tmux @@ -416,7 +404,7 @@ Here is a list of nodes in this lab This will create a new tmux session with title "lab name + first 4 lab id chars" (e.g. `PPK-c93a`). By default, the nodes will be grouped into one window (`cml tmux --group panes`), -``` sh +```sh ❯ printf '\033]2;%s\033\\' 'c8v-2' ❯ ssh -t admin@cml-01 open /PPK/c8v-2/0 admin@cml-01's password: @@ -441,7 +429,7 @@ c8v1# if you prefer having one connection per window, use: `cml tmux --group windows`. -``` sh +```sh ❯ ssh -t admin@cml-01 open /PPK/c8v-2/0 admin@cml-01's password: Connecting to console for c8v-2 @@ -480,7 +468,7 @@ cml generate pyats #### Command and Config Execution -Using the same pyATS framework, `virlutils` can execute CLI EXEC-level (e.g., "show") commands as well as configuration commands on nodes within a lab. These nodes do not have to be externally reachable or have any IP connectivity. This is a great way to test operational aspects of a completely isolated topology. Before using the `command` command you must install pyATS. You can install pyATS by running `pip install pyats`. +Using the same pyATS framework, `virlutils` can execute CLI EXEC-level (e.g., "show") commands as well as configuration commands on nodes within a lab. These nodes do not have to be externally reachable or have any IP connectivity. This is a great way to test operational aspects of a completely isolated topology. Before using the `command` command you must install pyATS. You can install pyATS by running `pip install pyats`. ```sh [venv]jclarke@jamahal:~/src/git/virlutils|cmlutils @@ -500,7 +488,7 @@ Technical Support: http://www.cisco.com/techsupport #### Ansible Inventory Generation quickly turn your simulations into an inventory file that can be used to run your playbooks -against. Both INI and YAML(default) formats are supported by the tool. +against. Both INI and YAML(default) formats are supported by the tool. ```sh Usage: cml generate ansible [OPTIONS] @@ -513,7 +501,7 @@ Options: --help Show this message and exit. ``` -The ansible group membership can be controlled by adding the "ansible_group" tag to nodes in your CML labs. Multiple "ansible_group" tags can be assigned to a single node, and that node will be placed into each Ansible inventory group. +The ansible group membership can be controlled by adding the "ansible_group" tag to nodes in your CML labs. Multiple "ansible_group" tags can be assigned to a single node, and that node will be placed into each Ansible inventory group. ```yaml nodes: @@ -533,10 +521,9 @@ all: hosts: branch-router: ansible_host: 192.0.2.1 - ``` -**NOTE:** if the ansible_group tag is not specified for a node, that node will not be included during inventory generation. Additionally, CML needs to know each node's management IP address before it will be placed into the inventory file +**NOTE:** if the ansible_group tag is not specified for a node, that node will not be included during inventory generation. Additionally, CML needs to know each node's management IP address before it will be placed into the inventory file #### Cisco Network Services Orchestrator @@ -566,7 +553,7 @@ Successfully added CML devices to NSO ``` -**NOTE**: NSO environment is also attempted to be determined using the following environment +**NOTE**: NSO environment is also attempted to be determined using the following environment variables - NSO_HOST @@ -617,7 +604,7 @@ eval "$(_CML_COMPLETE=zsh_source cml)" ## Local Development -If you have an idea for a feature you would like to see, we gladly accept pull requests. To get started developing, simply run the following.. +If you have an idea for a feature you would like to see, we gladly accept pull requests. To get started developing, simply run the following.. ```sh git clone https://github.com/CiscoDevNet/virlutils diff --git a/virl/api/cml.py b/virl/api/cml.py index 4870a17..777c824 100644 --- a/virl/api/cml.py +++ b/virl/api/cml.py @@ -60,3 +60,7 @@ def statistics(self): @property def owner(self): return "N/A" + + @property + def username(self): + return "N/A" diff --git a/virl/cli/views/labs/lab_views.py b/virl/cli/views/labs/lab_views.py index 1036729..c4d01a0 100644 --- a/virl/cli/views/labs/lab_views.py +++ b/virl/cli/views/labs/lab_views.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +import textwrap + import click import tabulate @@ -13,14 +15,14 @@ def lab_list_table(labs, cached_labs=None): def print_labs(labs): table = list() - # TODO: Do we truncate description as it can be kind of long? headers = ["ID", "Title", "Description", "Owner", "Status", "Nodes", "Links", "Interfaces"] for lab in labs: tr = list() tr.append(lab.id) tr.append(lab.title) - tr.append(lab.description) - tr.append(lab.owner) + wrapped_description = textwrap.fill(lab.description, width=40) + tr.append(wrapped_description) + tr.append(lab.username) status = lab.state() stats = lab.statistics if status in {"BOOTED", "STARTED"}: diff --git a/virl/cli/views/nodes/node_views.py b/virl/cli/views/nodes/node_views.py index c0e0276..10c810a 100644 --- a/virl/cli/views/nodes/node_views.py +++ b/virl/cli/views/nodes/node_views.py @@ -67,7 +67,7 @@ def node_list_table(nodes, computes): if disc_ipv6: intfs += disc_ipv6 - tr.append(",".join(intfs)) + tr.append("\n".join(intfs)) table.append(tr) # wrap the output in this try/except block as some terminals # may have problem with the 'fancy_grid'