586 05 03-16-saalvare-xr-mdp-ckn-may-2016-v8 - Cisco€¦ · Santiago Álvarez April 2016 For Cisco...
Transcript of 586 05 03-16-saalvare-xr-mdp-ckn-may-2016-v8 - Cisco€¦ · Santiago Álvarez April 2016 For Cisco...
Santiago Álvarez
April 2016
For Cisco IOS XR
Model-Driven Programmability
@111pontes
2 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
• Speed and scale demand software automation and data analytics
• Rapid innovation as competitive advantage • One network operator per 1000s / 10000s of
complex network devices
Motivations for Network Programmability
3 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
Protocol NETCONF gRPC RESTCONF
Encoding XML JSON
Model-Driven Programmability Stack
Models
APIs
Apps
Model-Driven APIs YANG Development Kit (YDK)
YANG Models (native, open)
App1 App2 App3
SSH HTTP Transport
4 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
• Model based, structured, computer friendly • Multiple model types (native, common, OpenConfig, IETF, etc.)
• Models decoupled from transport, protocol end encoding
• Choice of transport, protocol and encoding
• Model-driven APIs for abstraction and simplification
• Wide standard support while leveraging open source
Benefits of Model-Driven Programmability
5 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
• Model structures data (config and operational) as a tree
• Models files are self-documented and ship with devices
• Cisco IOS XR supports 150+ YANG models (config and operational) in release 6.0.0
• Native models provide most coverage
• OpenConfig and IETF models are mapped to native models
Data Models
Native / Common OpenConfig / IETF
6 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
• Modeling language (initially for NETCONF)
• Main node types • Leaf – node with name and value of
certain type (no children) • Leaf list – sequence of leafs • Container – groups nodes and has no
value • List – Sequence of records with key
leafs
• Deviations document data not implemented in non-native model
YANG
Leaf
Node without a value
Node with a value
Leaf list
Container (grouping)
Container (presence)
List
key
7 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
XML
NETCONF
• Rich functionality to manage configuration and operational (state) data
• Operations defined as RPCs (request / reply) in XML
• Client/app initiate request towards server/device
• Supports running, candidate and startup configurations
• Capability exchange during session initiation
NETCONF Protocol Overview
YANG
SSH
8 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
XML JSON
RESTCONF
YANG
HTTP / HTTPS
• RESTful API for NETCONF
• Functional subset of NETCONF
• Single hierarchy of resources (data + allowed methods)
• Resource hierarchy rooted at ‘restconf/’
• Configuration and operational data located under ‘restconf/data’
• Web app friendly
RESTCONF Protocol Overview
9 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
Cisco gRPC
CLI JSON
YANG
HTTP/2
• Google RPC provides a general (open source) RPC framework
• Interface definition in Cisco IOS XR specifies device operations
• Functional subset of NETCONF
• Simple client development
• High performance
Overview of gRPC on Cisco IOS XR
10 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
• Simplify app development
• Abstract transport, encoding, model language
• API generated from YANG model
• One-to-one correspondence between model and class hierarchy
• Multi-language (Python, C++, Ruby, Go, etc.)
Model-Driven APIs
YANG Model Class Hierarchy
(Python, C++, Ruby, Go)
11 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
Generation of Model-Driven APIs Using YANG Development Kit (YDK)
YANG YANG
YANG
Data Models (YANG)
API Generator
Docs Python
C++
: :
Ruby
go
Docs
Docs
Docs
C♯ Docs
YDK-gen
YDK-Py YDK
12 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
• YDK service will automatically perform local (client-side) validation
• Type check (enum, string, etc.)
• Value check (range, pattern, etc.)
• Semantic check (key uniqueness/presence, mandatory leafs, etc.)
• Model deviation check
Client-Side Validation
Application (client)
Device (server)
13 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
#CiscoYDK-PyOC-BGP“Helloworld”fromydk.servicesimportCRUDServicefromydk.providersimportNetconfServiceProviderfromydk.models.bgpimportbgpif__name__=="__main__":provider=NetconfServiceProvider(address=10.0.0.1,port=830,username=“admin”,password=“admin”,protocol=“ssh”)crud=CRUDService()#createCRUDservicebgp=bgp.Bgp()#createoc-bgpobjectbgp.global_.config.as_=65000#setlocalASnumbercrud.create(provider,bgp)#createonNETCONFdeviceprovider.close()exit()#Endofscript
A YDK-Py “Hello World” Using OC-BGP
module:openconfig-bgp+--rwbgp!+--rwglobal|+--rwconfig||+--rwas||+--rwrouter-id?|+--rostate||+--roas||+--rorouter-id?||+--rototal-paths?||+--rototal-prefixes?...
14 © 2015 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Demo
15 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
NETCONF
R1
OC-BGP IPv4 Unicast (NETCONF)
R2 R3
10.0.0.254
10.0.0.1
.0 .1 .0 .1
Controller
AS65001 172.16/16
AS65003 172.18/16
AS65002 172.17/16
eBGP eBGP
192.168.1/31 192.168.2/31
16 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
gRPC
R1
OC-BGP IPv6 Unicast (gRPC)
R2 R3
10.0.0.254
10.0.0.1
.0 .1 .0 .1
AS65001 2001:db8:1/48
AS65003 2001:db8:3/48
AS65002 2001:db8:2/48
eBGP eBGP
2001:db8:fff1/127 2001:db8:fff2/127
Controller
17 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
AS65002 172.17/16
NETCONF
R1
OC-BGP IPv4/IPv6 Unicast (Python)
R2
R3
10.0.0.254
10.0.0.1
.1 .0
Controller
AS65001 172.16/16
AS65003 172.18/16
eBGP
192.168.3/31
2001:db8:fff3/127
18 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
• Model-Driven Programmability • Speed and scale through automation • Rich and flexible in terms of models,
transports and encodings
• NETCONF • Rich, mature protocol • Relies on XML encoding
• RESTCONF • RESTful API for NETCONF • Single hierarchy of resources • Supports JSON and XML encoding
• Google RPC • Cisco interface definition (device operations) • Supports JSON and unstructured data (CLI) • High performance
• Model-Driven APIs • Simplify app development • Abstract transport and encoding
Let’s Recap
19 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
Cisco Knowledge Network Webinars
• Device Programmability Using YANG Development Kit and Python – Jun 7
Cisco Live Las Vegas
• LTRSPG-2601 - Cisco IOS XR Programmability Lab (4hrs)
• DEVNET-2057 - Ok, We Got YANG Data Models, Now What?
Upcoming Events
19
20 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
GitHub
• Cisco IOS XR YANG models (https://git.io/vg7fk)
• Getting Started With OpenConfig in Cisco IOS XR (https://git.io/vg7vF)
• Getting Started With gRPC in Cisco IOS XR (https://git.io/vg7vP)
• YDK Python API – YDK-Py (https://git.io/vaWsg)
• YDK-Py sample apps (https://git.io/vaw1U)
• YDK Generator – YDK-gen (https://git.io/vaw1M)
• YANG Explorer (https://git.io/vg7Jm)
Resources
21 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
DevNet
• YDK at DevNet (https://goo.gl/Wqwp3C)
• Cisco IOS XR 6.0 at DevNet (https://goo.gl/uaxrpN)
YDK Sandboxes
• Ubuntu YDK-PY Vagrant box (https://git.io/vaw1U)
• YDK on dCloud (http://dcloud.cisco.com.com)
YDK Support
• Cisco support community (https://communities.cisco.com/community/developer/ydk)
Resources (cont.)
22 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
Other
• Cisco Blogs (http://goo.gl/hBnkp2)
Resources (cont.)
22
23 © 2015 Cisco and/or its affiliates. All rights reserved. Cisco Confidential
Backup
24 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
YANG Model Example
containercommunity-sets{description“Containerforcommunitysets";listcommunity-set{keycommunity-set-name;description"Definitionsforcommunitysets";leafcommunity-set-name{typestring;description"nameofthecommunityset";}leaf-listcommunity-member{typestring{pattern'([0-9]+:[0-9]+)';}description"membersofthecommunityset";}}}
community-setCSET165172:1,65172:2,65172:3end-set!community-setCSET1065172:10,65172:20,65172:30end-set!
YANG CLI
25 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
Model Data Example
<community-sets><community-set><community-set-name>CSET1</community-set-name><community-member>65172:1</community-member><community-member>65172:2</community-member><community-member>65172:3</community-member></community-set><community-set><community-set-name>CSET10</community-set-name><community-member>65172:10</community-member><community-member>65172:20</community-member><community-member>65172:30</community-member></community-set></community-sets>
community-setCSET165172:1,65172:2,65172:3end-set!community-setCSET1065172:10,65172:20,65172:30end-set!
XML CLI
26 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
Model Data Example
community-setCSET165172:1,65172:2,65172:3end-set!community-setCSET1065172:10,65172:20,65172:30end-set!
{"community-sets":{"community-set":[{"community-set-name":"CSET1","community-member":["65172:1","65172:2","65172:3"]},{"community-set-name":"CSET10","community-member":["65172:10","65172:20","65172:30"]}]}}
JSON CLI
27 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
Main NETCONF Protocol Operations Operation Description get-config Retrieve all or part of a specified configuration
edit-config Loads all or part of a specified
configuration (merge, replace, create, delete, remove)
get Retrieve all or part of running configuration and device operational data
get-schema Retrieve device schema (model)
lock Lock entire configuration datastore (e.g. candidate)
unlock Remove lock on entire configuration datastore (e.g. candidate)
close-session Request graceful session termination
28 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
Main RESTCONF Protocol Operations Operation Description
GET Retrieve data for a resource (config/operational)
POST Create a configuration data resource
PUT Create or replace a configuration data resource
PATCH Merge configuration data with target resource
DELETE Delete a configuration data resource
29 © 2015 Cisco and/or its affiliates. All rights reserved. [email protected] - Cisco Confidential
Protocol Operations in Cisco IDL Operation Description
GetConfig Retrieve configuration data
MergeConfig Merge configuration data
DeleteConfig Delete configuration data
ReplaceConfig Replace configuration data
GetOper Retrieve operational data
CliConfig Merge configuration data in CLI format
ShowCmdTextOutput Retrieves CLI show-command output data