Fully automated, Crosswork Based Restful ZTP flow using Classic ZTP with IOS-XR 6.6.3+
xr-restztp is a simple Hook server that implements a REST client for Cisco Crosswork (3.2+) to enable and add ZTP devices, profiles, configs and credentials. It also hosts a flask based REST server in a thread to listen for POST events from a python script executed by the IOS-XR device that is running ZTP. The python ZTP script itself is uploaded to Cisco Crosswork by the xr-restztp code during the initial set up.
The flow of events is showcased below:
The Relevant APIs used for Cisco crosswork and to test the basic Flask server hosted by xr-restztp are captured in the Postman collection that can be found at the following URL:
Some Snapshots of these APIs are given below. Click the link above to view the same in your Postman Dashboard:
The code for the server is automatically built into a Docker image on Dockerhub here: https://hub.docker.com/repository/docker/akshshar/xr-restztp-hook
To run the server:
-
Install docker on the selected host machine
-
Clone the Git repo and drop into the repo directory:
git clone https://akshshar/xr-restztp ~/ cd ~/xr-restztp/
-
Launch the server by using the docker run command inside the repo directory to correctly mount the sample config.json provided in
/lib
(exposing either port 5000 as shown below or modify based on your choice):docker run --rm -itd \ --name xr-restztp -p 5000:5000 \ -v ${PWD}/lib/config.json:/usr/local/lib/xr-restztp/config.json \ akshshar/xr-restztp-hook
-
View the logs generated by the server in real time, using
docker logs -f
cisco@ztphook:~/xr-restztp$ docker logs -f xr-restztp * Serving Flask app "restful_ztp_hook" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: on * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) Configuration successfully updated Profile Created successfully ZTP Credential Profile Created successfully Device Added successfully