SlideShare a Scribd company logo
Network Automation Concept
1 - YAML
<< SHOW OF HANDS WHO HAS EXPERIENCE WITH YAML >>
Why YAML - it's simple, well known, and does the job
Great tool for representing data, no more (just want the data)
Similar-ish to XML or JSON but more useful to human beings than those two
First exercise is a list:
---
- Juniper
- Cisco
- Brocade
- VMware
Just an arbitrary list. No particular order, doesn't have to be unique.
I'll keep the Python light - for illustrative purposes only. Focus on YAML. We need to write a small
function to import the YAML data
import yaml
from pprint import pprint
def ly(filename):
with open(filename) as _:
return yaml.load(_)
Now we have a function we can use to quickly load the YAML files we write
Let's load the YAML file we wrote.
w body = ly('1-list.yml') print(type(body)) print(len(body)) print(body)
This is the representation of the data in Python
Items in list don't even have to be same type!! YAML mimics the flexibility of Python Notice that
strings (usually) don't have to be enclosed in quotes.
---
- Plants
- 12345
- False
- ['Hello', 'Workld', '!']
Let's run our function again
body = ly('2-mixedtypeslist.yml')
print(type(body))
print(len(body))
print(body)
Small loop to show individual types
for item in body:
print(type(item))
We can write dict of vendor to website mappings
---
Juniper: http://www.juniper.net/us/en/
Cisco: http://www.cisco.com/
Brocade: http://www.brocade.com/index.page
VMware: http://www.vmware.com/
Same as before, we can print type and length
body = ly('3-dictionary.yml')
print(type(body))
print(len(body))
We can call up a specific member of this dictionary by key
print(body['Juniper'])
Dictionaries can be mixed types
Also notice # for comment. Not part of data.
---
Juniper: Also a plant
Cisco: 6500 # They're still around, trust me.
Brocade: True
VMware: ['esxi', 'vcenter', 'nsx']
body = ly('4-mixedtypesdict.yml')
pprint(body)
If we specify values, iterates like a list
for v in body.values():
print(type(v))
Nesting is possible with lists and dictionaries
Here is a list OF dictionaries
---
- name: Juniper
products: ['vMX', 'vSRX', 'Contrail']
- name: Cisco
products: ['Nexus 7K', 'Catalyst 3750', 'ACI']
- name: Brocade
products: ['BVC', 'Vyatta 5400 vRouter', 'VDX 6740']
- name: VMware
products: ['vCenter', 'NSX', 'Virtual SAN']
Pretty print definitely comes in handy here.
body = ly('5-nesting.yml')
pprint(body)
As you can see, the root object is still a list
print(type(body))
However, we can loop through this list and see that there are dictionaries nested inside. This is
a list of dictionaries.
for vendor in body:
print(type(vendor))
Let's augment this loop a little bit to print the vendor name, and the first product in the list
for vendor in body:
print('First %s product is %s' % (vendor['name'], vendor['products'][0]))
You may have noticed YAML can store lists one of two ways I tend to use the one that looks
better (explicit is better than implicit).
---
- name: Juniper
products:
- vMX
- vSRX
- Contrail
- name: Cisco
products:
- Nexus 7K
- Catalyst 3750
- ACI
- name: Brocade
products:
- BVC
- Vyatta 5400 vRouter
- VDX 6740
- name: VMware
products: ['vCenter', 'NSX', 'Virtual SAN']
I'll run the same thing I ran in the last example on this new file. Same results.
body = ly('6-nesting2.yml')
for vendor in body:
print('First %s product is %s' % (vendor['name'], vendor['products'][0]))
We'll use Ansible in a bit - it does module arguments a little differently.
Either all on one line, or chunked up like this:
login_to_router:
user=root
passwd=Juniper
port=22
host=10.12.0.1
Python renders this as a single dictionary, all args just one big string
body = ly('7-sampleargs.yml')
print(body)
This implies that your Python is responsible for parsing this out. Fortunately, Ansible does
this for us.
Thank You.!
Cheers,
Ajeet Singh
Contact No:- +91 992039357 6
Linkedin:-https://in.linkedin.com/pub/ajeet-singh/3a/b42/895
Twitter:-@ajeet0537
Blog:-https://ajeets1.blogspot.in
Facebook:-https://www.facebook.com/NetworkingDCN?ref=hl
Network automation concept

