Date: Sat, 08 Jul 2017 23:00:00 -0400
<h3>Summary</h3> <p>Routers and switches are the stitches in the invisible fabric of the internet which we all rely on. Managing that hardware has traditionally been a very manual process, but the NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) is helping to change that. This week David Barroso and Mircea Ulinic explain how Python is being used to make sure that you can watch those cat videos.</p> <h3>Preface</h3> <ul> <li>Hello and welcome to Podcast.__init__, the podcast about Python and the people who make it great.</li> <li>I would like to thank everyone who supports us on <a href="https://www.pythonpodcast.com/podcastinit?utm_source=rss&utm_medium=rss">Patreon</a>. Your contributions help to make the show sustainable.</li> <li>When you’re ready to launch your next project you’ll need somewhere to deploy it. Check out Linode at <a href="https://www.pythonpodcast.com/linode?utm_source=rss&utm_medium=rss">www.podastinit.com/linode?utm_source=rss&utm_medium=rss</a> and get a $20 credit to try out their fast and reliable Linux virtual servers for running your awesome app.</li> <li>Visit the <a href="https://www.pythonpodcast.com?utm_source=rss&utm_medium=rss">site</a> to subscribe to the show, sign up for the newsletter, read the show notes, and get in touch.</li> <li>To help other people find the show please leave a review on <a href="https://itunes.apple.com/us/podcast/podcast.-init/id981834425?mt=2&uo=6&at=&ct=&utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">iTunes</a>, or <a href="https://play.google.com/music/m/I7ogju4xv6adasgqz6545jndgsy?t=Podcastinit_-_Python_and_the_people_who_make_it_great&utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Google Play Music</a>, tell your friends and co-workers, and share it on social media.</li> <li>Your host as usual is Tobias Macey and today I’m interviewing David Barroso and Mircea Ulinic about NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support), the library for managing programmable network devices</li> </ul> <h3>Interview</h3> <ul> <li>Introductions</li> <li>How did you get introduced to Python? <ul> <li>[david] 2012 trying to use django 1.4 to store data I had on confluence.</li> <li>[mircea] August 2008, when I bought the Learning Python, Mark Lutz, 2nd edition</li> </ul> </li> <li>Can you start by explaining what NAPALM is and the problem that you were solving when you started working on it? <ul> <li>[david] trying to remove all the if vendora do this, elif vendorb do this other thing instead</li> <li>[mircea] only if I will feel there’s anything to add</li> </ul> </li> <li>What led you to choose Python as the language for implementing it? <ul> <li>[david] it’s what I knew best and vendors were starting to provide libraries to interact with their platforms so python seemed like a natural evolution as we could just provide an abstraction on top of those libraries that already existed.</li> <li>[mircea] I didn’t implement NAPALM, I was fistly a user then contributor, now I’m one of the maintainers.</li> </ul> </li> <li>When working with network equipment it is easy to apply the wrong settings and bring down a large number of systems or lock yourself out entirely. Are there any tools in NAPALM to help prevent this from happening? <ul> <li>[david] We provide mechanisms to ensure proper peer reviewing; we let operators propose a configuration and get a diff. We have a rollback mechanism so if you detect an issue you can immediately rollback and we also added support to the autorollback feature some vendors have.</li> </ul> </li> <li>How have you architected the library to allow for easy integration of new classes of network devices? <ul> <li>[david] very simple architecture. Trying to avoid complex features like abstract classes, metaprogramming or decorators. Main reason is that I figured my main user base wasn’t going to be very python savvy so I wanted something simple. What I ended doing was simulating interfaces with with a base class that described the supported methods and how they were supposed to behave and an extensive testing framework that ensure the method signatures and the behaviors matched the expectations.</li> </ul> </li> <li>Designing and building a consistent API for such a wide variety of hardware and software platforms is a daunting task. How do you determine the lowest common set of functionality that you are going to expose as part of the core library vs delegating to the underlying dependencies? <ul> <li>[david] We don’t necessarily go with the lowest common denominator. Sometimes we try to emulate features. For example, if a platform doesn’t support atomic changes we might simulate it by trying to send the configuration as a block and rollback immediately. Obviously a feature likes this is clearly documented so people is aware that this might happen. What we try to avoid though is implementing things that are very specific to a single vendor. In any case the way it has worked so far falls into two categories:</li> </ul> <ol> <li>configuration management. These are primitives like loading a candidate configuration for merging or replacing into the device, getting a diff back, commiting, discarding or rolling back configuration. These primitives were designed at the very begining of the project based on the netconf protocol and they have changed very little since then. When a primitive is not natively supported by a device we try to emulate it as with the atomicity example I gave before or we don’t implement it at all if it’s not possible.</li> <li>The second category is what we call getters which are methods that retrieve information from the devices. Things like interface counters, bgp neighbors, etc. These are basically community driven. Someone opens an issue on github explaining the data that he or she needs, we discuss it, we define a model and then we work on it. Not all getters are supported on all platforms. People mostly implements them as they need.<br /> Now there is a third category though. It is actually funny but I presented napalm for the first time a couple of years ago at NANOG64. It turns out the day after, at the same venue, Google was presenting Openconfig. Openconfig is an effort to design a common set of models to operate the network. So, for example, they have models for BGP neighbors, for interfaces, vlans, etc… Those models try to be vendor agnostic and you should, in theory, be able to use them to configure or to retrieve consistently information from any device. Problem is that, of course, vendors are slow implementing them, they don’t even have plans for all of them or for all the platforms, etc… So the sad truth is that two years later support for Openconfig is extremely limited. However, in the last few months I have been working on integrating napalm with opencofig so now we have a beta version of napalm where you can use python bindings that can translate native data from a device into an Openconfig object and viceversa. That has two direct implications:</p> <ol> <li>Now we are not only operating all vendors with the same tool but we are also operating them with the same data structures. This means that I can get the configuration of a cisco device and translate it directly to junos configuration.</li> <li>It also means that because now we are dealing with objects, I can do smart things like having an object that represents the candidate configuration, anotther object that represents a certain running state and simulate merges myself without having to rely on the device itself. I can even generate the exact commands to do the merge without having to rely on them doing the actual merge. I can also simulate the changes offline, I don’t even need access to the device anymore, I could be builting the objects from a backup or from the resulting configuration after merging different branches on github.</li> </ol> </li> </ol> </li> <li>I have seen a few posts recently discussing the use of NAPALM in conjunction with configuration management platforms such as SaltStack and Ansible. What are the tradeoffs of using the library directly vs integrated with these other tools? <ul> <li>[david] napalm is a library in the strict sense. There is no business logic, no workflows, very little tooling embedded. Instead we try to implement as many primitives and be as flexible as possible so other tools can leverage on napalm to implement their workflows. What this means is that using napalm directly is great if you are writing a script to do backups or to solve a specific issue but if you want to build a whole framework for event driven automation or a configuration management system you are probably better off leveraging on napalm integration with salt/ansible/st2.</li> </ul> </li> <li>I noticed in the documentation that merging configuration is supported. How do you manage conflicts and priority of nested data structures? <ul> <li>[david] we try to make changes atomic. So if you make a change and trigger a conflict or you are missing some datastructure or some configuration is invalid configuration won’t be applied and the user will get an error. For platforms where changes can’t be atomic we try to apply the configuration changes in bulk and revert immediately if there is an error.</li> </ul> </li> <li>How does declarative modeling of network devices differ from general purpose operating systems and what unique challenges do they pose? <ul> <li>[david] lack of tooling like sed/awk/etc. Lots of state. Configuration is state itself and in most cases you can’t even reload it. Which means you have to type the exact commands to go from state a to state b. Like trying to configure the network stack of linux with only the iproute2 tooling available.</li> </ul> </li> <li>What are the most technically challenging aspects of managing different network hardware programmatically? <ul> <li>[david] Inconsistencies and buggy code. Not even inconsistencies across different platforms but across minor revisions of the same platforms. Small API changes that are not backwards compatible, small differences on output commands that break regular expressions and APIs that break every second call.</li> </ul> </li> <li>What are some of the most interesting or unusual uses of NAPALM that you have seen? <ul> <li>[david]</li> </ul> <ol> <li>I have seen people replacing their SNMP based monitoring system with napalm.</li> <li>I have built myself what you could call “immutable infrastructure for the network”. So for example, when you have to do a configuration change you don’t apply that configuration change. What you do instead is compile a full configuration for the device and fully reload the state of the device. That ensures you are always into a known state. So if a user would connect to the device and do a change outside the change control system because you are fully deploying state you can be certain that the manual change will be wipeout. So there is no way out of the automation.</li> <li>We also have this <code>validate</code> functionality integrated into napalm. With this functionality you can define a desired state, for example certain BGP neighbors have to be up and I must be receiving N prefixes from them. Napalm can then read those rules, figure out which data to retrieve and validate the data retrieved complies so I know some people using this state validation instead of using the traditional times series type of monitoring where you keep retrieving data constantly and alerting when you reach certain thresholds. I guess you could call this test driven monitoring?</li> </ol> <ul> <li>[mircea]</li> </ul> <ol> <li>SNMP thing</li> </ol> </li> <li>For someone who is interested in learning more about network management, what resources do you recommend? <ul> <li>[david]</li> </ul> <ol> <li>networktocode.com has some resources, labs, the slack community behing the organization is very active as well.</li> <li>ipspace.com has some good resources as well.</li> <li>pynet.twb-tech.com is also another great place to check for courses</li> <li>o’reilly has a book on Network Programmability and Automation which I haven’t read but I know the authors are very good so I am confident the content will be of high quality.</li> </ol> <ul> <li>[mircea]</li> </ul> <ol> <li>I blog about NAPALM & generally networking and network automation on my personal space: mirceaulinic.net</li> <li>packetpushers.net</li> </ol> </li> </ul> <h3>Keep In Touch</h3> <ul> <li>David <ul> <li>@dbarrosop on <a href="https://linkedin.com/in/dbarrosop?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">LinkedIn</a>, <a href="https://github.com/dbarrosop?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">GitHub</a> and <a href="https://twitter.com/dbarrosop?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Twitter</a></li> <li><a href="https://www.dravetech.com?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Blog</a></li> </ul> </li> <li>Mircea <ul> <li><a href="https://www.mirceaulinic.net?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Blog</a></li> <li>@mirceaulinic on <a href="https://linkedin.com/in/mirceaulinic?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">LinkedIn</a>, <a href="https://github.com/mirceaulinic?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">GitHub</a> and <a href="https://twitter.com/mirceaulinic?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Twitter</a></li> </ul> </li> <li>NAPALM <ul> <li><a href="https://twitter.com/napalm_auto?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">@napalmauto</a> on Twitter</li> <li><a href="https://napalm.readthedocs.io/en/latest/index.html#?utmsource=rss&utmmedium=rss" rel="noopener" target="blank">Documentation</a></li> </ul> </li> </ul> <h3>Picks</h3> <ul> <li>Tobias <ul> <li><a href="https://www.ietf.org/rfc/rfc1925.txt?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">The Twelve Networking Truths</a></li> <li><a href="http://blog.erratasec.com/2012/06/falsehoods-programmers-believe-about.html#.WVt2x3WQxhE?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Falsehoods Programmers Believe About Networking</a></li> </ul> </li> <li>David <ul> <li><a href="http://www.thefearsaga.com/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">The fear saga</a></li> <li><a href="https://en.wikipedia.org/wiki/Virtual_reality?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">VR</a></li> </ul> </li> <li>Mircea <ul> <li><a href="https://twitter.com/dailyzen?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Daily Zen</a></li> </ul> </li> </ul> <h3>Links</h3> <ul> <li><a href="https://www.juniper.net/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Juniper</a></li> <li><a href="https://www.arista.com/en/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Arista</a></li> <li><a href="http://www.paramiko.org/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Paramiko</a></li> <li><a href="https://github.com/ktbyers/netmiko?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">netmiko</a></li> <li><a href="https://en.wikipedia.org/wiki/Cisco_IOS?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Cisco IOS</a></li> <li><a href="https://www.vagrantup.com/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Vagrant</a></li> <li><a href="https://tools.ietf.org/html/rfc6241?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Netconf Protocol</a></li> <li><a href="https://tools.ietf.org/html/rfc4271?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">BGP</a></li> <li><a href="https://tools.ietf.org/html/rfc1247?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">OSPF</a></li> <li><a href="https://tools.ietf.org/html/rfc1157?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">SNMP</a></li> <li><a href="https://tools.ietf.org/html/rfc7414?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">TCP</a></li> <li><a href="https://en.wikipedia.org/wiki/Internet_Protocol?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">IP</a></li> <li><a href="https://blog.digitalocean.com/zero-touch-provisioning-how-to-build-a-network-without-touching-anything/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">ZTP (Zero Touch Provisioning)</a></li> <li><a href="https://en.wikipedia.org/wiki/Preboot_Execution_Environment?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">PXE (Preboot eXecution Environment) Boot</a></li> <li><a href="https://saltstack.com/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">SaltStack</a></li> <li><a href="https://www.ansible.com/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Ansible</a></li> <li><a href="https://stackstorm.com/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">StackStorm</a></li> <li><a href="https://trigger.readthedocs.io/en/latest/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Trigger</a></li> <li><a href="https://github.com/napalm-automation/napalm-logs?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">NAPALM Logs</a></li> <li><a href="http://www.openconfig.net/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">OpenConfig</a></li> <li><a href="https://www.nanog.org/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">NANOG</a></li> <li><a href="https://tools.ietf.org/html/rfc6020?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">YANG</a></li> <li><a href="https://en.wikipedia.org/wiki/Forwarding_plane?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">Data Plane</a></li> <li><a href="https://en.wikipedia.org/wiki/Network_Time_Protocol?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">NTP(network time protocol)</a></li> <li><a href="https://en.wikipedia.org/wiki/Secure_Shell?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">SSH</a></li> <li>Networking Resources <ul> <li><a href="http://packetpushers.net/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">PacketPushers.net</a></li> <li><a href="http://amzn.to/2tVoMsf?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">O’Reilly – Network Programmability and Automation</a></li> <li><a href="http://networktocode.com/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">networktocode.com</a></li> <li><a href="https://www.ipspace.net/Main_Page?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">ipspace.net</a></li> <li><a href="https://pynet.twb-tech.com/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">pynet.twb-tech.com</a></li> </ul> </li> </ul> <p>The intro and outro music is from Requiem for a Fish <a href="http://freemusicarchive.org/music/The_Freak_Fandango_Orchestra/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">The Freak Fandango Orchestra</a> / <a href="http://creativecommons.org/licenses/by-sa/3.0/?utm_source=rss&utm_medium=rss" rel="noopener" target="_blank">CC BY-SA</a><img alt="" height="0" src="https://analytics.boundlessnotions.com/piwik.php?idsite=1&rec=1&url=https%3A%2F%2Fwww.pythonpodcast.com%2Fnapalm-with-david-barosso-and-mircea-ulinic-episode-117%2F&action_name=NAPALM+with+David+Barroso+and+Mircea+Ulinic+-+Episode+117&urlref=https%3A%2F%2Fwww.pythonpodcast.com%2Ffeed%2F&utm_source=rss&utm_medium=rss" style="border: 0; width: 0; height: 0;" width="0" /></p>