Mais conteúdo relacionado Semelhante a Python for Network Engineers - A Practical Guide for Getting Started (20) Mais de Jeremy Schulman (6) Python for Network Engineers - A Practical Guide for Getting Started1. © Jeremy Schulman - 2018 - All Rights Reserved
Python for Network Engineers
Chapter 1
A Practical Guide for Getting Started
Jeremy Schulman
@nwkautomaniac
2. © Jeremy Schulman - 2018 - All Rights Reserved
Jeremy Schulman
● Software Engineer
● 20 Years in Industry
● Since 2012 exclusively focused
on "network automation"
● Other Roles:
○ Developer Advocate
○ Systems Engineer
○ Automation Architect
○ Open source contributor
@nwkautomaniac
Slides:
https://www.slideshare.net/
jeremyschulman
Github:
https://github.com/
jeremyschulman
3. © Jeremy Schulman - 2018 - All Rights Reserved
Obligatory Disclaimer
The views and opinions expressed in this presentation are Jeremy Schulman's and do not represent
any employer past or present.
Reference materials provided in this presentation, such as links to external training sites, do not
represent any form of recommendation.
4. © Jeremy Schulman - 2018 - All Rights Reserved
Network Engineers need to
competently use Python
so that they can make, and make use of,
power-tools that will improve their jobs.
These tools will not replace them.
5. © Jeremy Schulman - 2018 - All Rights Reserved
Agenda
● Discussion
○ Realistic expectations
○ Getting started
● Live coding
○ Jupyter Notebook - makes Python feel like a CLI
○ NetOps example exercises
● Where to go from here ...
6. © Jeremy Schulman - 2018 - All Rights Reserved
"Manual via CLI"
"SNMP based products"
"Vendor Products"
"SDN"
"Orchestration Systems"
"DevOps"
"Network Automation"
"Network Engineers
must become Software
Engineers"
Managing Networks
7. © Jeremy Schulman - 2018 - All Rights Reserved
"Manual via CLI"
"SNMP based products"
"Vendor Products"
"SDN"
"Orchestration Systems"
"DevOps"
"Network Automation"
"Network Engineers
must become Software
Engineers"
Managing Networks
8. © Jeremy Schulman - 2018 - All Rights Reserved
Learning any New Skill [1]
Novice Expert MasterCompetent Proficient
Experience over a long time
● Use everyday concrete experiences,
not abstract concepts
● Attaining core competency requires
instructor led training and / or
directed tutorials
Jeremy's key takeaways:
● Attaining proficient skill requires
experience and knowledge
that takes massive time investment
● Continuous mentorship, peer-review,
feedback, learning, experimentation
9. © Jeremy Schulman - 2018 - All Rights Reserved
Systems are Risky and Complex
Manage Distributed Network Services
High Risk
Complex
Tasks
Low Risk
Simple
Tasks
Configuration
Management
“config”
Situational
Awareness
“show”
Host-Only
(blast radius = 1)
Distributed System
(blast radius > 1)
10. © Jeremy Schulman - 2018 - All Rights Reserved
Where to start using Python
High Risk
Complex
Tasks
Low Risk
Simple
Tasks
Configuration
Management
“config”
Situational
Awareness
“show”
Host-Only
(blast radius = 1)
Distributed System
(blast radius > 1)
"Your network is a crime scene, and you
are the detective. You need better ways
to investigate what happened, and prove
guilt or innocence".
-- Jeremy
11. © Jeremy Schulman - 2018 - All Rights Reserved
Live Coding
Make Python *feel* like being on a CLI
http://jupyter.org/
12. © Jeremy Schulman - 2018 - All Rights Reserved
Jupyter Notebook
$ virtualenv playground
$ source playground/bin/activate
(playground)$ pip install ipython==5 jupyter
Setup a Python virtual-environment
(playground)$ pip install jupyter
Install Jupyter notebook for Python 2.7
Install Jupyter notebook for Python 3
13. © Jeremy Schulman - 2018 - All Rights Reserved
Jupyter Notebook
(playground)$ jupyter notebook
Start Jupyter notebook system, will launch browser
14. © Jeremy Schulman - 2018 - All Rights Reserved
Novice Topics
● Variables, duck-typing
● help(), type(), dir()
● pretty-printing
● Importing packages
● List, Dictionary
● Tuple, Set
● Functions
● For-loops
● If / Then / Else
● Working with files
● JSON, YAML files
● List Comprehensions
● Dictionary Comprehensions
● Set Comprehensions
● Collections - Counter
● Collections - defaultdict
15. © Jeremy Schulman - 2018 - All Rights Reserved
Python Libraries
● ipaddress
● tabulate
● first
● tqdm
● requests
● collections
● csv
● json
● yaml
● gtextfsm
● netmiko
● napalm
● lxml
● paramiko
● bidict
● operator
● itertools
● chain
16. © Jeremy Schulman - 2018 - All Rights Reserved
NetOps Examples
1. Use NAPALM drivers to execute device-specific CLI commands
a. Arista EOS
b. Cisco NX-OS
2. Process IP routing table information
3. Process LLDP neighbor information
4. Process Interface information
17. © Jeremy Schulman - 2018 - All Rights Reserved
Next Steps
● Take formal Python courses
● Global Knowledge
● Subscribe to Python News
○ Dan Bader
○ https://www.pythonweekly.com/
● https://www.python.org/
● Try PyCharm IDE
(Integrated Development Environment)
● Use Python every day
● Use Jupyter notebook
● Take industry classes
○ IpSpace
○ NetworkToCode
○ Kirk Byers
● Free Cisco DevNet
Building Novice Skills Building Competency
18. © Jeremy Schulman - 2018 - All Rights Reserved
Closing Thoughts
"A good network engineer is proficient at
quickly becoming competent."
-- Derick Winkworth (@cloudtoad)
● Be patient. Set realistic goals, both with yourself and
your management
● Consider how long it took you to become a Senior
Network Engineer
19. © Jeremy Schulman - 2018 - All Rights Reserved
Cheers!
Jeremy Schulman
@nwkautomaniac