Kirk Byers Python for Network Engineers Videos

Over the last three months I’ve been transitioning back over to network engineering. When I first started working in IT, my role was as a network technician, but slowly I took on more and more systems administration and engineering, and the work I was doing was mostly with PowerShell.

As a result, my Python skills have atrophied over the years since I was so focused on PowerShell, and if there’s one thing I’ve learned while being put in charge of managing thousands of switches, it’s that I need some scripting in place to handle mass changes.

Image result for python

The perfect class to get myself back in the Python game was from reddit, offered by Kirk Byers called “Python for Network Engineers“. It’s a introductory course on some Python basics, which for offered enough to get me going again.

I’m putting this list of the videos online for myself since I hate referencing my emails all the time, but if someone else finds it useful, awesome.

Lesson 1: Why Python, the Shell, and Strings
Lesson 2: Numbers, Files, Lists, and Linters
Lesson 3: Conditionals and Loops
Lesson 4: Dictionaries, Exceptions, and Regular Expressions
Lesson 5: Functions and the Python Debugger
Lesson 6: Netmiko
Lesson 7: Jinja2, YAML and JSON
Lesson 8: Libraries, PIP, and Virtual Environments

Lesson 1: Why Python, the Shell, and Strings

  1. Introduction 
    Video https://vimeo.com/243034300
    Length is 7 minutes
  2. Why Learn Programing?
    Video https://vimeo.com/243905715
    Length is 1 minute
  3. Why Python?
    Video https://vimeo.com/243909371
    Length is 3 minutes
  4. Python2 versus Python3
    Video https://vimeo.com/243912631
    Length is 2 minutes
  5. Characteristics of Python
    Video https://vimeo.com/243918300
    Length is 5 minutes
  6. The Python Interpreter Shell
    Video https://vimeo.com/242411259
    Length is 9 minutes
  7. IPython
    Video https://vimeo.com/242460561
    Length is 4 minutes
  8. Printing to stdout and Reading from stdin
    Video https://vimeo.com/243028886
    Length is 6 minutes
  9. Dir, Help, and Variables
    Video https://vimeo.com/243480156
    Length is 10 minutes
  10. Python Strings (Part 1)
    Video https://vimeo.com/243481392
    Length is 6 minutes
  11. Python Strings (Part 2)
    Video https://vimeo.com/243482081
    Length is 8 minutes
  12. Python Strings (Part 3)
    Video https://vimeo.com/243482871
    Length is 10 minutes
  13. Python String Formatting (Part 1)
    Video https://vimeo.com/243936489
    Length is 12 minutes
  14. Python String Formatting (Part 2)
    Video https://vimeo.com/243956669
    Length is 4 minutes

Lesson 2: Numbers, Files, Lists, and Linters

  1. Numbers
    Video https://vimeo.com/244128549
    Length is 9 minutes
  2. Files
    Video https://vimeo.com/244127459
    Length is 10 minutes
  3. Lists
    Video https://vimeo.com/244257596
    Length is 6 minutes
  4. List Slices
    Video https://vimeo.com/244259492
    Length is 4 minutes
  5. Lists are Mutable
    Video https://vimeo.com/244287000
    Length is 5 minutes
  6. Tuples
    Video https://vimeo.com/244153105
    Length is 3 minutes
  7. Using .join()
    ​Video https://vimeo.com/245464488
    Length is 3 minutes
  8. sys.argv
    Video https://vimeo.com/245464766
    Length is 2 minutes
  9. Linters
    Video https://vimeo.com/245102246
    Length is 6 minutes

Lesson 3: Conditionals and Loops

  1. Conditionals
    Video https://vimeo.com/245104620
    Length is 8 minutes
  2. Boolean Logic (Booleans, Ternary Operator, None)
    Video https://vimeo.com/245112558
    Length is 8 minutes
  3. Python For Loops
    Video https://vimeo.com/245466297
    Length is 5 minutes
  4. For Loops (Enumerate)
    Video https://vimeo.com/245477015
    Length is 6 minutes
  5. For Loops (Break and Continue)
    Video https://vimeo.com/245478016
    Length is 9 minutes
  6. While Loops
    Video https://vimeo.com/245545155
    Length is 5 minutes
  7. Loops Miscellaneous
    Video https://vimeo.com/245552604
    Length is 6 minutes

Lesson 4: Dictionaries, Exceptions, and Regular Expressions

  1. Dictionaries
    Video https://vimeo.com/246157566
    Length is 6 minutes
  2. Dictionaries Methods
    Video https://vimeo.com/246163031
    Length is 7 minutes
  3. Sets
    Video https://vimeo.com/246167477
    Length is 9 minutes
  4. Exceptions
    Video https://vimeo.com/246174686
    Length is 15 minutes
  5. Regular Expressions (Part1)
    Video https://vimeo.com/246184715
    Length is 15 minutes
  6. Regular Expressions (Part2)
    Video https://vimeo.com/246532117
    Length is 7 minutes
  7. Regular Expressions (Part3)
    Video https://vimeo.com/246534450
    Length is 8 minutes
  8. Regular Expressions, Other Methods
    Video https://vimeo.com/246535038
    Length is 4 minutes

Lesson 5: Functions and the Python Debugger

  1. Functions (Part1)
    Video link https://vimeo.com/247570174
    Length is 8 minute
  2. Functions (Part2)
    Video link https://vimeo.com/247581011
    Length is 11 minutes
  3. Misc Topics (Part1)
    Video link https://vimeo.com/247582360
    Length is 10 minutes
  4. Misc Topics (Part2)
    Video link https://vimeo.com/247655574
    Length is 8 minutes
  5. Python Debugger (pdb)
    Video link https://vimeo.com/247724017
    Length is 10 minutes