More Related Content

DOC
Devry gsp 215 week 6 i lab virtual memory new
PPTX
PHP 5.5.0 ChangeLog
PPTX
Introduction To Terraform
PDF
Fun Teaching MongoDB New Tricks
PPTX
Amazon elastic map reduce
PDF
Talk KVO with rac by Philippe Converset
PPTX
Introduction tomongodb
Devry gsp 215 week 6 i lab virtual memory new
PHP 5.5.0 ChangeLog
Introduction To Terraform
Fun Teaching MongoDB New Tricks
Amazon elastic map reduce
Talk KVO with rac by Philippe Converset
Introduction tomongodb

What's hot (20)

PPT
Spring data ii
PDF
QB Into the Box 2018
PDF
JRubyKaigi2010 Hadoop Papyrus
PPTX
Cassandra 2.2 & 3.0
PDF
New in MongoDB 2.6
PDF
Kotlin wonderland
PPTX
Azure sql insert perf
PPTX
Config BuildConfig
PPTX
Coding using jscript test complete
PDF
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
PPT
Full-Stack JavaScript with Node.js
PDF
Python my SQL - create table
PDF
"Metrics: Where and How", Vsevolod Polyakov
PPTX
Queue in the cloud with mongo db
PPTX
Mobile TechTalk - Interesting talks from NSConference 6
PDF
Queue in swift
PDF
ClickHouse and the Magic of Materialized Views, By Robert Hodges and Altinity...
PPT
Sqlxml vs xquery
PDF
CFML Enhancements in ColdFusion 10
PDF
Storm introduction
Spring data ii
QB Into the Box 2018
JRubyKaigi2010 Hadoop Papyrus
Cassandra 2.2 & 3.0
New in MongoDB 2.6
Kotlin wonderland
Azure sql insert perf
Config BuildConfig
Coding using jscript test complete
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
Full-Stack JavaScript with Node.js
Python my SQL - create table
"Metrics: Where and How", Vsevolod Polyakov
Queue in the cloud with mongo db
Mobile TechTalk - Interesting talks from NSConference 6
Queue in swift
ClickHouse and the Magic of Materialized Views, By Robert Hodges and Altinity...
Sqlxml vs xquery
CFML Enhancements in ColdFusion 10
Storm introduction
Ad

Viewers also liked (20)

PPTX
Python (Jinja2) Templates for Network Automation
PDF
Automating the Network
PDF
Model-driven Network Automation
PDF
Cohesive Networks Support Docs: VNS3 Setup for Juniper
PDF
Portfolio
PPTX
JDI Innovation Day
PPTX
Juniper Innovation Contest
PDF
Junos space seminar
PPTX
Network Innovation with Open Software
PPTX
An In-Depth Look at Junos Space SDK
PDF
Juniper Content Delivery Network
PDF
『WAN SDN Controller NorthStarご紹介 & デモ』
PDF
SFA: Stateful Forwarding Abstraction in SDN Data Plane
PDF
Quagga Overview as of 2015/10/17
PDF
Introduction to Software Defined Networking (SDN)
PPT
Software defined network and Virtualization
PDF
20150818 jun lee_openstack juno release 내용 분석
PDF
Performance Lessons learned in vRouter - Stephen Hemminger
PPTX
A Network Engineer's Approach to Automation
PDF
Here There Be Turtles: Platform Ops in Public Cloud
Python (Jinja2) Templates for Network Automation
Automating the Network
Model-driven Network Automation
Cohesive Networks Support Docs: VNS3 Setup for Juniper
Portfolio
JDI Innovation Day
Juniper Innovation Contest
Junos space seminar
Network Innovation with Open Software
An In-Depth Look at Junos Space SDK
Juniper Content Delivery Network
『WAN SDN Controller NorthStarご紹介 & デモ』
SFA: Stateful Forwarding Abstraction in SDN Data Plane
Quagga Overview as of 2015/10/17
Introduction to Software Defined Networking (SDN)
Software defined network and Virtualization
20150818 jun lee_openstack juno release 내용 분석
Performance Lessons learned in vRouter - Stephen Hemminger
A Network Engineer's Approach to Automation
Here There Be Turtles: Platform Ops in Public Cloud
Ad

