0% found this document useful (0 votes)
15 views28 pages

Devnet 2556

The document discusses leveraging Python on IOS-XE through the Guest Shell, which provides a Linux environment for network administrators to run Python scripts and manage network devices. It highlights the benefits of using Python for automation, the integration of NETCONF and YANG for configuration management, and provides a use case for adjusting QoS policies based on WAN link status. Additionally, it includes instructions for setting up a local image for lab use and emphasizes the importance of feedback through session evaluations.

Uploaded by

jsuarez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views28 pages

Devnet 2556

The document discusses leveraging Python on IOS-XE through the Guest Shell, which provides a Linux environment for network administrators to run Python scripts and manage network devices. It highlights the benefits of using Python for automation, the integration of NETCONF and YANG for configuration management, and provides a use case for adjusting QoS policies based on WAN link status. Additionally, it includes instructions for setting up a local image for lab use and emphasizes the importance of feedback through session evaluations.

Uploaded by

jsuarez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Dive into Leveraging

Python on IOS-XE

Adrian Iliesiu – Corporate Technology Engineer


DEVNET-2556
DEVNET-2556

Guest Shell
Guest Shell Application
Linux Shell Environment On Your Switch or Router
• Maintain IOS-XE system integrity
• Isolated User Space
• Fault Isolation
• Resource Isolation
Linux
• On-box rapid prototyping applications
• Device-level API Integration
• Scripting (Python) Guest Shell
• Linux Commands
• Application Hosting Open Application Container
API
• Integrate into your Linux workflow
Network OS
• Integrated with IOS-XE

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 4
Preparing the Vagrant Image
Initial Setup of Local Image for Lab
1. From csr1kv# prompt:
1. guestshell run bash
2. sudo yum install -y git
3. git clone https://github.com/rshoemak/DevNet2556
4. ./DevNet2556/laptop-prep.sh

2. Exit Guest Shell


1. exit
2. copy bootflash:IOS-config-base.txt running-config
3. write mem

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 5
Guest Shell Overview
Guest Shell is a decoupled execution space running within a Linux Container
(LXC)
From within the Guest Shell the network-admin has the following capabilities:
• Access to the network over Linux network interfaces
• Access to bootflash
• Access to IOS CLI
• The ability to install and run python scripts.
• The ability to install and run 32-bit and 64-bit Linux applications.

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 6
DEVNET-2556

Python on Guest Shell


Why Python on IOS-XE?
• Python is the de-facto automation
language of the day
• Easy to learn but powerful programming
language
• Helps overcome operational
shortcomings of CLI
• Provides programmatic access to
device’s configuration

http://www.python.org/

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 8
Cisco’s Python Enhancements
IOS-XE 16.5 operating system enables the Python API
• Interactive python prompt
• Running python script
• Zero Touch Provisioning (ZTP)
• Embedded Event Manager (EEM)

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 9
Let’s Get Started
Open a Browser and go to:

https://github.com/rshoemak/DevNet2556

Then, click on “Modules” link

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 10
Module 6 – NETCONF & YANG
What is NETCONF?
• “NETCONF is a protocol defined by the IETF to “install, manipulate, and delete
the configuration of network devices”. NETCONF operations are realised on top
of a Remote Procedure Call (RPC) layer using an XML encoding and provides a
basic set of operations to edit and query configuration on a network device”
• http://www.tail-f.com/education/what-is-netconf/
• NETCONF RFCs
• https://tools.ietf.org/html/rfc6241 (NETCONF RFC)
• https://tools.ietf.org/html/rfc6242 (NETCONF over SSH)
• https://tools.ietf.org/html/rfc5277 (NETCONF notifications)

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 12
What is YANG?
• ”YANG is a data modeling language used to model configuration and state
data manipulated by the NETCONF protocol.”
• http://www.tail-f.com/education/what-is-yang/
• RFC 6020 - https://tools.ietf.org/html/rfc6020

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 13
Q. Why Do We Even Need a Modeling Framework?

We’ve all seen this one, right?

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 15
A. Simplicity and Automation
• Without a modeling framework, every device and device type must be
configured using a different set of rules.
• How would an automation tool program different device types?
• How would an automation tool determine the structure of data for various device
types?

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 16
Taking a Look at a YANG Model

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 17
Elements of Using
NETCONF

Device login info

Opening a
NETCONF session

YANG model info

NETCONF request:
“get_config”

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 18
Module 7 – A Deeper Look at
NETCONF
Elements of Using
NETCONF
Define class object
two variables returned per object:
name & description

Definition to extract
data from parsed
YANG info

Iterate through GE
interfaces
Iterate through
Loopback interfaces

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 20
Module 8 – Bringing it All Together
On-Box Python Use Case
• Device has standard QoS policy for egress shaping
• Multiple egress links provide application routing
• If a WAN link fails, want to resize QoS policy since overall bw is reduced

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 22
On-Box Python Use Case
• Use EEM to monitor for Syslog Message about failed link
• Python running on Guest Shell will execute the Python script
• NETCONF will validate the link being modified is a “WAN” link and is operational
• Python API will execute CLI change to modify the QoS policy on the remaining
“WAN” link

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 23
Elements of Python
Use Case
Define class object
three variables returned per object:
name, description & state

Open a NETCONF
session and return config

Definition to extract
data from parsed
YANG info and return
data

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 24
Elements of Python
Use Case (cont.)

Iterate through all


interfaces and return
object data

Match the correct


interface and adjust the
QoS setting

DEVNET-2556 © 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 25
Q&A
Complete Your Online
Session Evaluation
• Give us your feedback and
receive a Cisco Live 2018 Cap
by completing the overall event
evaluation and 5 session
evaluations.
• All evaluations can be completed
via the Cisco Live Mobile App.
Don’t forget: Cisco Live sessions will be
available for viewing on demand after the
event at www.CiscoLive.com/Global.

© 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Thank you

You might also like