Am I doing the right Python-API things? Interview with Adam Ordal from ANM Denver
"And you may ask yourself, 'Well, how did I get here?'" - Talking Heads
Like many, I am looking to automate- to get data and get faster data, because all of that means faster answers and better direction. Per one of my exec customers, “Let’s find the problems before they’re reported.” I totally agree.
To gain directions and understanding I have:
-Taken an excellent Python course from Coursera, “Python for Everybody”
-Learned to get adept at prompt engineering with ChatGPT, CoPilot and dabbled with Gemini a bit.
-Taken the great class, Cisco Programming for Network Engineers (PRNE)
-I’m looking forward to taking the Certified Wireless Network Professional (CWNP) course, Certified Python Network Administrator (CPNAE)- that great organization makes things very affordable.
-Per Adam, Python for Network Engineers https://pynet.twb-tech.com/
I’ve created some great scripts to do various things like, pull inventory across a network, look for rogues, and list clients.
Link to code, here:
https://github.com/jadexing/Merakicode/tree/main
There’s much more I want to do with scripts- but as I venture with these toolsets, how do I know I’m doing the right things? A chat with Adam Ordal from the Denver office of ANM gave me some good guidance and insight.
Here are my questions and Adam’s perspective:
What is your methodology for Python Scripts?
Adam begins by writing his code, leveraging the integration with Visual Studio Code to optimize and refine it. This integration often helps him discover new ways to enhance his code that he hadn't initially considered. Software developers who tend to integrate tools like ServiceNow, rather than write API tools for Access Points (APs). Adam's focus is more on the code itself for the functionality fix over large scale programming. Adam is a Network Engineer who has learned Python to aid his work, emphasizing the technical aspects and optimizations.
What are some best practices you recommend?
When working on scripts, it's important to avoid hardcoding anything, especially credentials. I always try to compartmentalize functions as much as possible. For example, I create a function specifically for posting data and break out the ELT process. This way, if something breaks, I don't have to troubleshoot a monolithic block of code. As scripts grow in size, I separate them into multiple files, each responsible for a specific task. I then have a main file that references these other files. This approach ensures that I don't end up with a single script trying to do everything. Instead, each script is focused on a particular function.
Are there good sites with Meraki API programming you would recommend?
You can find various resources on GitHub, and sometimes or something on developer.cisco.com or DevNet. Of course, the API guide itself is also a valuable resource.
How do I use code on GitHub? I tend to run the code through Copilot and ask what the code does.
Clone the repository and open it in Visual Studio with AI tools enabled. Once you have the project open, you can simply ask, "What does this do?" The AI tools will then crawl through the files and provide you with a detailed explanation of the code's functionality.
I need to look into regularly getting some datapoints, what are your suggestions on polling?
AWS Lambda is incredibly fast, and with its efficiency, you might not even have to pay for it. Think of Lambda as a script executor. For instance, this is a Lambda function running Python 3.12. You could use it to update a webpage and change colors—essentially hiring a robot to run tasks. It's really just a code executor.
When using Python Lambda functions, Lambda will poll, but then you need to decide what to do with the data. Do you blindly take the result and have it emailed to you, or do you store it in a database? You could use Grafana, which can use your database as a data source to display information on a webpage. This is where the art form of our job comes into play. Put on your creative hat—our work is as much about creativity as it is about technical skills.
Meraki Contribution I Found on GitHub— some people I know there:
Contributors to meraki/automation-scriptsmeraki/automation-scripts
Thanks for checking out my blog and taking this journey with me. If you have some tips on the subject, I’d love to hear them. Find me on X @jamiegprice CWNE #510