300-435 ENAUTO 01 (Autosaved)
300-435 ENAUTO 01 (Autosaved)
300-435 ENAUTO 01 (Autosaved)
ENAUTO:
Automating and
Programming Cisco
Enterprise Solutions
Topic
Let’s Start …
Find the Topic
Link :
https://learningnetwork.cisco.com/s/ena
uto-exam-topics
1.0
1.1 Utilize common version control operations with git (add, clone, push, commit, diff,
branching, merging conflict)
1.2 Describe characteristics of API styles (REST and RPC)
1.3 Describe the challenges encountered and patterns used when consuming APIs
synchronously and asynchronously
1.4 Interpret Python scripts containing data types, functions, classes, conditions, and looping
1.5 Describe the benefits of Python virtual environments
1.6 Explain the benefits of using network configuration tools such as Ansible and Puppet for
automating IOS XE platforms
Introduction to Git
The Concurrent Versions System was first designed in the 1980s. Originally, it handled conflicting situations.
For example, when two engineers who worked on the same file, CVS allowed only the latest version of the
code to be worked on and updated. As such, it was a first come, first serve system.
Apache Subversion (SVN) was created as an alternative to CVS. SVN uses atomic operations, meaning that
either all changes that are made to the source are applied or none are applied. No partial changes are allowed,
avoiding many potential issues. A drawback of SVN is its slower speed.
http://stackoverflow.com/a/1408464
Opens up to new workflows: git flow
Distributed
https://git-scm.com/images/about/workflow-b@2x.png
Under the Hood
• Changes are stored in trees
• Trees contain changed files
• Commits contain trees
13
http://git-scm.com/figures/18333fig0903-tn.png
Git Config
• So you can be held accountable, configure git
$ git add .
Git Commit
• Store your changes into a commit
Distributed Version Control System based on Git that is a web-based hosting service Free
GitHub is a distributed version control system that is based on Git that is a web-based hosting service. It is
the leading git platform for independent and open source projects. While GitHub offers unlimited free
repositories as long as the repository is public, they offer subscriptions for those organizations who want
private repositories.
Git Over SSH Vs HTTP
• No password
• Set up SSH key on remote server
My Software System
In Java, C and C#, "callbacks" are usually synchronous (with respect to a "main event loop").
In Javascript, on the other hand, callbacks are usually asynchronous - you pass a function that will be
invoked ... but other events will continue to be processed until the callback is invoked.
If you don't care what Javascript events occur in which order - great. Otherwise, one very powerful
mechanism for managing asynchronous behavior in Javascript is to use "promises":
Synchronous vs.
Asynchronous
Writes
Synchronous API calls are blocking calls that do not return until either the change has been
completed or there has been an error. For asynchronous calls, the response to the API call is
returned immediately with a polling URL while the request continues to be processed.
In heavier load conditions, it can be more efficient to submit multiple async calls and
periodically check the status than to wait for each call to complete before submitting the
next one.
https://web.dev/promises/
1.4 Interpret
Python scripts
containing data
types, functions,
classes,
conditions, and
looping
Follow-up with 2 Videos on Python
1.5 Describe the benefits of Python virtual
environments
http://learnpy.cisco.com/learn/devenv/virtualenv
Virtual Environments
In the Python world, virtual environments are a way to keep distinct environments that contain the
requirements particular to each application, tool or script that you can be working on. These are very useful
when working with environments that require specific libraries to function. Take for example that you are
working on a project that is written for Cisco ACI APIC version 1.1j and you are also working in sustaining
your project in the release 1.0(2)m. Instead of having to change the version of the REST API, you could
simply contain two separate virtual environments that each have different versions of the Cobra SDK with
your application.
Virtual environments contain all the requirements for the function of the application, including the version
of Python itself that is required. In this document we will cover how to create virtual environments in
separate operating systems to help you in setting up an environment that contains all the requirements for
Python to develop applications to interface with Cisco ACI and NX-OS.
1.6 Explain the benefits of using
network configuration tools such
as Ansible and Puppet for
automating IOS XE platforms
Configuration Management
Automate the provisioning and deployment of applications and infrastructure No
knowledge of programming required Leverages software development practices for
deployments: Version Control Design Patterns Testing Common tools: Puppet, Ansible,
Chef, and SaltStack
From a networking perspective, it’s common to deploy changes manually. This change could be adding
a VLAN across a data center or campus or making daily changes to firewall policies for new
applications being deployed. When there is a defined manual workflow to perform a set of tasks, proper
tools should be used to automate it. It does not make sense to spend an hour performing a change. This
change could take just a few minutes by using a properly engineered tool. This process is where open
source tools such as Puppet, Chef, Ansible, and SaltStack can dramatically reduce the number of
manual interactions with the network.
These tools are often referred to as DevOps tools.
They are more specifically configuration
management and automation tools that happen to
be used by those organizations that have
implemented some form of DevOps practices.
Before Netmiko.
General Notes for Tonight
After Netmiko.
Installing Netmiko
Concurrency:
https://github.com/ktbyers/pynet-ons-oct17/blob/master/threads_procs/
Jinja2 Templating
http://jinja.pocoo.org/docs/2.10/templates/
Simple Orchestration
Wide 92
Deployment
Adoption
https://www.ansible.com/blog/coming-soon-networking-features-in-ansible-2.5
Getting started with
Ansible
Ansible Controller
Target
s
SSH
(user/pass, public key)
1. Push configuration
2. Get configuration/state
3. Execute commands
?
Let‘s first cover the
basic terms and concepts.
Ansible Configuration – ansible.cfg
• The place for adjusting default settings based on your requirements
• Multiple alternative places for parameters and setting exists
• Typically, default settings are sufficient for most users
Inventory
$ cat ansible/hosts
• INI format file usually called ‘hosts’ [core]
CORE_XR
ansible_host=198.18
• Defines the hosts which Ansible manages [branch1]
.1.5
BRANCH_1_CSR ansible_host=198.18.1.12
BRANCH_1_SWITCH
• Hosts can be grouped together with [] ansible_host=198.18.1.11
[branch2]
BRANCH_2_CSR ansible_host=198.18.1.22
• Additional optional parameters can be defined BRANCH_2_SWITCH
ansible_host=198.18.1.21
[csr]
• Where does Ansible look for the inventory file: BRANCH_1_CSR ansible_host=198.18.1.12
Modules https://docs.ansible.com/ansible/latest/modules/modules_by_category.html
Ad-hoc Commands
• Allows you to execute tasks really quick without saving steps
• Useful to understand the basics of how Ansible works
Playbooks
$ cat sample.yaml
---
• Ansible‘s method of procedures (MoP) - hosts: control
gather_facts: no
connection: local
• Playbooks store task sequences for later reuse tasks:
- name: PING
• Can have one or more plays and tasks ANSIBLE CONTROL
ping:
$ ansible-playbook sample.yaml
PLAY [control]
**********************************************************************************************************************
LTRRST- 1954 © 2019 Cisco and/or its affiliates. All rights reserved. Cisco Public 10
0
Jinja2 Templates
• Jinja2 templates further enhance modelling $ cat ios_interface.yaml
- hosts: branch1[0]
capabilities, e.g. including native configlets gather_facts: no
connection:
• Jinja2 templates have access to Ansible variables local
YAML playbooks
SNMP
syslog
CLI
• Interface up/down
• Instantaneous config Storage and
• Instantaneous topology Analytics
• Flow fingerprints
• Routes
SNMP polling hard on
everybody
Devices Network Managers
Request-ID 1:
Sent, No Response
Request-ID 2:
Sent, No Response
Push Not
Pull
Vs
Pull
Why this
matters now
New Capabilities New Requirements
• Speed and scale
• Quick fault isolation
• Open source applications
• Near real time data availability
• Automated remediation
• Forensic analysis
Model-Driven Telemetry
Subscription
Periodic or On-change NETCONF
Device Features
SNMP
Physical and Virtual Network Infrastructure Interface
BGP QoS ACL …
Data Models and NETCONF
Cisco-IOS-XE-mdt-oper.yang
Data Models
Protocol
Data-Model
https://tools.ietf.org/html/rfc6020
YANG Models
Example
YANG Models
Data
XML Payload
Xpath mdt-
s ubs c ript ion
period 1000
https://github.com/YangModels/yang
https://github.com/openconfig
Where are YANG
models?
Also can be downloaded from GitHub.
https://github.com/YangModels/yang/tree/master/
vendor/cisco
container mdt-oper-data
list mdt-subscriptions
list mdt-connections subscription-id? (ro) uint32
transport? (ro) string type? (ro) mdt-oper:mdt-sub-type container mdt-streams
peer-id? (ro) string state? (ro) mdt-oper:mdt-sub-state stream[]? (ro) string
state? (ro) mdt-oper:mdt-con- comments? (ro) string
state updates-in? (ro) uint64
address? (ro) inet:ip-address updates-dampened? (ro) uint64
port? (ro) uint16 updates-dropped? (ro) uint64
list mdt-receivers
list mdt-sub-con-stats protocol? (ro) string container base
sub-id? (ro) uint32 state? (ro) mdt-oper:mdt-receiver-state stream? (ro) string
updates-sent? (ro) uint64 comments? (ro) string encoding? (ro) string
updates-dropped? (ro) address (ro) inet:ip-address
uint64 port (ro) uint16
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
DEVNET-1693
119 choice update-trigger-choice
choice filter-type-choice
case sub-filter-type-xpath case sub-filter-type-none case sub-upd-trig-on-change case sub-upd-trig-periodic case sub-upd-trig-none
xpath? (ro) string no-filter? (ro) uint32 no-synch-on-start? (ro) boolean period (ro) uint32 no-trigger? (ro) uint32
NETCONF definition
“NETCONF is a protocol defined by the IETF to install, manipulate, and delete the
configuration of network devices”
Transport
2006 2011
https://tools.ietf.org/html/rfc6241
NETCONF vs. YANG
Communication
Protocol Data Description
NETCONF YANG
SNMP MIB/ASN.1
NETCONF
protocol stack
CONTENT XML (based on YANG)
MESSAGES RPC
Instruction on:
• What data to collect
• Where to send it and how
• How often
Collector
Network
Subscription
• Any YANG subtree on device Subscription Publication
• Structured data
• Periodic or On-change
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
DEVNET-1693
125
Types of Subscriptions
Periodic On-change
Continuous data Event occurs
Subscriber Subscriber
Datastore Datastore
Periodic
subscription
t t t DEVNET-1693
t t
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
127 t t
Counters / Measures
Periodic
subscription RPC
• Xpath-filter:
• XML Xpath filter defining the data object to which you want to subscribe.
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
• Period:
DEVNET-1693
128
notification and
subscription-ID
Verify
subscription
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
On-change
subscription
t t t DEVNET-1693
t t
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
132 t t
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
DEVNET-1693
133
notification
and
subscription-ID
Verify
subscription
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
DEVNET-1693
135
Demo
MDT
Text message
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Delete
subscription
• Subscriptions can be deleted in two ways:
• Send a delete-subscription RPC with the subscription ID (Preferred)
• Close/disconnect the Netconf session
• (All subscriptions created over this session will be deleted)
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
DEVNET-1693
137
Streaming Telemetry benefits
•
over SNMP
devices stream data based on a specified frequency or upon state change
• data is sent as soon as it is available, reducing the need to buffer
• no single large request for all data (unlike SNMP polling)
• data sent incrementally, e.g., only for those data items that have changed
• ability to distribute the telemetry sources (e.g., directly to linecards)
• users issue subscription requests via RPC for data of interest
• data exported in a well-structured, common format, e.g., based on YANG models
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
DEVNET-1693
•
138
https://github.com/YangModels/yang/tree/master/vendor/cisco/xe/ DEVNET-1693 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 38
Conclusion
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Reca
p
✔ Telemetry Push
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
DEVNET-1693
141
BRKCRS-2451: Scripting Catalyst switches - tools and techniques beyond the basics
Jeff McLaughlin, Thursday, Feb 01, 11:30 a.m. - 01:30 p.m.
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
DEVNET-1693
142
WISP Labs:
LABCRS-2222: Open IOS XE Programmability, Krishna Kotha, all week
IOS XE Programmability DevNet
Sessions @ CL Barcelona
DEVNET-1693: Model-Driven Telemetry for IOS XE
Krishna Kotha, Thursday, Feb 01, 04:00 p.m. - 04:45 p.m.
© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
DEVNET-1693
144
developer.cisco.com/site/ios-xe/