Subject: [lmap] yang data model / restconf interaction example

From: Juergen Schoenwaelder <[email-masked]>
Date: Thu, 19 Mar 2015 16:33:24 +0100

Hi,

we thought it might be useful if people can see an example showing how
a YANG data model leads to HTTP interactions on the wire by using
RESTCONF. So here is an example we came up with.

* RESTCONF Example Interactions

  We thought it might help if we provide an example how a YANG data
  model and RESTCONF result in HTTP protocol interactions on the wire.
  We decided to pick the configuration of a new schedule as an
  example. We will show the respective part of the data model, how
  that leads to an XML serialization of instance data and how a
  RESTCONF POST to create this instance data looks like on the wire.

** Data Model

   Below is a YANG tree diagram of a part of the data model covering
   schedules. This is taken from draft-schoenw-lmap-yang-02.

module: ietf-lmap
   +--rw lmap
      +--rw schedules
         +--rw schedule* [name]
            +--rw name      string
            +--rw action* [name]
            |  +--rw name           string
            |  +--rw task           leafref
            |  +--rw option* [name]
            |  |  +--rw name     string
            |  |  +--rw value?   string
            |  +--rw destination* [name]
            |     +--rw name        string
            |     +--rw output*     uint16
            |     +--rw schedule    leafref
            |     +--rw action      leafref
            +--rw timing    leafref

** XML Instance Data

   Here is an XML representation of instance data conforming to the
   YANG data model is shown below. Note that some of the strings are
   references to other portions of the instance data not show here.
   This is again taken from draft-schoenw-lmap-yang-02.txt.

  <lmap xmlns="urn:ietf:params:xml:ns:yang:ietf-lmap">
    <schedules>
      <schedule>
        <name>hourly</name>
        <action>
          <name>icmp-latency-hourly</name>
          <task>icmp-latency-measurement</task>
          <destination>
            <name>q-all</name>
            <schedule>daily</schedule>
            <action>report-daily</action>
          </destination>
        </action>
        <timing>hourly</timing>
      </schedule>
    </schedules>
  </lmap>

** RESTCONF POST to create an hourly schedule

   Here is an example showing how RESTCONF can be used to create the
   above schedule. The prefix C: indicates the controller, the prefix
   M: indicates the measurement agent. This example uses a JSON
   encoding (and note that much of the white-space can be removed, this
   is only there to help with readability).

  C: POST /restconf/data/ietf-lmap:lmap/schedules HTTP/1.1
  C: Host: example.com
  C: Content-Type: application/yang.data+json
  C:
  C:   {
  C:     "ietf-lmap:schedule": {
  C:       "name": "hourly",
  C:       "action": [
  C:         {
  C:           "name": "icmp-latency-hourly",
  C:           "task": "icmp-latency-measurement",
  C:           "destination": [
  C:             {
  C:               "name": "q-all",
  C:               "schedule": "daily",
  C:               "action": "report-daily"
  C:             }
  C:           ]
  C:         }
  C:       ],
  C:       "timing": "hourly"
  C:     }
  C:   }

  M: HTTP/1.1 201 Created
  M: Date: Mon, 23 Apr 2012 17:01:00 GMT
  M: Server: example-server
  M: Location: https://example.com/restconf/data/ietf-lmap:lmap/schedules/schedule=hourly
  M: Last-Modified: Mon, 23 Apr 2012 17:01:00 GMT
  M: ETag: b3a3e673be2

/js

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
Fax:   +49 421 200 3103         <http://www.jacobs-university.de/>