際際滷

際際滷Share a Scribd company logo
PyEZ
Nitin Kumar nitinkr@juniper.net
 Remote device management and "fact" gathering
 Troubleshooting, Audit and Reporting
 Operational data
 Configuration data
 Configuration Management
 Unstructured config snippets and templates
 Structured abstractions
 Generalized utilities for file-system, software-upgrade, secure file copy (scp), etc.
 RPC Meta-Programming
 "PyEZ is meant to address all aspects for quickly and easily building network tools.
Junos PyEZ is a micro framework for Python that enables you to remotely manage and
automate devices running Junos OS
Junos and Python  Make it Easy (PyEZ)
Why Python?
 excellent for beginners, yet superb for experts
 highly scalable, suitable for large projects as well as small ones
 portable, cross-platform
 easily extensible
 object-oriented
 Automatic memory management
 simple yet elegant
 powerful standard libs
 wealth of 3rd party packages
What is Jinja2
Jinja2 is a widely used templating engine for Python.
Design and implementation is intuitive
Template inheritance
Allows you to build a base skeleton template that contains all the
common elements of your site and defines blocks that child
templates can override.
Easy to debug
Line numbers of exceptions directly point to the correct line in the
template.
Execution is very fast
Widely adopted
Jinja2 example
# Template
interfaces {
{% for item in interfaces %}
{{ item }} {
description "{{ description }}";
unit 0 {
family {{ family }};
}
} {% endfor %}
}
protocols {
mpls {
{% for item in interfaces %}
interface {{ item }};
{% endfor %}
}
}
interfaces {
ge-1/0/1 {
description "MPLS
interface";
unit 0 {
family mpls;
}
}
ge-1/0/2 {
description "MPLS
interface";
unit 0 {
family mpls;
}
}
}
protocols {
mpls {
interface ge-1/0/1;
data= {
'interfaces': ['ge-1/0/1', 'ge-1/0/2],
'description': 'MPLS interface',
'family': 'mpls'
}
YAML
{
'interfaces': ['ge-1/0/1', 'ge-1/0/2],
'description': 'MPLS interface',
'family': 'mpls'
}
Python data
---
interfaces:
- ge-1/0/1
- ge-1/0/2
description: 'MPLS interface'
family: mpls
YAML
 YAML is a human readable mechanism for storing data that is easily mapped
to common data types.
 It supports hierarchical structures
 Whitespace delimited (like Python) so files have consistent look.
 Program language agnostic  supported by most.
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
LAYERED APPROACH
Secure TCP/IP connections via
SSHv2 (RFC4742)
XML
NETCONF XML
PROTOCOL
(RFC4741)
Management System
Python script to configure
device
User is encapsulated of backend activities like XML processing.
Different protocol involved in communication and other
processing.
Security Routing Switching
Junos PyEZ
1. Python framework with easy learning curve
2. Works with any Junos device running 11.4 or later
3. Operational and Configuration Data/Management
4. Generalized utilities for file-system, software-upgrade, scp
5. Community supported
Top 5 reasons for PyEZ
* Based on queries posted by their employees on Google Group
PyEZ users*
PyEZ success stories
BGP Flow Specification
Newrelic performance analysis
Diagnose LAG health LLDP network topology
YouTube: https://www.youtube.com/user/JuniperNetworks/search?query=pyez
Wiki: https://techwiki.juniper.net/Automation_Scripting/Junos_PyEZ
API Docs: http://junos-pyez.readthedocs.org/
Forum: http://groups.google.com/group/junos-python-ez
GitHub: http://github.com/Juniper/py-junos-eznc/
Google Group: https://groups.google.com/forum/#!forum/junos-python-ez
Resources
Demo

More Related Content

PyEZ

  • 2. Remote device management and "fact" gathering Troubleshooting, Audit and Reporting Operational data Configuration data Configuration Management Unstructured config snippets and templates Structured abstractions Generalized utilities for file-system, software-upgrade, secure file copy (scp), etc. RPC Meta-Programming "PyEZ is meant to address all aspects for quickly and easily building network tools. Junos PyEZ is a micro framework for Python that enables you to remotely manage and automate devices running Junos OS Junos and Python Make it Easy (PyEZ)
  • 3. Why Python? excellent for beginners, yet superb for experts highly scalable, suitable for large projects as well as small ones portable, cross-platform easily extensible object-oriented Automatic memory management simple yet elegant powerful standard libs wealth of 3rd party packages
  • 4. What is Jinja2 Jinja2 is a widely used templating engine for Python. Design and implementation is intuitive Template inheritance Allows you to build a base skeleton template that contains all the common elements of your site and defines blocks that child templates can override. Easy to debug Line numbers of exceptions directly point to the correct line in the template. Execution is very fast Widely adopted
  • 5. Jinja2 example # Template interfaces { {% for item in interfaces %} {{ item }} { description "{{ description }}"; unit 0 { family {{ family }}; } } {% endfor %} } protocols { mpls { {% for item in interfaces %} interface {{ item }}; {% endfor %} } } interfaces { ge-1/0/1 { description "MPLS interface"; unit 0 { family mpls; } } ge-1/0/2 { description "MPLS interface"; unit 0 { family mpls; } } } protocols { mpls { interface ge-1/0/1; data= { 'interfaces': ['ge-1/0/1', 'ge-1/0/2], 'description': 'MPLS interface', 'family': 'mpls' }
  • 6. YAML { 'interfaces': ['ge-1/0/1', 'ge-1/0/2], 'description': 'MPLS interface', 'family': 'mpls' } Python data --- interfaces: - ge-1/0/1 - ge-1/0/2 description: 'MPLS interface' family: mpls YAML YAML is a human readable mechanism for storing data that is easily mapped to common data types. It supports hierarchical structures Whitespace delimited (like Python) so files have consistent look. Program language agnostic supported by most.
  • 7. 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 LAYERED APPROACH
  • 8. Secure TCP/IP connections via SSHv2 (RFC4742) XML NETCONF XML PROTOCOL (RFC4741) Management System Python script to configure device User is encapsulated of backend activities like XML processing. Different protocol involved in communication and other processing. Security Routing Switching Junos PyEZ
  • 9. 1. Python framework with easy learning curve 2. Works with any Junos device running 11.4 or later 3. Operational and Configuration Data/Management 4. Generalized utilities for file-system, software-upgrade, scp 5. Community supported Top 5 reasons for PyEZ
  • 10. * Based on queries posted by their employees on Google Group PyEZ users*
  • 11. PyEZ success stories BGP Flow Specification Newrelic performance analysis Diagnose LAG health LLDP network topology
  • 12. YouTube: https://www.youtube.com/user/JuniperNetworks/search?query=pyez Wiki: https://techwiki.juniper.net/Automation_Scripting/Junos_PyEZ API Docs: http://junos-pyez.readthedocs.org/ Forum: http://groups.google.com/group/junos-python-ez GitHub: http://github.com/Juniper/py-junos-eznc/ Google Group: https://groups.google.com/forum/#!forum/junos-python-ez Resources
  • 13. Demo

Editor's Notes

  • #3: Junos PyEZ is designed to provide the capabilities that a user would have on the Junos OS command-line interface (CLI) in an environment built for automation tasks. Junos PyEZ does not require extensive knowledge of Junos OS or the Junos XML APIs. It also enables you to manage devices running Junos OS using the familiarity of Python. Python enrich-ness of inbuilt & 3rd party modules enables user to develop huge set of application and frameworks Junos PyEZ enables you to perform specific operational and configuration tasks on devices running Junos OS and also provide utilities such as file system, software upgrade, scp etc
  • #4: These are some of the feature which makes Python a gem. Hence Python outstands from other programming languages.
  • #7: YAML is a human friendly data serialization standard for many programming languages. We can define python data types like list, dictionary in normal text format using YAML.
  • #8: Need to cite URL for ncclient.
  • #9: All Juons devices support XML rpcs over NETCONF APIs. Juniper follows single Junos even with different set of platform like security, Routing and switching PyEZ leverages this and hence support any boxes with Junos as the OS.
  • #10: Earlier we talked a bit about Python with Junos PyEZ, PyEz is a Python library to remotely manage/automate Junos devices. One of the biggest benefits of Python with Junos PyEz is that the user isNOTrequired: (a) to be a "Software Programmer", (b) have sophisticated knowledge of Junos, or (c) have a complex understanding of the Junos XML API. This is beneficial to the software side as well as to the networking side. The PyEz library was built for two types of users: For "Non-Programmers" - PyEz was designed as a Power Shell This means the engineers that currently lean more toward a networking discipline, can use the native Python shell on their management server (laptop, tablet, phone, etc.) as their point-of-control for remotely managing Junos devices. The Python shell is an interactive environment (and feels similar to a device CLI due to it ability to provide instant feedback), that provides the necessary means to perform common automation tasks, such as conditional testing, for-loops, macros, and templates. These building blocks are similar enough to other "shell" environments, like Bash, to enable you to use the Python shell as a power-tool, rather than a programming language. From the Python shell a user can manage Junos devices using native hash tables, arrays, etc. rather than device-specific Junos XML or resorting to 'screen scraping, AKA TCL or Expect scripts, against the actual Junos CLI. Also, this is environment lends it self easily to your first scripts simply by adding Dot P Y to a set of commands you have tested. For "Programmers" PyEz Open and Extensible There is a growing interest and need to automate the network infrastructure into larger IT systems. To do so, traditional software programmers, DevOps, "hackers", etc. need an abstraction library of code to further those activities.Junos PyEZis designed for extensibility so that the programmer can quickly and easily add new widgets to the library in support of their specific project requirements. There is no need to "wait on the vendor" to provide new functionality.Junos PyEZis not specifically tied to any version of Junos or any Junos product family.
  • #11: These are some of our happy customers using PyEZ extensively.
  • #12: BGP Flow Specification with help thwarting Distributed Denial of Service (DDoS) attacks our customer Newrelic kuses PyEZ to now the performance, resource utilization, and health of network devices in order to help prevent outages, troubleshoot issues, and perform network planning Mapping an entire network topology into a diagram is a tedious task and might take hours and various licensed tools to be done manually. This app is developed on top of PyEZ to have a Web Tool for LLDP network visualization. This tool represents the LLDP networks in terms of bidirectional network graph diagrams showing various connections and interfaces between the devices and giving a high level overview of the network. An APP to monitor the health of your LAG bundles. Link Aggregation Groups (LAG) are widely deployed by customers in their networks for improved bandwidth and availability. LAG child links can be faulty and troubleshooting is hard. Dr.LAG app helps to diagnose the health of LAG bundles.