Device(Programmability Using(YANG(Development(Kit · [email protected] NETCONF RESTCONF gRPC XML...

26
Santiago Álvarez June 2016 Device Programmability Using YANG Development Kit @111pontes

Transcript of Device(Programmability Using(YANG(Development(Kit · [email protected] NETCONF RESTCONF gRPC XML...

Page 1: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

Santiago  Álvarez

June  2016

Device  Programmability  Using  YANG  Development  Kit

@111pontes

Page 2: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

NETCONF gRPCRESTCONF

XML JSON

Model-­Driven  Programmability  Stack

Model-­Driven  APIsYANG  Development  Kit  (YDK)

YANG  Models  (native,  open,   common)

XR  Data  Model  Database

App1 App2 App3

Models

Encoding

Protocol

APIs

Apps

SSH HTTPTransport

Page 3: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

• 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

Page 4: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

• Simplify  app  development

• Abstract  transport,  encoding,  modeling  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

4

YANG  ModelClass  Hierarchy

(Python,  C++,  Ruby,  Go)

Page 5: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

• Model  structures  data  (config and  operational)  as  a  tree

• Models  files  are  self-­documented  and  ship  with  devices  

• Cisco  IOS  XR  supports  180+  YANG  models  (config and  operational)  in  release  6.0.1

• Native  models  provide  most  coverage

• OpenConfig and  IETF  models  are  mapped  to  native  models

• OpenConfig (BGP,  Routing  Policy,  MPLS,  Interfaces)

XR  Data  Models

Native  /  Common OpenConfig  /  IETF

Page 6: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

Generation  of  Model-­Driven  APIs  Using  YANG  Development  Kit  (YDK)

YANGYANGYANG

Data  Models  (YANG)

APIGenerator

DocsPython

C++

: :

Ruby

go

Docs

Docs

Docs

C♯ Docs

YDK-­gen

YDK-­PyYDK

Page 7: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

YDK-­Py API  Structure

Models(BGP,  IS-­IS,  etc)

Services(CRUD,  NETCONF,  etc.)

Providers(NETCONF,  Codec,  etc.)

• Models group  Python  APIs  created  for  each  YANG  model

• Services perform  operations  on  model  objects  (interface)

• Providers implement  services  (implementation)

Page 8: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

• 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)

Page 9: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

#  Cisco  YDK-­‐Py OC-­‐BGP  “Hello  world”from ydk.services import CRUDServicefrom ydk.providers import NetconfServiceProviderfrom ydk.models.bgp import bgp

if __name__  == "__main__":provider  = NetconfServiceProvider(address=10.0.0.1,

port=830,username=“admin”,password=“admin”,protocol=“ssh”)

crud  = CRUDService()   #  create  CRUD  servicebgp = bgp.Bgp() #  create  oc-­‐bgp objectbgp.global_.config.as_  = 65000 #  set  local  AS  numbercrud.create(provider, bgp) #  create  on  NETCONF  deviceprovider.close()exit()

# End  of  script

A  YDK-­Py “Hello  World”  Using  OC-­BGP

module:  openconfig-­‐bgp+-­‐-­‐rw bgp!

+-­‐-­‐rw global|    +-­‐-­‐rw config|    |    +-­‐-­‐rw as|    |    +-­‐-­‐rw router-­‐id?      |    +-­‐-­‐ro state|    |    +-­‐-­‐ro as|    |    +-­‐-­‐ro router-­‐id?                |    |    +-­‐-­‐ro total-­‐paths?            |    |    +-­‐-­‐ro total-­‐prefixes?      

...

Page 10: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

Releases

• CRUD  service,  NETCONF  provider

• Python  APIs  for  XR  native  and  OpenConfig models

• Client-­side  validation

• Netconf service  

• Codec  service  (py2xml  /  xml2py)

• Validation  of  YANG  deviations

• Improved  error  reporting

• Improved  logging

• Model  bundles

• Additional  languages  (Ruby,  C++)

• Enhanced  error  reporting

• Model-­driven  telemetry

• YDK  app  maker

• YANG  RPC  support

0.3.0 0.4.0 Roadmap0.4.1

• Netconf service  

• Codec  service  (py2xml  /  xml2py)

• Validation  of  YANG  deviations

• Improved  error  reporting

• Improved  logging

Page 11: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

Demo

Page 12: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

carreras

YDK  Demo  Testbed

domingo pavarotti

YDK  Sample  Apps

NETCONF Management  network

Page 13: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

Cisco  Live  Las  Vegas

• LTRSPG-­2601  -­ Cisco  IOS  XR  Programmability  Lab  (4hrs)

• DEVNET-­2057  -­ Ok,  We  Got  YANG  Data  Models,  Now  What?

• YDK  Self-­paced  Lab

Upcoming  Events

13

Page 14: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

GitHub

• 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)

• Cisco  IOS  XR  YANG  models  (https://git.io/vg7fk)

• YANG  Explorer  (https://git.io/vg7Jm)

DevNet

• YDK  at  DevNet (https://developer.cisco.com/site/ydk/)  

• Cisco  IOS  XR  6.0  at  DevNet (https://developer.cisco.com/site/ios-­xr/)  

Resources

14

Page 15: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

YDK  Sandboxes

• Ubuntu  YDK-­PY  Vagrant  box  (https://git.io/vaw1U)

• YDK  on  dCloud.cisco.com  – Coming  soon

YDK  Support

• Cisco  support  community  (https://communities.cisco.com/community/developer/ydk)

Other

• Blog  (http://blogs.cisco.com/author/santiagoalvarez)

• Twitter  (@111pontes)

Resources  (cont.)

15

Page 16: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

Programming

• Codecademy:  Learn  to  code  interactively  (https://www.codecademy.com)

• Code  School:  Learn  by  Doing  (https://www.codeschool.com)

• Learning  Git and  GitHub  (https://git.io/vTmHO)

Resources  (cont.)

16

Page 17: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

Thank  you!

+

Page 18: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

Backup

Page 19: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

carreraslo0172.16.255.2/32

YDK  Demo  Testbed

domingo

172.16.1.0/31

lo0172.16.255.1/32

pavarotti

lo0172.16.255.3/32

director

10.30.110.82 10.30.110.83 10.30.110.84

10.30.110.85

.0 .1 .4 .5172.16.1.0/31 172.16.1.0/31

.2 .3

gi0/0 gi0/1 gi0/0 gi0/1

gi0/1 gi0/0

YDK  Sample  Apps

NETCONF

Page 20: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

• 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  valueNode  with  a  value

Leaf  list

Container(grouping)

Container(presence)

List

key

Page 21: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

YANG  Model  Example

container community-­‐sets {description “Container  for  community  sets";list community-­‐set {key community-­‐set-­‐name;description "Definitions  for  community  sets";leaf community-­‐set-­‐name {type string;description "name  of  the  community  set";

}leaf-­‐list community-­‐member {type  string  {pattern '([0-­‐9]+:[0-­‐9]+)';

}description "members  of  the  community  set";

}}

}

community-­‐set CSET165172:1,65172:2,65172:3

end-­‐set!community-­‐set CSET10

65172:10,65172:20,65172:30

end-­‐set!

YANG CLI

Page 22: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

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-­‐set CSET165172:1,65172:2,65172:3

end-­‐set!community-­‐set CSET10

65172:10,65172:20,65172:30

end-­‐set!

XML CLI

Page 23: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

Model  Data  Example

community-­‐set CSET165172:1,65172:2,65172:3

end-­‐set!community-­‐set CSET10

65172:10,65172:20,65172:30

end-­‐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

Page 24: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

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

XML

YANG

SSH

Page 25: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)

[email protected]

Main  NETCONF  Protocol  OperationsOperation Descriptionget-­config Retrieve  all  or  part  of  a  specified  configuration

edit-­configLoads  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

Page 26: Device(Programmability Using(YANG(Development(Kit · saalvare@cisco.com NETCONF RESTCONF gRPC XML JSON ModelGDriven(ProgrammabilityStack Model3Driven9APIs YANG9Development9Kit9(YDK)