This Python app is containerised with Docker Compose for a modular and cloud native deployment that fits in any microservice architecture.
It does the following:
- Call the VMware VeloCloud Orchestrator (VCO) API to download a copy of the config stack for all of the SD-WAN Edges in the enterprise network;
- Export the config stacks as separate JSON files on a
Docker volume
that is mounted in the same directory of thedocker-compose.yml
file on the Docker host, or in the same directory of the Python script if it is run as a standalone service, in a number of nested directories by the date and time of the API call; and - Repeat the process every 15 minutes on the hour and at :15, :30 and :45 past for an automated Edge config backup.
A detailed walk-through is available here.
Get started in three simple steps:
- Download a copy of the app;
- Create the environment variables for the VCO authentication and modify the crontab if needed; and
- Docker Compose or build and run the image manually to start the app, or alternatively run the Python script as a standalone service.
Download a copy of the app with git clone
. Be sure to pass the --recurse-submodules
argument to initialise and update each submodule in the repository.
$ git clone --recurse-submodules https://github.com/kurtcms/vco-api-ent-edge-config /app/vco-api-ent-edge-config/
The app expects the hostname, the API token or the username and password for the VCO, as environment variables in a .env
file in the same directory.
Should both the API token, and the username and password, for the VCO be present, the app will always use the API token.
Be sure to create the .env
file.
$ nano /app/vco-api-ent-edge-config/.env
And define the credentials accordingly.
VCO_HOSTNAME = 'vco.managed-sdwan.com/'
# Either the API token
VCO_TOKEN = '(redacted)'
# Or the username and password
VCO_USERNAME = 'kurtcms'
VCO_PASSWORD = '(redacted)'
By default the app is scheduled with cron to pull a copy of the config stack for all the SD-WAN Edges in the enterprise network every 15 minutes, with stdout
and stderr
redirected to the main process for Docker logs
.
Modify the crontab
if a different schedule is required.
$ nano /app/vco-api-ent-edge-config/crontab
Packaged as a container, the app is a standalone, executable package that may be run on Docker Engine. Be sure to have Docker installed.
With Docker Compose, the app may be provisioned with a single command.
Install Docker and Docker Compose with the Bash script that comes with app.
$ chmod +x /app/vco-api-ent-edge-config/docker-compose/docker-compose.sh \
&& /app/vco-api-ent-edge-config/docker-compose/docker-compose.sh
Start the containers with Docker Compose.
$ docker-compose -f /app/vco-api-ent-edge-config/docker-compose.yml up -d
Stopping the container is as simple as a single command.
$ docker-compose -f /app/vco-api-ent-edge-config/docker-compose.yml down
Otherwise the Docker image can also be built manually.
$ docker build -t vco_api_ent_edge_config /app/vco-api-ent-edge-config/
Run the image with Docker once it is ready.
$ docker run -it --rm --name vco_api_ent_edge_config vco_api_ent_edge_config
Alternatively the vco_api_ent_edge_config.py
script may be deployed as a standalone service.
In which case be sure to install the following required libraries for the vco_api_main.py
:
Install them with pip3
:
$ pip3 install requests python-dotenv numpy pandas
The script may then be executed with a task scheduler such as cron that runs it once every 15 minutes for example.
$ (crontab -l; echo "*/15 * * * * /usr/bin/python3 /app/vco-api-ent-edge-config/vco_api_ent_edge_config.py") | crontab -
The config stacks for all the Edges in the enterprise network will be downloaded and saved as separate JSON files on a Docker volume
that is mounted in the same directory of the docker-compose.yml
file on the Docker host. If the Python script is run as a standalone service, the JSON files will be in the same directory of the script instead.
In any case, the JSON files are stored under a directory by the enterpriseName
, and nested in a number of subdirectories named respectively by the year, the month and the day, and finally by the full date and time of the API call to ease access.
.
└── enterpriseName/
└── Year/
└── Month/
└── Date/
└── YYYY-MM-DD-HH-MM-SS/
├── edgeName1.json
├── edgeName2.json
├── edgeName3.json
└── edgeName4.json