NETCONF/YANG Workshop Overview
NETCONF/YANG Workshop Overview
●   NETCONF/YANG Overview
●   YANG basics
●   YANG advanced
●   NETCONF basics
●   NETCONF advanced
●   OpenDaylight NETCONF/YANG and RESTCONF
●   Troubleshooting
●   Demo
●   Tooling, References etc.
NETCONF/YANG Overview
 Why NETCONF/YANG – RFC3535
                                                             configur
                                                             ation
RFC3535 - legacy situation
              OSS
              NMS
              EMS
          NETCONF
          Manager
      Cost and
     complexity     •   No well-defined protocols and
                        data-models
                    •   Lack of atomicity
                    •   Ordering problem
RFC3535 - NETCONF/YANG solution
            OSS
            NMS
            EMS
        NETCONF
        Manager
    Reduced                       Cost/
    Cost and                      Value
   complexity     Transactions
                  Models
                  Standardized
                  Protocols
So what is a data model anyway?
                                YANG Models
                                      Yang
                                      Model
                                        s
                    NETCONF
                     NETCONF
                    Manager
NETCONF
 Mgmt info
                         YANG modules
 (definition)                                          Manager (client)
 Mgmt info
                     XML-encoded content
 (payload)
    Mgmt info
                                  YANG modules
    (definition)
     Remote          XML
                                   HTTP          I2RS   ODL
    Operations       RPC
                     TLS,
    Transport                       TCP
                     SSH
How are YANG modules structured?
acme-box module
properties container
interfaces container
                    Header information
                    Imports & Includes
Type definitions
               Fragment     import
                A.yang
                    include                          Fragment
                                                      E.yang
               Fragment
                B.yang
                                         Imported fragments are just
     include              include        referenced, not included
      Fragment        Fragment
       C.yang          D.yang
percent
completed
                                       <completed>50</completed
                                       >
Common YANG Types
                                      target
                                             address
                                             port
                                      peer
                                           destination
                                               address
                                               port
                                              <host—name>my-host</host-name
                                              >
                                              <cpu-temp>62</cpu-temp>
  YANG Data Declarations – Leaf-List
• Holds multiple values of a particular type
• Has no children
                                                             domain-search
                                               <domain-search>foo.com</domain-search
                                               >
                                               <domain-search>bar.com</domain-search
YANG Data Declarations – List Statement
user
user
user
●   The file name and the module name must be the same
●   The namespace is a global unique URI (Unique Resource Identifier)
●   The prefix is to define the prefix associated with the module and its
    namespace
●   The revision define the date when this module was first created. You
    would change the revision date after updating an existing yang file
YANG Basics
<dependencies>
    <dependency>
        <groupId>org.opendaylight.mdsal.model</groupId>
        <artifactId>ietf-yang-types-20130715</artifactId>
    </dependency>
</dependencies>
YANG Basics
                    Header information
                    Imports & Includes
Type definitions
Instance Data:
                                 <connection-status>connected</connection-status
                                 >
 Advanced YANG Types - Unions
Union - a value that represents one of its member types
Instance Data:
<threshold>50</threshold>
Or:
                                         <threshold>disabled</threshold>
 Advanced YANG Types - Choice
Choice - allows one of several alternatives              transfer-method
                                                                   transfer-interval
                                                                   transfer-on-commit
Instance Data:
                                        <transfer-interval>120</transfer-interval
                                        >
                                        Or:
                                        <transfer-on-commit/>
Advanced YANG Types - Choice
• Each alternative may consist of multiple definitions
• Use case statement to group them
• Note that choice and case do not appear in instance data
Instance Data:
                                       <threshold>60</threshold>
                                       <ignore-count>3</ignore-count>
                                       <ignore-time>30</ignore-time>
                                       <reset-time>120</reset-time>
Advanced YANG Types - Identity
                 refer back
                  to base
                                 leaf refers to
                                 base identity
Advanced Data Definition - Augment
Context node
                                                                              Information to
                                                                           augment the context
                                                                                node with
Instance Data:
                   <interfaces>
                     <ifEntry>
                       <ifIndex>1</ifIndex>
                       <ifType>ds0</ifType>
                       <ifMtu>1500</ifType>
                       <ds0ChannelNumber>13<ds0ChannelNumber>
                     </ifEntry>
                   </interfaces>
             Effectively equivalent
                to the following
 YANG Constraints – must statement
           Xpath expression to
           validate against data