Lesson 6: Netmiko

  1. Netmiko Introduction and Basics 
    Video link https://vimeo.com/254569911
    Length is 8 minutes
  2. Netmiko Show Commands
    Video link https://vimeo.com/254578980
    Length is 13 minutes
  3. Netmiko and Prompting
    Video link https://vimeo.com/254587832
    Length is 12 minutes
  4. Netmiko and TextFSM
    Video link https://vimeo.com/254611876
    Length is 10 minutes
  5. Netmiko Config Changes
    Video link https://vimeo.com/254614073
    Length is 8 minutes
  6. Netmiko Troubleshooting
    Video link https://vimeo.com/254786724
    Length is 9 minutes

Lesson 7: Jinja2, YAML and JSON

  1. Jinja2 Basics
    Video link https://vimeo.com/257997257
    Length is 7 minutes
  2. Jinja2 For-Loops and Conditionals
    Video link https://vimeo.com/257999160
    Length is 9 minute
  3. Jinja2 and CSV
    Video link https://vimeo.com/258142987
    Length is 5 minutes
  4. Jinja2 Dictionaries and Nested Loops
    Video link https://vimeo.com/258145504
    Length is 11 minutes
  5. YAML Basics
    Video link https://vimeo.com/258161182
    Length is 9 minutes
  6. YAML Part2
    Video link https://vimeo.com/258169427
    Length is 10 minutes
  7. Using Python to Write YAML
    Video link https://vimeo.com/258171559
    Length is 3 minutes
  8. JSON
    Video link https://vimeo.com/258178243
    Length is 5 minutes
  9. Managing Data Structures
    Video link https://vimeo.com/258181273
    Length is 5 minutes

Lesson 8: Libraries, PIP, and Virtual Environments

  1. Importing Libraries
    Video link https://vimeo.com/259422351
    Length is 5 minutes
  2. sys.path and PYTHONPATH
    Video link https://vimeo.com/259423316
    Length is 7 minutes
  3. pip
    Video link https://vimeo.com/259424573
    Length is 7 minutes
  4. Virtual Environments
    Video link https://vimeo.com/259426537
    Length is 6 minutes
  5. Creating a Simple Python Module
    Video link https://vimeo.com/259427586
    Length is 4 minutes

Virtualbox VLANs in Ubuntu

Wanted to add quick note about VLANs, VirtualBox, and Ubuntu.

Virtualbox does VLANs a little differently on Ubuntu than other hypervisors. In order to get a VLANs working for a Virtualbox VM, you have to create a subinterface that is for a specific VLAN (of course, assuming your NIC supports 802.1q tagging). To create a subinterface in Ubuntu, follow the instructions here:

https://wiki.ubuntu.com/vlan

Then in Virtualbox, you set the network interface to ‘bridged mode’, then select the subinterface. Assuming your new subinterface is permanent, the VM will use that subinterface and be within that VLAN.

I’m not entirely sure how to accomplish this for Virtualbox on Windows. It would seem like you would need a separate physical interface, especially for Windows 10 and probably others.

Unrelated note: Virtualbox on Windows 10 is horrible, and so is the native Hyper-V, but that’s for another post, maybe.

Edit (20180705): A few years later, and I can honestly say VirtualBox on Windows 10 is stable now, and has been for awhile. Felt the need to update this. :-p

Skill Atrophy

One of the greatest threats to a young IT professional is skill atrophy. You work hard at developing a skill set over a given period of time, and you even go so far as to earn a certification in such a skill set — and then you quit using it.

The old appropriate is appropriate here: “Use it or lose it.”

Recently while working at a site, and much to my frustration, my skills in router and switch configuration — even just layer 2 and 3 protocols — had started to atrophy because I hadn’t touch a device in five months — then bam! I’m setting up not just layer 5-7 devices, but I’m also setting up layer 2 and 3. I’ve been working so long in the higher layers that I started to forget basics in layer 2 and 3.

 

Layer 3 Switch

 

The hard part is that it was something rather ridiculous. It was a layer 3 switch, and turned the gateway port into a routed port instead of a switched port, thinking that I would separate out a server farm from the layer 2 network that it was attached to through that port. Nothing was getting DHCP requests on this switch and it was frustrating me to no end, not to mention I had to local techs looking over my shoulder and just standing there wondering what was going on! In the end, it was by getting help from my boss and co-worker that lead me down the road to figure out what I had been doing wrong.

So how does one prevent skill atrophy? The obvious answer is to practice, but that may not always be an option, especially if you’re in an environment where the work constantly changes and you’re insanely busy (that’s my excuse at least). Perhaps doing Packet Tracer simulations — for CCNA folks like myself — would be really helpful here.

Another idea is just good documentation, even trying to take a snapshot in time to see what you were doing. Copy your configs and annotate the configs to explain what the heck you were thinking — even encouraging this at your company so that other techs, or future techs, can get an idea of what’s going on.

Asking for help is always an option, especially if you’re really stumped. Time wasted can never be taken back (it’s a sunk cost), so realizing you’re failing bad early on can help mitigate future problems. To quote Freakonomics writer Steve Levitt, “Fail quickly.” However, at the same time, realize your failure is also a learning and/or reinforcement opportunity and will make you a better IT professional.

And of course, there’s also a good IT professionals google-fu, but you should be relying on that constantly, otherwise, are you learning any of this stuff?

All this being said, I’ve learned my lesson and I’m better because of it.