Cisco Modeling Labs is a tool for building virtual network simulations (or labs) for you to test out new topologies, protocols, and config changes; automate network tests via CI/CD pipeline integration; and learn new things about the cool world of networking.
With this demo you can deploy a docker containers to control multiple CML2s.
git clone https://github.com/masanobu48154/cml2_lab_operation.git
cd cml2_lab_operation/
vi env.py
Define variables for your environment.
The environment when testing CML2 with 10 units is as follows.
$ cat env.py
#!user/bin/python
class MyEnv:
"""
Define variables for your environment.
key
---
your_username:
Username with administrator privileges for cml2 rest API.
your_password:
Password for "your_username".
subnet
The subnet to which the docker host server belongs.
This subnet is required to reach the internet.
Controllers, API servers, selenium hubs and selenium chromes need to
belong to this subnet.
gateway
Docker host subnet gateway.
cml2_
Address of CML2 built in your environment.
api_server
Address of api_server.
The API server is automatically deployed as a docker container.
selenium_hub
Address of selenium_hub.
The selenium_hub is automatically deployed as a docker container.
selenium_chrome01
Address of selenium_chrome01.
The selenium_chrome01 is automatically deployed as a docker container.
selenium_chrome02
Address of selenium_chrome02.
The selenium_chrome02 is automatically deployed as a docker container.
breakout_tool
Address of breakout_tool0.
The breakout_tool0 is automatically deployed as a docker container.
controller
Address of controller.
The controller is automatically deployed as a docker container.
This controller provides only minimal functionality.
1.Stop the existing lab, wipe it, and delete it.
2.Start lab from the yaml file.
3.Make it possible to operate the nodes in lab with telnet via
breakout_tool.
It is your job to make a controller, so please refer to this form to
make it.
phsical_nic
NIC name of docker host.
"""
def __init__(self):
self.my_env = {
"your_username": "testuser",
"your_password": "testpassword",
"subnet": "172.16.1.0/24",
"gateway": "172.16.1.1",
"cml2_0": "172.16.1.200",
"cml2_1": "172.16.1.201",
"cml2_2": "172.16.1.202",
"cml2_3": "172.16.1.203",
"cml2_4": "172.16.1.204",
"cml2_5": "172.16.1.205",
"cml2_6": "172.16.1.206",
"cml2_7": "172.16.1.207",
"cml2_8": "172.16.1.208",
"cml2_9": "172.16.1.209",
"api_server": "172.16.1.254",
"selenium_hub": "172.16.1.150",
"selenium_chrome01": "172.16.1.151",
"selenium_chrome02": "172.16.1.152",
"breakout_tool0": "172.16.1.180",
"breakout_tool1": "172.16.1.181",
"breakout_tool2": "172.16.1.182",
"breakout_tool3": "172.16.1.183",
"breakout_tool4": "172.16.1.184",
"breakout_tool5": "172.16.1.185",
"breakout_tool6": "172.16.1.186",
"breakout_tool7": "172.16.1.187",
"breakout_tool8": "172.16.1.188",
"breakout_tool9": "172.16.1.189",
"controller": "172.16.1.250",
"num_cml2": "10",
"phsical_nic": "ens160"
}
Store the yaml file that defines the lab configuration in the virl_data directory. You can download this yaml file from the lab defined in CML2.
sudo python3 create_controller.py
This script creates html files for the controller.
sudo python3 docker_start.py
This script build and run breakout tool containers, python container, controller container, selenium-hub container and selenium-chrome containers.
The details of the container runned by this script are as follows.
- breakout_tool containers :
- Pulled image == ubuntu:20.04
- Software installed when built == nothing
- python(API server) container :
- Pulled image == ubuntu:20.04
- Software installed when built == python3, python3-pip, apache2, vim, requests, selenium
- controller container :
- Pulled image == ubuntu:20.04
- Software installed when built == apache2, vim
- selenium-hub container :
- Pulled image == selenium/hub:3.14.0-helium
- Software installed when built == nothing
- selenium-chrome container :
- Pulled image == selenium/node-chrome-debug:3.14.0-helium
- Software installed when built == nothing
sudo python3 remove_all_container.py
Delete all docker containers and delete the built image as well.
Owner
Contributors
Categories
Products
Cisco Modeling Labs (CML)Programming Languages
PythonLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community