Re: [netmod] attributes in draft-lhotka-netmod-yang-json
Andy Bierman <andy@yumaworks.com> Sat, 22 March 2014 10:47 UTC
Return-Path: <andy@yumaworks.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 46D5B1A0954 for <netmod@ietfa.amsl.com>; Sat, 22 Mar 2014 03:47:31 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.622
X-Spam-Level:
X-Spam-Status: No, score=0.622 tagged_above=-999 required=5 tests=[FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bebXErs3lhvI for <netmod@ietfa.amsl.com>; Sat, 22 Mar 2014 03:47:28 -0700 (PDT)
Received: from mail-qg0-f50.google.com (mail-qg0-f50.google.com [209.85.192.50]) by ietfa.amsl.com (Postfix) with ESMTP id A69B21A0951 for <netmod@ietf.org>; Sat, 22 Mar 2014 03:47:28 -0700 (PDT)
Received: by mail-qg0-f50.google.com with SMTP id q108so10361226qgd.9 for <netmod@ietf.org>; Sat, 22 Mar 2014 03:47:28 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=zvZZY/RbnEHO2kHmipI96qINdsJ2r24zGDJp69qkmug=; b=HAjK39kU0gceSjxx1VX8NqKJS7sbBX94Va7Qv1jwcmZ6jtZ7pnAIKCBmGSoimX7uBQ lrqklvC5ma++qXTsio9n4oLlE4sCw/wfpwLhEaev2l0u+BdEq8PTSjogdHAqJSGIvFzu KfeRrHMCEdZswP2QWrTqOK8labMi23t4ia0yKgZLGGB8EXc4G/ADP28Ofo3tG6g3041b zxeHu3omnUOiT5MaqO/2S94PSnkni9gqwA52kQaoAYfpiajHZgCkqrxwjpTQS1MZgBsX 5KO9avNOEWxwlNphfdr7PnlsG0UTwnxkgrKtks1fGn1SlxKK+KPcbzTV31NFORgt0Spl +L9A==
X-Gm-Message-State: ALoCoQmabswZ+lKz3ESvAE10bLl1k9ZZ9G3gVD0WcKt7WsSVoO8/5DpeBdGIxARTcPa5nmnQrpFp
MIME-Version: 1.0
X-Received: by 10.224.89.71 with SMTP id d7mr62792999qam.54.1395485248345; Sat, 22 Mar 2014 03:47:28 -0700 (PDT)
Received: by 10.140.104.194 with HTTP; Sat, 22 Mar 2014 03:47:28 -0700 (PDT)
In-Reply-To: <m2bnwy7j0c.fsf@nic.cz>
References: <3FADE5E8-88AC-4FD0-A2F6-72F408FAFFC4@juniper.net> <20140320.150426.496532825.mbj@tail-f.com> <CABCOCHT3AJR0u=-GV1eM8geL-F2j7HSBsw0uBb1DYDvZio6eCA@mail.gmail.com> <CABCOCHSM7CwAPFOZ4qzzTtTRRX0LWE2Gb+ZWzmDpwBGSKRGhOg@mail.gmail.com> <m2bnwy7j0c.fsf@nic.cz>
Date: Sat, 22 Mar 2014 03:47:28 -0700
Message-ID: <CABCOCHSZd_460W-u4Opc+A2sdkXs=57WHgD9OpZ26=HjP1=PRg@mail.gmail.com>
From: Andy Bierman <andy@yumaworks.com>
To: Ladislav Lhotka <lhotka@nic.cz>
Content-Type: multipart/alternative; boundary="001a11c3e166846b5c04f52fba58"
Archived-At: http://mailarchive.ietf.org/arch/msg/netmod/GfZw0Xjld5qaN4Jb_7em5lVNfL8
Cc: "netmod@ietf.org" <netmod@ietf.org>
Subject: Re: [netmod] attributes in draft-lhotka-netmod-yang-json
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 22 Mar 2014 10:47:31 -0000
On Sat, Mar 22, 2014 at 1:08 AM, Ladislav Lhotka <lhotka@nic.cz> wrote: > Andy Bierman <andy@yumaworks.com> writes: > > > On Thu, Mar 20, 2014 at 8:25 AM, Andy Bierman <andy@yumaworks.com> > wrote: > > > >> > >> > >> > >> On Thu, Mar 20, 2014 at 7:04 AM, Martin Bjorklund <mbj@tail-f.com> > wrote: > >> > >>> Dean Bogdanovic <deanb@juniper.net> wrote: > >>> > Hi, > >>> > > >>> > In draft yang leaf node is defined as name value pair in json > >>> > > >>> > If it would be represented, as an object then we can assign > attributes > >>> to it. > >>> > > >>> > Example > >>> > "host-name" { > >>> > "data" : "router", > >>> > "attributes" : { "protect" : protect} > >>> > } > >>> > > >>> > We need attributes for several things, so lets try to figure out how > to > >>> enable > >>> > them. > >>> > >>> I agree that the lack of attributes is a problem with the JSON > >>> mapping. > >>> > >>> The problem with your solution is that it adds noise to the normal > >>> case where there are no attributes. We're using another encoding: > >>> > >>> "host-name": "router", > >>> "@host-name": { > >>> "protect": "protect", > >>> ... > >>> } > >>> > >>> Yep, not very elegant... > >>> > >>> > > > > More importantly, it doesn't work for lists or leaf-lists. > > The attributes cannot be siblings (or ancestors) of the target data node. > > An option for boolean-type properties is to wrap the affected object or > value, e.g. > > "@protect": { > "host-name": ... > } > > or > > "foo" : [ 1, 2, {"@protect": 3}, 4] > > Instead of defining a general JSON equivalent of XML attributes, it might > actually be easier to come up with an ad hoc representation for every use > case. This is the approach of some native JSON applications such as MongoDB. > > So, the specification of each global property (e.g. "protected") would > also define an appropriate encoding in both XML and JSON. > > > > > Consider the following YANG data-stmt, and how an attribute > > would be encoded in every data node (as a worse-case example). > > > > > > container top { > > list A { > > key id; > > leaf id { type string; } > > leaf-list aa { type int8; } > > } > > leaf host-name { type string; } > > } > > > > Plain JSON > > > > { "top" : { > > "A" : [ > > { "id":"entry-1", > > "aa": [42, 19] > > }, > > { "id":"entry-2", > > "aa" : [99, 11] > > } ] > > }, > > "host-name":"router" > > } > > > > Add attribute to each node: > > leaf owner { type string; } > > > > With Owner Attribute using RESTCONF encoding: > > > > { "top" : { > > "@owner":"system", > > "A" : [ > > { "@owner":"admin1", > > "id" : { > > "@owner":"admin1", > > "id": "entry-1" > > }, > > "aa" : [ { "@owner":"admin1", "aa": 42 }, > > { "@owner":"admin1", "aa": 19 } ] > > }, > > { "@owner":"admin2", > > "id" : { > > "@owner":"admin2", > > "id": "entry-2" > > }, > > "aa" : [ { "@owner":"admin2", "aa": 99 }, > > { "@owner":"admin2", "aa": 11 } ] > > } ] > > }, > > "host-name" : { "@owner":"system", > > "host-name":"router" } > > } > > > > > > This is not elegant either, but it works for all YANG node types. > > How would your encoding look for this example? > > "@owned-object": { > "@owner": "system", > "host-name": "router" > } > > Can you show how 2 list entries and 2 leaf-list entries have different attribute values. Of course we need to support string values, not just boolean. > Lada > Andy > > > > > > > > > Andy > > > > > > > > > >> > >> This is how RESTCONF encodes these attributes in a leaf: > >> (see sec. 3.4.1) > >> > >> "host-name" : { > >> "@protect" : "protect", > >> "host-name" : "router" > >> } > >> > >> Lada says that this is a YANG to JSON mapping and YANG has no > attributes, > >> so the attribute encoding is in RESTCONF. I think it would be better > >> if there was 1 mapping, instead of a different mapping in each protocol > >> that uses this JSON encoding of YANG data. > >> > >> I do not think YANG needs to model attributes! > >> The protocol may need to use them to tag data with meta-data. > >> We do not need to model some leafs as attributes and others > >> as child nodes in YANG data models. Use RelaxNG instead > >> of YANG to do that. > >> > >> > >> > >> > >>> /martin > >>> > >>> > >> Andy > >> > >> > >>> _______________________________________________ > >>> netmod mailing list > >>> netmod@ietf.org > >>> https://www.ietf.org/mailman/listinfo/netmod > >>> > >> > >> > > _______________________________________________ > > netmod mailing list > > netmod@ietf.org > > https://www.ietf.org/mailman/listinfo/netmod > > -- > Ladislav Lhotka, CZ.NIC Labs > PGP Key ID: E74E8C0C >
- [netmod] attributes in draft-lhotka-netmod-yang-j… Dean Bogdanovic
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Ladislav Lhotka
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Martin Bjorklund
- Re: [netmod] attributes in draft-lhotka-netmod-ya… Andy Bierman