Similar to Network automation concept (20)

PDF
Introductontoxaml
PPTX
IBM Workload Scheduler for z/OS Security with RACF & IBM zSecure
PDF
YAML crash COURSE how to write yaml file for adding configuring details
PDF
Enable Database Service over HTTP or IBM WebSphere MQ in 15_minutes with IAS
PPTX
Mule data weave_10
PDF
Triggers and Stored Procedures
PPTX
How to deploy spark instance using ansible 2.0 in fiware lab v2
PPTX
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
PDF
Develop an inventory management system for an electronics store. The .pdf
PDF
New and improved hacking oracle from web apps sumit sidharth
PPT
Java Script ppt
DOCX
The program reads data from two files, itemsList-0x.txt and .docx
PDF
Introduction to r
PPT
Matlab isim link
PDF
Amazon EMR Masterclass
PDF
Writing Rust Command Line Applications
PPTX
Unit 6 Image processing Libraries.[pptx]
PPTX
Simple xml in .net
PPTX
Learn you some Ansible for great good!
PDF
ZLM-Cython Build you first module
Introductontoxaml
IBM Workload Scheduler for z/OS Security with RACF & IBM zSecure
YAML crash COURSE how to write yaml file for adding configuring details
Enable Database Service over HTTP or IBM WebSphere MQ in 15_minutes with IAS
Mule data weave_10
Triggers and Stored Procedures
How to deploy spark instance using ansible 2.0 in fiware lab v2
How to Deploy Spark Instance Using Ansible 2.0 in FIWARE Lab
Develop an inventory management system for an electronics store. The .pdf
New and improved hacking oracle from web apps sumit sidharth
Java Script ppt
The program reads data from two files, itemsList-0x.txt and .docx
Introduction to r
Matlab isim link
Amazon EMR Masterclass
Writing Rust Command Line Applications
Unit 6 Image processing Libraries.[pptx]
Simple xml in .net
Learn you some Ansible for great good!
ZLM-Cython Build you first module

More from Ajeet Singh (6)

PDF
Kubernetes Architecture with Components
DOCX
Deploy the blockchain network using kubernetes ap is on google cloud
PDF
Setup Kubernetes with flannel on ubuntu platform
PDF
vPC techonology for full ha from dc core to baremetel server.
PDF
Palo Alto Virtual firewall deployment Architecture
PDF
Palo Alto Virtual firewall deployment guide on OpenStack Cloud
Kubernetes Architecture with Components
Deploy the blockchain network using kubernetes ap is on google cloud
Setup Kubernetes with flannel on ubuntu platform
vPC techonology for full ha from dc core to baremetel server.
Palo Alto Virtual firewall deployment Architecture
Palo Alto Virtual firewall deployment guide on OpenStack Cloud

Recently uploaded (20)

PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
Big Data Technologies - Introduction.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
A Presentation on Artificial Intelligence
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Spectroscopy.pptx food analysis technology
PPTX
1. Introduction to Computer Programming.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Empathic Computing: Creating Shared Understanding
NewMind AI Weekly Chronicles - August'25-Week II
Per capita expenditure prediction using model stacking based on satellite ima...
Advanced methodologies resolving dimensionality complications for autism neur...
Network Security Unit 5.pdf for BCA BBA.
A comparative analysis of optical character recognition models for extracting...
Big Data Technologies - Introduction.pptx
cuic standard and advanced reporting.pdf
A Presentation on Artificial Intelligence
Group 1 Presentation -Planning and Decision Making .pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Spectroscopy.pptx food analysis technology
1. Introduction to Computer Programming.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Electronic commerce courselecture one. Pdf
Assigned Numbers - 2025 - Bluetooth® Document
Reach Out and Touch Someone: Haptics and Empathic Computing

