First of all, I have to thank Yedu Siddalingappa from Mist and then Thomas Munzer who created the Mist Switch Operator UI.
I was working on a script to accomplish the following goals:
- Individual port level changes on the Juniper switches using the APIs
- View the changes
- Allow users to only view and make changes to the access ports only and not touch the SFP (uplink) ports.
I completed my script that was menu driven and made changes to the individual port(s). Mist API’s currently don’t have support for PATCH or merge. So making a change to an individual port means you have to ensure to send push out the whole port configuration and not just part of it. This can get a little tricky, there is some GET involved, then extract related data and then do a PUT with all that data to update the port config.

I am very new to programming and automation and have so much to learn, this would have added additional effort for me. When I found out about Mist Switch Port Operator script I figured why re invent the wheel. Why not use it and use my time and effort to learn it and customize it.
Next step was to download the script and figure out how to use it.
Script is located here and Thomas has added excellent and simple instructions. All you have to do is download the script and execute it. I did run into an issue where I had to add an environment variable to my “.zprofile”.
DJANGO_ALLOWED_HOSTS=127.0.0.1
All I had to do was point my browser to “127.0.0.1”, which brought me to the following screen:

NOTE: I couldn’t get my API token to work for some reason so I used my user ID and password to login. I’ll have to trouble shoot the API token part later on.

I am able to easily select a port or ports and make some basic changes to them.
- Enable/Disable Port
- Enable/Disable PoE
- Enable/Disable Auto-Negotiation
- Change VLAN
docker: (what took me so long)
While I was reading the instructions I noticed that there is a “docker image” available for this whole script as well. docker image sounds great but I needed to understand docker a bit more as I had no clue where and how to start and what exactly it is.
Little bit of search on the Google helped me understand the basics of “docker”. It was so easy to install on my Mac and get this script going. It almost made me say to myself, “why did I not do this before”. Just like when I first learned about using “YAML” files for some of my python scripts. Anyways all part of the learning process. I fired up this script in the docker. Found the container ID so that I can edit the files.
There is a small process you have to follow to accomplish this. Instead of me trying to explain it to everyone, I think it is best if I simply post the link. Editing Docker files.
Ok back to what I wanted to do. Notice in the image below SFP interfaces are listed top and bottom (xe-0/1/0 and xe-0/1/1). I needed them gone. Can I simply tell the script to not GET those interfaces and display them?

Looking through some files I found the “devices.py” file that I was simply able to modify and exclude those SFP(uplink) ports.

When I am done all I have to do is just close the script by hitting the stop button.

Bottom line I learned how to use this script and docker. Possibilities are endless and so much can be done using docker and this script. Much to learn here especially about django. Being able to put a UI to my scripts would be amazing. Although it was exciting to learn the basics of docker and getting this container/app running in a matter of minutes. There is certainly more to learn there.