Subject: Re: [netmod] Key-value data structures in YANG/JSON encoding

From: Juergen Schoenwaelder <[email-masked]>
Date: Wed, 1 Oct 2014 09:08:09 +0200

On Tue, Sep 30, 2014 at 04:31:03PM -0400, Y. Richard Yang wrote:
 
> A particular example of using key-value map is the network-map, which is
> defined as a key-value store to enforce that each named endpoint address
> group has a unique name. A specific example is in Section 11.2.1.7 of RFC
> 7285 (http://www.rfc-editor.org/rfc/rfc7285.txt):
> 
>          "network-map" : {
>            "PID1" : {
>              "ipv4" : [
>                "192.0.2.0/24",
>                "198.51.100.0/25"
>              ]
>            },
>            "PID2" : {
>              "ipv4" : [
>                "198.51.100.128/25"
>              ]
>            },
>            "PID3" : {
>              "ipv4" : [
>                "0.0.0.0/0"
>              ],
>              "ipv6" : [
>                "::/0"
>              ]
>            }

Since YANG's native encoding is XML, how would you represent this in
XML with the restriction that XML element names are defined by the
data model and all values are in XML elements?

/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/>

---

From: "Y. Richard Yang" <[email-masked]>
Date: Wed, 1 Oct 2014 15:23:49 -0400

> data model and all values are in XML elements?

Would you consider this as a limitation of the restriction?

With the restriction, if we have the YANG data type to introduce key-value
store, for XML, the Mapping Rule may still be that of using two elements
with name and value: pid-name = (or just key as name), pid-value = (or
value). But for json and languages that support maps, the mapping does not.
Make sense?

Richard

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Thu, 2 Oct 2014 09:15:23 +0200

> value). But for json and languages that support maps, the mapping does not.

I am saying that YANG was designed to model data carried by NETCONF
(check the title of RFC 6020) and NETCONF uses XML as its data
encoding with a set of restrictions that were found useful to simplify
things (all data in XML elements, no mixed content, ...). Several
details of the YANG language are related to XML (e.g., much of the
type system, the usage of xpath in must/when expressions, instance
identifier as a subset of xpath, ...).

Alternate _encodings_ are proposed (such as JSON) but the question
raised here seems to be whether we want to start an effort to turn
YANG into a schema language for JSON (which it is not today and this
is by design and not by accident).

/js

---

From: Martin Bjorklund <[email-masked]>
Date: Thu, 02 Oct 2014 10:46:02 +0200 (CEST)

> is by design and not by accident).

I think the question is if it would be a good idea to add a "map"
keyword to YANG.  Then, if we have "map", we can decide how to encode
it in XML and JSON.

For the record, I do not think we should add this.  I am not sure when
it is a good idea to model an open-ended map (i.e., with keys that are
not formally defined).  In many cases I think it is better with
something like:

  list my-map {
    key "key";
    leaf key {
      type identityref { ... } // this means all keys are
                               // formally defined in YANG
    }
    leaf value {
      type string;
    }
  }

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 02 Oct 2014 15:03:50 +0200

> data model and all values are in XML elements?

Moreover, even in JSON we have to work with essentially the same schema
as in XML, so as to be able to interpret XPath expressions in the data
model.

So indeed, a new data node type would be needed for this.

Lada

> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod

-- 
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C

---

From: "Y. Richard Yang" <[email-masked]>
Date: Thu, 2 Oct 2014 14:25:24 -0400

Hi Juergen,

> identifier as a subset of xpath, ...).
Yes. The binding of YANG as a data description language to XML is clear.

> is by design and not by accident).
Good comment. My personal opinion, JSON is widely used enough to justify
this effort.

Richard