Network automation concept

  • 1. Network Automation Concept 1 - YAML << SHOW OF HANDS WHO HAS EXPERIENCE WITH YAML >> Why YAML - it's simple, well known, and does the job Great tool for representing data, no more (just want the data) Similar-ish to XML or JSON but more useful to human beings than those two First exercise is a list: --- - Juniper - Cisco - Brocade - VMware Just an arbitrary list. No particular order, doesn't have to be unique. I'll keep the Python light - for illustrative purposes only. Focus on YAML. We need to write a small function to import the YAML data import yaml from pprint import pprint def ly(filename): with open(filename) as _: return yaml.load(_) Now we have a function we can use to quickly load the YAML files we write Let's load the YAML file we wrote. w body = ly('1-list.yml') print(type(body)) print(len(body)) print(body) This is the representation of the data in Python Items in list don't even have to be same type!! YAML mimics the flexibility of Python Notice that strings (usually) don't have to be enclosed in quotes. --- - Plants - 12345 - False - ['Hello', 'Workld', '!']
  • 2. Let's run our function again body = ly('2-mixedtypeslist.yml') print(type(body)) print(len(body)) print(body) Small loop to show individual types for item in body: print(type(item)) We can write dict of vendor to website mappings --- Juniper: http://www.juniper.net/us/en/ Cisco: http://www.cisco.com/ Brocade: http://www.brocade.com/index.page VMware: http://www.vmware.com/ Same as before, we can print type and length body = ly('3-dictionary.yml') print(type(body)) print(len(body)) We can call up a specific member of this dictionary by key print(body['Juniper']) Dictionaries can be mixed types Also notice # for comment. Not part of data. --- Juniper: Also a plant Cisco: 6500 # They're still around, trust me. Brocade: True VMware: ['esxi', 'vcenter', 'nsx'] body = ly('4-mixedtypesdict.yml') pprint(body)
  • 3. If we specify values, iterates like a list for v in body.values(): print(type(v)) Nesting is possible with lists and dictionaries Here is a list OF dictionaries --- - name: Juniper products: ['vMX', 'vSRX', 'Contrail'] - name: Cisco products: ['Nexus 7K', 'Catalyst 3750', 'ACI'] - name: Brocade products: ['BVC', 'Vyatta 5400 vRouter', 'VDX 6740'] - name: VMware products: ['vCenter', 'NSX', 'Virtual SAN'] Pretty print definitely comes in handy here. body = ly('5-nesting.yml') pprint(body) As you can see, the root object is still a list print(type(body)) However, we can loop through this list and see that there are dictionaries nested inside. This is a list of dictionaries. for vendor in body: print(type(vendor)) Let's augment this loop a little bit to print the vendor name, and the first product in the list for vendor in body: print('First %s product is %s' % (vendor['name'], vendor['products'][0])) You may have noticed YAML can store lists one of two ways I tend to use the one that looks better (explicit is better than implicit). --- - name: Juniper products:
  • 4. - vMX - vSRX - Contrail - name: Cisco products: - Nexus 7K - Catalyst 3750 - ACI - name: Brocade products: - BVC - Vyatta 5400 vRouter - VDX 6740 - name: VMware products: ['vCenter', 'NSX', 'Virtual SAN'] I'll run the same thing I ran in the last example on this new file. Same results. body = ly('6-nesting2.yml') for vendor in body: print('First %s product is %s' % (vendor['name'], vendor['products'][0])) We'll use Ansible in a bit - it does module arguments a little differently. Either all on one line, or chunked up like this: login_to_router: user=root passwd=Juniper port=22 host=10.12.0.1 Python renders this as a single dictionary, all args just one big string body = ly('7-sampleargs.yml') print(body) This implies that your Python is responsible for parsing this out. Fortunately, Ansible does this for us.
  • 5. Thank You.! Cheers, Ajeet Singh Contact No:- +91 992039357 6 Linkedin:-https://in.linkedin.com/pub/ajeet-singh/3a/b42/895 Twitter:-@ajeet0537 Blog:-https://ajeets1.blogspot.in Facebook:-https://www.facebook.com/NetworkingDCN?ref=hl