YANG RPCs
                                               activate-software-image
                                                    image
                                                    status
YANG Notifications
Instance-identifier values
<change>/ex:system/ex:services/ex:ssh/ex:port</change>
<change>/ex:system/ex:user[ex:name='fred']/ex:type</change>
<change>/ex:system/ex:server[ex:ip='192.0.2.1'][ex:port='80’]</change>
 YANG Extensions
                                      Deviation A
      A
     if-feature individualStats
      if-feature aggregatedStats
YANG Advanced
●   Operation’s name
●   Input parameters
●   Output parameters
YANG Advanced
Create a Notification
●   Notification allows you to get notify when a change occurs for a given path
    in the module
●   Let’s define a notification that will be send when we’re out of gaz
YANG Advanced
Create a Grouping
●   The grouping statement is used to define a reusable block of nodes. In
    this grouping, we will define characteristic for our augmentation.
YANG Advanced
Create a Augmentation
●   Augment the car-info container with the created grouping
●   The augmentation will add extra information to the existing container. This
    augmentation will thus provide all the information provided by car-info plus
    the information from sport-car.
YANG Advanced
Netconf is connection-orientated
    SSH, TLS as underlying transport
Netconf client (“manager”) establishes session with server (“agent”)
Data is XML-encoded
Based on RPCs
• <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id=”100">
Defined in RFC4741 (NETCONF 1.0) and RFC6241 (NETCONF 1.1)
• ODL supports NETCONF 1.1
Call-home being standardised
• Enables managed device to contact server
 The NETCONF Hello
<validate> (:validate)
• Copy candidate to running
• Discard changes in candidate (copy running to candidate)
<create-subscription> (:notification)
<get-schema> (:ietf-netconf-monitoring)
NETCONF Basics
● Get ConfD
$ sudo wget -O confd.tar.gz https://db.tt/ClWpS3qR
$ tar xvf confd.tar.gz
$ sudo mv confd /opt
● Start ConfD:
$ /opt/confd/bin/confd
For each existing yang model, there is its associated .fxs file
NETCONF Basics
● Generate the .fxs file for the yang files (ConfD’s YANG binary)
$ cd /opt/confd/etc/confd
$ /opt/confd/bin/confdc -c /opt/confd/etc/confd/car.yang
$ ls | grep car
car.fxs car.yang
● We now have both our yang file and its associated ConfD’s binary
NETCONF Basics
$ /opt/confd/bin/confd --stop
$ /opt/confd/bin/confd --start-phase0
$ /opt/confd/bin/confd --start-phase1
$ /opt/confd/bin/confd --start-phase2
NETCONF Basics
$ /opt/confd/bin/confd --status
--[cut]--
SMP support: no
Using epoll: no
running modules: backplane,netconf,cdb,cli
status: started
namespaces: urn:opendaylight:car prefix:car exported to: all
          urn:ietf:params:xml:ns:yang:iana-crypt-hash prefix:ianach exported to: all
          urn:ietf:params:xml:ns:yang:ietf-inet-types prefix:inet exported to: all
--[cut]--
YANG data models:
  module: car revision: 2016-06-09
          namespace: urn:opendaylight:car
          prefix: car
          exported to: all
--[cut]--
NETCONF Basics
● Help
  $ /opt/confd/bin/netconf-console-tcp --help
● Hello Message
  $ /opt/confd/bin/netconf-console-tcp --hello
● Get-schema
  $ /opt/confd/bin/netconf-console-tcp --get-schema=car
NETCONF Basics
● Get-config
  $ /opt/confd/bin/netconf-console-tcp --get-config
  Specify the database:
  $ /opt/confd/bin/netconf-console-tcp --get-config --db candidate
 ● Lock Payload
<lock>
       <target>
              <running/>
       </target>
</lock>
 ● Unlock Payload
<unlock>
       <target>
              <running/>
       </target>
</unlock>
NETCONF Basics
 ● Edit-config Payload
<edit-config>
       <target>
              <candidate/>
       </target>
       <config>
              <car-info xmlns="urn:opendaylight:car"
                     xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
                     nc:operation="merge">
                     <max-speed>220</max-speed>
                     <gaz-tank-state>low</gaz-tank-state>
                     <car-id>1</car-id>
              </car-info>
       </config>
</edit-config>
NETCONF Basics
 ● Response
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
 <ok/>
</rpc-reply>
● Get-config
  $ /opt/confd/bin/netconf-console-tcp --get-config --db candidate
● Response
   <?xml version="1.0" encoding="UTF-8"?>
   <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
    <data>
           <car-info xmlns="urn:opendaylight:car">
           <max-speed>220</max-speed>
           <gaz-tank-state>low</gaz-tank-state>
           <car-id>1</car-id>
           </car-info>
     </data>
   </rpc-reply>
NETCONF Advanced
NETCONF/YANG vs SNMP
                                     Ability to express hierarchy
      Definition language:          (compare MIBs: flat + tables)     Definition language:
            YANG                    Richer conditions, constraints          SMIv2
                                      Facilities for easier reuse
                                         RPC/Action support
      Information model:            Import conversion rules exist     Information model:
       YANG modules                       (MIBs → YANG)                 MIB modules
                                          “instant content”
                                        Human readability
       Instantiated data:              Dynamic extensibility           Instantiated data:
             XML                        B2B, Web toolkits                ASN.1 BER
                                     Bulk vs only incremental ops
                                     (manipulation of config files,
           Transport:                      e.g. edit-config)
                                                                          Transport:
           Netconf                       Transaction support                SNMP
        or possibly other            Configuration vs monitoring
 (no inherent dependency but
 will require different bindings)
  What makes NETCONF better than SNMP?
                     This is where the difference is:
                      In the supported use cases!
Use Case                                                SNMP              NETCONF
Get collection of status fields                         Yes               Yes. Bulk xfer up to
                                                                          10x faster.
<notification xmlns="urn:ietf:params:netconf:capability:notification:1.0">
     <netconf-capability-change xmlns="urn:ietf:params:xml:ns:yang:. . . “>
          <changed-by><server/></changed-by>
          <added-capability>. . .</added-capability>
     </netconf-capability-change>
     <eventTime>2016-09-21T11:22:52-07:00</eventTime>
</notification>
NETCONF Advanced
● RPC
Execute the RPC using the netconf-console in interactive mode
$ /opt/confd/bin/netconf-console-tcp -i
● RPC response
  “Not yet implemented”
● Add the following into the file, “medium” will be the output
    #!/bin/sh
    mesg=medium
    echo "current-trank-state $mesg"
NETCONF Advanced
● Regenerate car.fxs
$ rm car.fxs
$ /opt/confd/bin/confdc -c car.yang
 ● RPC Response
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
 <current-trank-state xmlns="urn:opendaylight:car">medium</current-trank-state>
</rpc-reply>
NETCONF Advanced
● Notification (rfc5277)
Requires notifications.yang
http://www.netconfcentral.org/modulereport/notifications
Payload
<create-subscription xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
       <stream>YOUR-DEFINED-STREAM</stream>
</create-subscription>
NETCONF Advanced
                       RESTCONF
      Node Inventory   Model Cache    MD-SAL
NETCONF
$ sudo ./Training/opendaylight/distribution-karaf-0.5.0/bin/karaf
opendaylight-user@root>netconf:list-devices
opendaylight-user@root>feature:install odl-mdsal-apidocs
→ http://localhost:8181/apidoc/explorer/index.html
opendaylight-user@root>feature:install odl-dlux-yangui
→ http://localhost:8181/index.html#/yangui/index
OpenDaylight NETCONF/YANG and
RESTCONF
Editor plug-ins:
•   emacs (yang-mode.el)
•   vim (yang.vim)
•   sublime text (sublime-yang-syntax)
pyang
• an extensible YANG validator written in Python.
• can be used standalone to validate YANG modules, or to translate YANG to YIN, XSD,
  DSDL etc.
• can be integrated into other applications
libsmi
• a library allowing the generation of YANG models from SMI/SMIv2 compliant MIBs
• has a variety of supporting tools available for generation, debug etc.
    “Run-Time” Tooling
ncclient
     a Python library that facilitates client-side scripting and application development around the
     NETCONF protocol
Postman
• a Chrome app for REST APIs, allowing for customized sets of REST snippets to be easily
  built, maintained and shared
• Useful for accessing ODL RESTCONF APIs
OpenDaylight
•   ODL auto-generates RESTCONF and NETCONF APIs from YANG models
•   apidocs provides a way to explore both local and mounted YANG models
•   YANG-UI provides a model-driven WEB UI for exploring YANG models
•   YANGman is a YANG-aware Postman equivalent
Thanks