SlideShare a Scribd company logo
1 of 21
JUNOS
AUTOMATION
INTRO
DAVID MCKAY
@DAVIDMCKAYV
OFFICE OF THE
NETWORK ENGINEER
• I am not a "Programmer"
• I think about the network & complex networking planning
• I spend a lot of my time fire-fighting the network
• I need automation tools to help me do my job
• I know I need to "level-up" with automation but I need something that helps me get started
• I’d like to use Python since it is shaping up as the standard
THINKING LIKE A
PROGRAMMER
• You do *not* have to be a programmer to be successful in automation.
• In the most simple of terms, programming is the manipulation of data.
• You already know the core concepts of data types and how to manipulate
them, the missing link is the language.
THIS LOOKS FAMILIAR,
BUT WHAT THE HELL IS
GOING ON
IT'S SHOWTIME
BECAUSE I'M GOING TO SAY PLEASE a
TALK TO THE HAND "a is true"
BULLSHIT
TALK TO THE HAND "a is not true"
YOU HAVE NO RESPECT FOR LOGIC
YOU HAVE BEEN TERMINATED
ArnoldC
https://github.com/lha
rtikk/ArnoldC
PYEZ – A LAYERED
APPROACH
Python Shell Python script
IT
Frameworks
Custom
Applications
ncclient
junos-pyez
• Junos specific
• Abstraction Layer
• micro-framework
• NETCONF transport only
• Vendor Agnostic
• No abstractions
• Native Python data types (hash/list)
• Junos specific not required
• XML not required
open-source, Juniper
open-source, Community
interactive simple → complex
INTRO
JunOS has a number of automation options available
• Ansible, www.ansible.com
• Chef, www.chef.io/chef/
• Puppet, www.puppetlabs.com
• Salt, www.saltstack.com
Today we will focus on pyez, www.github.com/Juniper/py-
junos-eznc
• A python library to directly interact with a device’s API via
netconf over SSH
• The JunOS API is primarily XML driven, pyez simplifies
that
INSTALL PYTHON
FRAMEWORK
Install pip
• Type ‘easy_install pip’
• easy_install assumes your system has python on it
• If not, please install python first
• www.python.org
Install the JunOS python framework
• Type ‘pip install junos-eznc’
Optionally install ipython
• Type ‘pip install ipython’
• ipython provides a better python shell than standard python
• This shell is what will be used in this deck
SETUP YOUR DEVICE
JunOS’s API is accessed via SSH and netconf
• Login to your Juniper device
• Type ‘set system services netconf ssh’
• Type ‘commit’
• This will open TCP port 830
• This will need to be done on all devices that want to
participate in automation via netconf
SETUP DEVICE
CONNECTION
We need to open a connection to our device, all scripts or
interactions via the shell will need to use the Device object and
call open() before we do anything
• Type ‘python’ or ‘ipython’ to enter the interactive shell
• Type ‘from jnpr.junos import Device’
• We need to import a class Device, to access to code for
connecting
• Type ‘myDev = Device('192.168.212.129', user='dave',
password='juniper123’)’
• myDev is now our connection variable
• Type ‘myDev.open()’
• If you get a connection error, check your username and
password
• Also check that TCP port 830 is open on your device
MORE SECURE WAY
TO CONNECT
Typing out a plain text password isn’t ideal for a shell or a script,
so we can set it as a local environment variable and call it that
way
• Before starting the python shell (or script) type ‘export
MYSSHPW=“yourSSHPass”’
• This assumes you are using Bash for your shell
• Now we setup the connection like we previously did
• Type ‘python’ or ‘ipython’ to enter the interactive shell
• Type ‘from jnpr.junos import Device’
• Type ‘import os’
• Type ‘sshpass = os.environ['MYSSHPW']’
• This assigns the variable “sshpass” to your ssh password
• Type ‘myDev = Device('192.168.212.129', user='dave',
password=sshpass)’
• Type ‘myDev.open()’
SETUP CONNECTION
VIA SSH KEY
If you want to use an SSH key to login to the device, that is
also possible
• Before starting the python shell (or script) type ‘export
MYSSHPW=“yourSSHPass”’
• This assumes you are using Bash for your shell
• Now we setup the connection like we previously did
• Type ‘python’ or ‘ipython’ to enter the interactive shell
• Type ‘from jnpr.junos import Device’
• Type ‘sshpass = os.environ['MYSSHPW']’
• This assigns the variable “pass” to your ssh password
• Type ‘myDev = Device('192.168.212.129', user='dave',
password=sshpass),
ssh_private_key_file='/home/dave/.ssh/id_rsa'’
• Type ‘myDev.open()’
CHECK SOME FACTS
Now that we have a good connection open let’s see some
device attributes
• Type ‘from pprint import pprint’
• We want a “pretty print” option for printing out our
attributes
• Type ‘pprint( myDev.facts )’
• This should output a python dictionary of device attributes
• But maybe we want to get a specific fact, like a serial
• In this case we use key -> value to grab it
• Type ‘pprint ( myDev.facts['serialnumber'] )’
• This is using our myDev.facts dictionary and calling
the key “serialnumber” to get the serial number’s
value
REFRESH AND CHECK
Some attributes may change like system uptime
• We can refresh the device facts by asking for an update
• Type ‘myDev.facts_refresh()’
• Now we can see if anything has changed
• For instance, the uptime should have incremented
• Type ‘pprint ( myDev.facts['RE0']['up_time'] )’
• Note here that we are accessing a dictionary within a
dictionary
• We are asking for the RE0 key inside our
myDev.facts dict and the up_time key inside of
the RE0 dict
LOOK AT THE
INTERFACES
Perhaps we want to check into our ethernet interfaces
• Type the following block of code:
• This should give you a dictionary of all of your interfaces
and associated attributes
from jnpr.junos.op.ethport import EthPortTable
eths = EthPortTable(myDev)
eths.get()
x = 0
while x < len(eths):
print "Interface: " + eths.keys()[x] + " Information"
print eths[x].items()
x += 1
A BETTER INTERFACE
LIST
This will give a printout of all ethernet interfaces on a device,
whether or not they are up, the corresponding mac address
and duplex setting
from jnpr.junos.op.ethport import EthPortTable
eths = EthPortTable(myDev)
eths.get()
x = 0
while x < len(eths):
print "Interface {} is {}, MAC: {}, Link Mode: {}".format(eths.keys()[x], 
eths[x].oper, eths[x].macaddr, eths[x].link_mode )
x += 1
LOOKING AT THE
ROUTE TABLE
Check out the routing table, but do note, this could be very
memory intensive for tables with huge numbers of routes
from jnpr.junos.op.routes import RouteTable
routes = RouteTable(myDev)
routes.get()
r = 0
while r < len(routes):
print "Route: {}, via interface: {}, protocol: {}".format(routes.keys()[r], 
routes[r].via, routes[r].protocol)
r += 1
UPDATING A CONFIG
TUTORIAL
• https://pynet.twb-tech.com/blog/juniper/juniper-pyez.html
• https://pynet.twb-tech.com/blog/juniper/juniper-pyez-
commit.html
ADVANCED
TECHNIQUES
• Jinja2
• Smart templating system
• SLAX
• On board scripts
• http://www.juniper.net/techpubs/en_US/junos-
pyez1.0/topics/task/program/junos-pyez-program-
configuration-data-loading.html
• JunOS 14.2
• REST API
BONUS - ZTP
• ZTP or Zero-Touch Provisioning allows you to setup a
device without every logging in.
• ZTP utilizes DHCP and (T)FTP/HTTP. With these it can
upgrade code and/or add a configuration to a device.
• ZTP is enabled by default on JUNOS from the factory or
via ‘request system zeroize’.
• ZTP requires DHCP option 43 to be set and serves a
number of suboptions.
• http://www.juniper.net/techpubs/en_US/junos13.3/topics/ta
sk/configuration/software-image-and-configuration-
automatic-provisioning-confguring.html
SUBOPTIONS
• 00 - name of the software image file to install
• 01 - name of the configuration file to install
• 03 - transfer mode (ftp, tftp, http)
NEXT STEPS
• Learn Python
• http://www.codecademy.com/tracks/python
• Juniper Python framework
• https://github.com/Juniper/py-junos-eznc
• Multi-vendor network API abstraction framework
• https://github.com/spotify/napalm
• Zero-Touch Provisioning
• http://www.juniper.net/techpubs/en_US/junos13.2/topics/to
pic-map/ztp-overview-els.html

More Related Content

What's hot

10 minutes fun with Cloud API comparison
10 minutes fun with Cloud API comparison10 minutes fun with Cloud API comparison
10 minutes fun with Cloud API comparisonLaurent Cerveau
 
Play concurrency
Play concurrencyPlay concurrency
Play concurrencyJustin Long
 
Zabbix visión general del sistema - 04.12.2013
Zabbix   visión general del sistema - 04.12.2013Zabbix   visión general del sistema - 04.12.2013
Zabbix visión general del sistema - 04.12.2013Emmanuel Arias
 
Windows Configuration Management: Managing Packages, Services, & Power Shell-...
Windows Configuration Management: Managing Packages, Services, & Power Shell-...Windows Configuration Management: Managing Packages, Services, & Power Shell-...
Windows Configuration Management: Managing Packages, Services, & Power Shell-...Puppet
 
Splunk Modular Inputs / JMS Messaging Module Input
Splunk Modular Inputs / JMS Messaging Module InputSplunk Modular Inputs / JMS Messaging Module Input
Splunk Modular Inputs / JMS Messaging Module InputDamien Dallimore
 
London Hashicorp Meetup #22 - Congruent infrastructure @zopa by Ben Coughlan
London Hashicorp Meetup #22 - Congruent infrastructure @zopa by Ben CoughlanLondon Hashicorp Meetup #22 - Congruent infrastructure @zopa by Ben Coughlan
London Hashicorp Meetup #22 - Congruent infrastructure @zopa by Ben CoughlanBen Coughlan
 
Creating pools of Virtual Machines - ApacheCon NA 2013
Creating pools of Virtual Machines - ApacheCon NA 2013Creating pools of Virtual Machines - ApacheCon NA 2013
Creating pools of Virtual Machines - ApacheCon NA 2013Andrei Savu
 
Puppet Release Workflows at Jive Software
Puppet Release Workflows at Jive SoftwarePuppet Release Workflows at Jive Software
Puppet Release Workflows at Jive SoftwarePuppet
 
Puppet Camp Denver 2015: Nagios Management With Puppet
Puppet Camp Denver 2015: Nagios Management With PuppetPuppet Camp Denver 2015: Nagios Management With Puppet
Puppet Camp Denver 2015: Nagios Management With PuppetPuppet
 
Vladimir Ulogov - Large Scale Simulation | ZabConf2016 Lightning Talk
Vladimir Ulogov - Large Scale Simulation | ZabConf2016 Lightning TalkVladimir Ulogov - Large Scale Simulation | ZabConf2016 Lightning Talk
Vladimir Ulogov - Large Scale Simulation | ZabConf2016 Lightning TalkZabbix
 
Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture AppDynamics
 
Nagios XI Best Practices
Nagios XI Best PracticesNagios XI Best Practices
Nagios XI Best PracticesNagios
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsGary Yeh
 
Monitoring Oracle SOA Suite - UKOUG Tech15 2015
Monitoring Oracle SOA Suite - UKOUG Tech15 2015Monitoring Oracle SOA Suite - UKOUG Tech15 2015
Monitoring Oracle SOA Suite - UKOUG Tech15 2015C2B2 Consulting
 
Nagios, Getting Started.
Nagios, Getting Started.Nagios, Getting Started.
Nagios, Getting Started.Hitesh Bhatia
 
Elements for an iOS Backend
Elements for an iOS BackendElements for an iOS Backend
Elements for an iOS BackendLaurent Cerveau
 
Podila mesos con-northamerica_sep2017
Podila mesos con-northamerica_sep2017Podila mesos con-northamerica_sep2017
Podila mesos con-northamerica_sep2017Sharma Podila
 
Nagios Conference 2011 - Nate Broderick - Nagios XI Large Implementation Tips...
Nagios Conference 2011 - Nate Broderick - Nagios XI Large Implementation Tips...Nagios Conference 2011 - Nate Broderick - Nagios XI Large Implementation Tips...
Nagios Conference 2011 - Nate Broderick - Nagios XI Large Implementation Tips...Nagios
 
Puppet Camp Melbourne 2014:
Puppet Camp Melbourne 2014: Puppet Camp Melbourne 2014:
Puppet Camp Melbourne 2014: Puppet
 

What's hot (20)

10 minutes fun with Cloud API comparison
10 minutes fun with Cloud API comparison10 minutes fun with Cloud API comparison
10 minutes fun with Cloud API comparison
 
Play concurrency
Play concurrencyPlay concurrency
Play concurrency
 
Zabbix visión general del sistema - 04.12.2013
Zabbix   visión general del sistema - 04.12.2013Zabbix   visión general del sistema - 04.12.2013
Zabbix visión general del sistema - 04.12.2013
 
Windows Configuration Management: Managing Packages, Services, & Power Shell-...
Windows Configuration Management: Managing Packages, Services, & Power Shell-...Windows Configuration Management: Managing Packages, Services, & Power Shell-...
Windows Configuration Management: Managing Packages, Services, & Power Shell-...
 
Splunk Modular Inputs / JMS Messaging Module Input
Splunk Modular Inputs / JMS Messaging Module InputSplunk Modular Inputs / JMS Messaging Module Input
Splunk Modular Inputs / JMS Messaging Module Input
 
London Hashicorp Meetup #22 - Congruent infrastructure @zopa by Ben Coughlan
London Hashicorp Meetup #22 - Congruent infrastructure @zopa by Ben CoughlanLondon Hashicorp Meetup #22 - Congruent infrastructure @zopa by Ben Coughlan
London Hashicorp Meetup #22 - Congruent infrastructure @zopa by Ben Coughlan
 
Creating pools of Virtual Machines - ApacheCon NA 2013
Creating pools of Virtual Machines - ApacheCon NA 2013Creating pools of Virtual Machines - ApacheCon NA 2013
Creating pools of Virtual Machines - ApacheCon NA 2013
 
Puppet Release Workflows at Jive Software
Puppet Release Workflows at Jive SoftwarePuppet Release Workflows at Jive Software
Puppet Release Workflows at Jive Software
 
Puppet Camp Denver 2015: Nagios Management With Puppet
Puppet Camp Denver 2015: Nagios Management With PuppetPuppet Camp Denver 2015: Nagios Management With Puppet
Puppet Camp Denver 2015: Nagios Management With Puppet
 
Vladimir Ulogov - Large Scale Simulation | ZabConf2016 Lightning Talk
Vladimir Ulogov - Large Scale Simulation | ZabConf2016 Lightning TalkVladimir Ulogov - Large Scale Simulation | ZabConf2016 Lightning Talk
Vladimir Ulogov - Large Scale Simulation | ZabConf2016 Lightning Talk
 
Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture
 
Nagios XI Best Practices
Nagios XI Best PracticesNagios XI Best Practices
Nagios XI Best Practices
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
 
Monitoring Oracle SOA Suite - UKOUG Tech15 2015
Monitoring Oracle SOA Suite - UKOUG Tech15 2015Monitoring Oracle SOA Suite - UKOUG Tech15 2015
Monitoring Oracle SOA Suite - UKOUG Tech15 2015
 
Nagios, Getting Started.
Nagios, Getting Started.Nagios, Getting Started.
Nagios, Getting Started.
 
Elements for an iOS Backend
Elements for an iOS BackendElements for an iOS Backend
Elements for an iOS Backend
 
Podila mesos con-northamerica_sep2017
Podila mesos con-northamerica_sep2017Podila mesos con-northamerica_sep2017
Podila mesos con-northamerica_sep2017
 
Nagios Conference 2011 - Nate Broderick - Nagios XI Large Implementation Tips...
Nagios Conference 2011 - Nate Broderick - Nagios XI Large Implementation Tips...Nagios Conference 2011 - Nate Broderick - Nagios XI Large Implementation Tips...
Nagios Conference 2011 - Nate Broderick - Nagios XI Large Implementation Tips...
 
JustLetMeCode-Final
JustLetMeCode-FinalJustLetMeCode-Final
JustLetMeCode-Final
 
Puppet Camp Melbourne 2014:
Puppet Camp Melbourne 2014: Puppet Camp Melbourne 2014:
Puppet Camp Melbourne 2014:
 

Similar to Automation intro

Python for the Network Nerd
Python for the Network NerdPython for the Network Nerd
Python for the Network NerdMatt Bynum
 
Managing Large-scale Networks with Trigger
Managing Large-scale Networks with TriggerManaging Large-scale Networks with Trigger
Managing Large-scale Networks with Triggerjathanism
 
How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to productionSean Hess
 
Who pulls the strings?
Who pulls the strings?Who pulls the strings?
Who pulls the strings?Ronny
 
Internet of things the salesforce lego machine cloud
Internet of things   the salesforce lego machine cloudInternet of things   the salesforce lego machine cloud
Internet of things the salesforce lego machine cloudandyinthecloud
 
DeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel EdisonDeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel EdisonGabriel Arnautu
 
Puppet for Developers
Puppet for DevelopersPuppet for Developers
Puppet for Developerssagarhere4u
 
Puppet Camp Boston 2014: Keynote
Puppet Camp Boston 2014: Keynote Puppet Camp Boston 2014: Keynote
Puppet Camp Boston 2014: Keynote Puppet
 
OSX Pirrit : Why you should care about malicious mac adware
OSX Pirrit : Why you should care about malicious mac adwareOSX Pirrit : Why you should care about malicious mac adware
OSX Pirrit : Why you should care about malicious mac adwarePriyanka Aash
 
Python and Oracle : allies for best of data management
Python and Oracle : allies for best of data managementPython and Oracle : allies for best of data management
Python and Oracle : allies for best of data managementLaurent Leturgez
 
E yantra robot abstractions
E yantra robot abstractionsE yantra robot abstractions
E yantra robot abstractionsAkshar Desai
 
Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'Jen Andre
 
Simplifying openstack instances networking
Simplifying openstack instances networkingSimplifying openstack instances networking
Simplifying openstack instances networkingMohamed ELMesseiry
 
Automating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleAutomating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleBrian Hogan
 
Devnet 1005 Getting Started with OpenStack
Devnet 1005 Getting Started with OpenStackDevnet 1005 Getting Started with OpenStack
Devnet 1005 Getting Started with OpenStackCisco DevNet
 

Similar to Automation intro (20)

Python for the Network Nerd
Python for the Network NerdPython for the Network Nerd
Python for the Network Nerd
 
Managing Large-scale Networks with Trigger
Managing Large-scale Networks with TriggerManaging Large-scale Networks with Trigger
Managing Large-scale Networks with Trigger
 
How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to production
 
Who pulls the strings?
Who pulls the strings?Who pulls the strings?
Who pulls the strings?
 
Java sockets
Java socketsJava sockets
Java sockets
 
Internet of things the salesforce lego machine cloud
Internet of things   the salesforce lego machine cloudInternet of things   the salesforce lego machine cloud
Internet of things the salesforce lego machine cloud
 
DeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel EdisonDeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel Edison
 
Puppet for Developers
Puppet for DevelopersPuppet for Developers
Puppet for Developers
 
Puppet Camp Boston 2014: Keynote
Puppet Camp Boston 2014: Keynote Puppet Camp Boston 2014: Keynote
Puppet Camp Boston 2014: Keynote
 
OSX Pirrit : Why you should care about malicious mac adware
OSX Pirrit : Why you should care about malicious mac adwareOSX Pirrit : Why you should care about malicious mac adware
OSX Pirrit : Why you should care about malicious mac adware
 
Python and Oracle : allies for best of data management
Python and Oracle : allies for best of data managementPython and Oracle : allies for best of data management
Python and Oracle : allies for best of data management
 
E yantra robot abstractions
E yantra robot abstractionsE yantra robot abstractions
E yantra robot abstractions
 
Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'Codetainer: a Docker-based browser code 'sandbox'
Codetainer: a Docker-based browser code 'sandbox'
 
OLSR setup
OLSR setup OLSR setup
OLSR setup
 
HPC Examples
HPC ExamplesHPC Examples
HPC Examples
 
Socket.io (part 1)
Socket.io (part 1)Socket.io (part 1)
Socket.io (part 1)
 
Simplifying openstack instances networking
Simplifying openstack instances networkingSimplifying openstack instances networking
Simplifying openstack instances networking
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Automating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleAutomating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and Ansible
 
Devnet 1005 Getting Started with OpenStack
Devnet 1005 Getting Started with OpenStackDevnet 1005 Getting Started with OpenStack
Devnet 1005 Getting Started with OpenStack
 

Recently uploaded

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 

Recently uploaded (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 

Automation intro

  • 2. OFFICE OF THE NETWORK ENGINEER • I am not a "Programmer" • I think about the network & complex networking planning • I spend a lot of my time fire-fighting the network • I need automation tools to help me do my job • I know I need to "level-up" with automation but I need something that helps me get started • I’d like to use Python since it is shaping up as the standard
  • 3. THINKING LIKE A PROGRAMMER • You do *not* have to be a programmer to be successful in automation. • In the most simple of terms, programming is the manipulation of data. • You already know the core concepts of data types and how to manipulate them, the missing link is the language.
  • 4. THIS LOOKS FAMILIAR, BUT WHAT THE HELL IS GOING ON IT'S SHOWTIME BECAUSE I'M GOING TO SAY PLEASE a TALK TO THE HAND "a is true" BULLSHIT TALK TO THE HAND "a is not true" YOU HAVE NO RESPECT FOR LOGIC YOU HAVE BEEN TERMINATED ArnoldC https://github.com/lha rtikk/ArnoldC
  • 5. PYEZ – A LAYERED APPROACH Python Shell Python script IT Frameworks Custom Applications ncclient junos-pyez • Junos specific • Abstraction Layer • micro-framework • NETCONF transport only • Vendor Agnostic • No abstractions • Native Python data types (hash/list) • Junos specific not required • XML not required open-source, Juniper open-source, Community interactive simple → complex
  • 6. INTRO JunOS has a number of automation options available • Ansible, www.ansible.com • Chef, www.chef.io/chef/ • Puppet, www.puppetlabs.com • Salt, www.saltstack.com Today we will focus on pyez, www.github.com/Juniper/py- junos-eznc • A python library to directly interact with a device’s API via netconf over SSH • The JunOS API is primarily XML driven, pyez simplifies that
  • 7. INSTALL PYTHON FRAMEWORK Install pip • Type ‘easy_install pip’ • easy_install assumes your system has python on it • If not, please install python first • www.python.org Install the JunOS python framework • Type ‘pip install junos-eznc’ Optionally install ipython • Type ‘pip install ipython’ • ipython provides a better python shell than standard python • This shell is what will be used in this deck
  • 8. SETUP YOUR DEVICE JunOS’s API is accessed via SSH and netconf • Login to your Juniper device • Type ‘set system services netconf ssh’ • Type ‘commit’ • This will open TCP port 830 • This will need to be done on all devices that want to participate in automation via netconf
  • 9. SETUP DEVICE CONNECTION We need to open a connection to our device, all scripts or interactions via the shell will need to use the Device object and call open() before we do anything • Type ‘python’ or ‘ipython’ to enter the interactive shell • Type ‘from jnpr.junos import Device’ • We need to import a class Device, to access to code for connecting • Type ‘myDev = Device('192.168.212.129', user='dave', password='juniper123’)’ • myDev is now our connection variable • Type ‘myDev.open()’ • If you get a connection error, check your username and password • Also check that TCP port 830 is open on your device
  • 10. MORE SECURE WAY TO CONNECT Typing out a plain text password isn’t ideal for a shell or a script, so we can set it as a local environment variable and call it that way • Before starting the python shell (or script) type ‘export MYSSHPW=“yourSSHPass”’ • This assumes you are using Bash for your shell • Now we setup the connection like we previously did • Type ‘python’ or ‘ipython’ to enter the interactive shell • Type ‘from jnpr.junos import Device’ • Type ‘import os’ • Type ‘sshpass = os.environ['MYSSHPW']’ • This assigns the variable “sshpass” to your ssh password • Type ‘myDev = Device('192.168.212.129', user='dave', password=sshpass)’ • Type ‘myDev.open()’
  • 11. SETUP CONNECTION VIA SSH KEY If you want to use an SSH key to login to the device, that is also possible • Before starting the python shell (or script) type ‘export MYSSHPW=“yourSSHPass”’ • This assumes you are using Bash for your shell • Now we setup the connection like we previously did • Type ‘python’ or ‘ipython’ to enter the interactive shell • Type ‘from jnpr.junos import Device’ • Type ‘sshpass = os.environ['MYSSHPW']’ • This assigns the variable “pass” to your ssh password • Type ‘myDev = Device('192.168.212.129', user='dave', password=sshpass), ssh_private_key_file='/home/dave/.ssh/id_rsa'’ • Type ‘myDev.open()’
  • 12. CHECK SOME FACTS Now that we have a good connection open let’s see some device attributes • Type ‘from pprint import pprint’ • We want a “pretty print” option for printing out our attributes • Type ‘pprint( myDev.facts )’ • This should output a python dictionary of device attributes • But maybe we want to get a specific fact, like a serial • In this case we use key -> value to grab it • Type ‘pprint ( myDev.facts['serialnumber'] )’ • This is using our myDev.facts dictionary and calling the key “serialnumber” to get the serial number’s value
  • 13. REFRESH AND CHECK Some attributes may change like system uptime • We can refresh the device facts by asking for an update • Type ‘myDev.facts_refresh()’ • Now we can see if anything has changed • For instance, the uptime should have incremented • Type ‘pprint ( myDev.facts['RE0']['up_time'] )’ • Note here that we are accessing a dictionary within a dictionary • We are asking for the RE0 key inside our myDev.facts dict and the up_time key inside of the RE0 dict
  • 14. LOOK AT THE INTERFACES Perhaps we want to check into our ethernet interfaces • Type the following block of code: • This should give you a dictionary of all of your interfaces and associated attributes from jnpr.junos.op.ethport import EthPortTable eths = EthPortTable(myDev) eths.get() x = 0 while x < len(eths): print "Interface: " + eths.keys()[x] + " Information" print eths[x].items() x += 1
  • 15. A BETTER INTERFACE LIST This will give a printout of all ethernet interfaces on a device, whether or not they are up, the corresponding mac address and duplex setting from jnpr.junos.op.ethport import EthPortTable eths = EthPortTable(myDev) eths.get() x = 0 while x < len(eths): print "Interface {} is {}, MAC: {}, Link Mode: {}".format(eths.keys()[x], eths[x].oper, eths[x].macaddr, eths[x].link_mode ) x += 1
  • 16. LOOKING AT THE ROUTE TABLE Check out the routing table, but do note, this could be very memory intensive for tables with huge numbers of routes from jnpr.junos.op.routes import RouteTable routes = RouteTable(myDev) routes.get() r = 0 while r < len(routes): print "Route: {}, via interface: {}, protocol: {}".format(routes.keys()[r], routes[r].via, routes[r].protocol) r += 1
  • 17. UPDATING A CONFIG TUTORIAL • https://pynet.twb-tech.com/blog/juniper/juniper-pyez.html • https://pynet.twb-tech.com/blog/juniper/juniper-pyez- commit.html
  • 18. ADVANCED TECHNIQUES • Jinja2 • Smart templating system • SLAX • On board scripts • http://www.juniper.net/techpubs/en_US/junos- pyez1.0/topics/task/program/junos-pyez-program- configuration-data-loading.html • JunOS 14.2 • REST API
  • 19. BONUS - ZTP • ZTP or Zero-Touch Provisioning allows you to setup a device without every logging in. • ZTP utilizes DHCP and (T)FTP/HTTP. With these it can upgrade code and/or add a configuration to a device. • ZTP is enabled by default on JUNOS from the factory or via ‘request system zeroize’. • ZTP requires DHCP option 43 to be set and serves a number of suboptions. • http://www.juniper.net/techpubs/en_US/junos13.3/topics/ta sk/configuration/software-image-and-configuration- automatic-provisioning-confguring.html
  • 20. SUBOPTIONS • 00 - name of the software image file to install • 01 - name of the configuration file to install • 03 - transfer mode (ftp, tftp, http)
  • 21. NEXT STEPS • Learn Python • http://www.codecademy.com/tracks/python • Juniper Python framework • https://github.com/Juniper/py-junos-eznc • Multi-vendor network API abstraction framework • https://github.com/spotify/napalm • Zero-Touch Provisioning • http://www.juniper.net/techpubs/en_US/junos13.2/topics/to pic-map/ztp-overview-els.html

Editor's Notes

  1. A bit too long of a process to go through in a power point, but easily doable from this tutorial which can walk you through the process.