Re: [netmod] attributes in draft-lhotka-netmod-yang-json

Andy Bierman <andy@yumaworks.com> Sun, 23 March 2014 15:24 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 3F4DB1A6FC4 for <netmod@ietfa.amsl.com>; Sun, 23 Mar 2014 08:24:55 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.978
X-Spam-Level:
X-Spam-Status: No, score=-1.978 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham
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 Dw5aSsr9Dkjc for <netmod@ietfa.amsl.com>; Sun, 23 Mar 2014 08:24:50 -0700 (PDT)
Received: from mail-qa0-f44.google.com (mail-qa0-f44.google.com [209.85.216.44]) by ietfa.amsl.com (Postfix) with ESMTP id 234D41A08CC for <netmod@ietf.org>; Sun, 23 Mar 2014 08:24:49 -0700 (PDT)
Received: by mail-qa0-f44.google.com with SMTP id f11so4311459qae.17 for <netmod@ietf.org>; Sun, 23 Mar 2014 08:24:49 -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=qgGZxt6Xe64ZL3PjXf1eTCe6VF4AaLqjGS05gbSbAAc=; b=HtGIqpKw90qp2gB0d+8JnnHymvXKkC1N8Tlni0SXQ42dQUX3OC0tjtQx+DcJDaFdL6 WnHvGR4I4C+v0zqDizYcZNXt5+FmvAqsacGZUynT+5U/t5/Tp2LJL+nyBWS4Ye0ZTz92 yimfwYEX7MVtiLp1rRgC7mVvSlFU9TVwtxDuMMAVJaBf5PlmmKCaqgKfPTHjTq2mxq+w /d2q+124pizCzLn7Xj+ibBNvh0lH3tGF8pv+1MyJVHlajm8wiK7dIoDnn4AkgYserZ9r FX1484w/9uwCutWRYc7EoKqtFMNXA7OesNU7tiIuoPt/1apyf0GR/scQ4YCNLrkDimu+ jMKQ==
X-Gm-Message-State: ALoCoQmejSSO6NFGX1v6VgP+Sa1FxTV5qaVe5JBtY3/cpVLkDJ6gHQ89++JgyrhY2zTiGh8j6PpX
MIME-Version: 1.0
X-Received: by 10.224.66.8 with SMTP id l8mr69703208qai.16.1395588289362; Sun, 23 Mar 2014 08:24:49 -0700 (PDT)
Received: by 10.140.104.194 with HTTP; Sun, 23 Mar 2014 08:24:49 -0700 (PDT)
In-Reply-To: <m2k3blar7e.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> <CABCOCHRFjzj40nWtckJRPCbxCMSwojadRh0rBb27qMRyHx8MHA@mail.gmail.com> <m2ob0xb697.fsf@nic.cz> <CABCOCHS0=fODFFaf_2kDZVcbGAd=BuvJXCpR5-K3uQFXy+PAsw@mail.gmail.com> <m2k3blar7e.fsf@nic.cz>
Date: Sun, 23 Mar 2014 08:24:49 -0700
Message-ID: <CABCOCHRZLp52pgMhi0tKs3=vLZLkAQcw=iK4TG77BArSCK8-_g@mail.gmail.com>
From: Andy Bierman <andy@yumaworks.com>
To: Ladislav Lhotka <lhotka@nic.cz>
Content-Type: multipart/alternative; boundary="001a11c2c27a3dac2704f547b82b"
Archived-At: http://mailarchive.ietf.org/arch/msg/netmod/3fr3-36JSN8e7wVU53bpMtqBCmQ
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: Sun, 23 Mar 2014 15:24:55 -0000

On Sun, Mar 23, 2014 at 8:07 AM, Ladislav Lhotka <lhotka@nic.cz> wrote:

> Andy Bierman <andy@yumaworks.com> writes:
>
> > On Sun, Mar 23, 2014 at 2:42 AM, Ladislav Lhotka <lhotka@nic.cz> wrote:
> >
> >> Andy Bierman <andy@yumaworks.com> writes:
> >>
> >> ...
> >>
> >> >
> >> > The attribute mapping needs to correspond to the XML attribute
> mapping.
> >> > Attributes have string values, so the mapping above will not work.
> >>
> >> I don't understand. XML schemas can define attribute values to be of
> other
> >> types, too, not only string.
> >>
> >>
> > I meant they are encoded in XML as quoted strings
> >
> >
> >> >
> >> > Attributes can be qualified or unqualified.  If qualified, then the
> >> > module-name
> >> > is used as a prefix:
> >> >
> >> >   "foo" [ 1, 2, { "@foo-mod:owner":"admin1", "foo":3}, {
> >> > "@foo-mod:owner":"admin2", "foo":4},
> >> >
> >> >
> >> > This approach presumes the attribute has a YANG module name that
> defines
> >> > the attribute,
> >> > which is of course not allowed.
> >> >
> >> > RFC 6241 defines XML attributes for the <get> operation, using a hack
> >> > called the  'get-filter-element-attributes' extension.
> >> >
> >>
> http://www.netconfcentral.org/modules/ietf-netconf/2011-06-01#get-filter-element-attributes.56
> >>
> >> This is another extension that violates the rule stated in RFC 6020,
> sec.
> >> 6.3.1:
> >>
> >>    If a YANG compiler does not support a particular extension, which
> >>    appears in a YANG module as an unknown-statement (see Section 12),
> >>    the entire unknown-statement MAY be ignored by the compiler.
> >>
> >> >
> >> > The NETCONF-EX <get2> operation has a "with-metadata" parameter that
> uses
> >> > identities
> >> > to map attributes to YANG.
> >> >
> >> > I think a standard mechanism is needed to properly map attributes to
> JSON
> >> > and XML.
> >>
> >> I'd suggest to define two generic constructs:
> >>
> >> 1. Metadata
> >>
> >> Every JSON value (false / null / true / object / array / number /
> string)
> >> can be changed into a "@tagged-value" object, e.g. the number 42 can
> become
> >>
> >> {
> >>   "@tagged-value" : {
> >>     "@owner": "admin1",
> >>     "@value": 42
> >>   }
> >> }
> >>
> >> Multiple metadata key-value pairs may be present inside the
> >> "@tagged-value" object.
> >>
> >>
> > I don't think this works for lists and leaf-lists.
> > Can you expand the encoding to show a real example with
> > container, list, leaf, and leaf-list used?
>
> container
> =========
>
> "foo": { "bar": 42 }
>
> becomes
>
> "foo": {
>   "@tagged-value": {
>     "@tag1": 54,
>     "@value": { "bar": 42 },
>     "@tag2": "hi!"
>   }
> }
>
> leaf
> ====
>
> "bar": 42
>
> becomes
>
> "bar": {
>   "@tagged-value": {
>     "@tag3" = false,
>     "@value": 42
>   }
> }
>
> leaf-list
> =========
>
> "foos": [ 6, 3, 7, 8]
>
> when tagging the whole array becomes
>
> "foos": {
>   "@tagged-value": {
>     "@value": [ 6, 3, 7, 8 ]
>     "tag4": true
>
> or, when tagging only one entry, becomes
>
> "foos":
>   [ 6,
>     { @tagged-value: { "@tag5": 1, "@value": 3 } },
>     7,
>     8
>   ]
>
> list
> ====
>
> is analogical, only scalar values (numbers in the above example) will be
> replaced with objects.
>



Try the example I did where entry1 is owned by owner admin1 and entry2
is owned by admin2.  I don't think this works.

This approach is way too complicated. The encoding scheme in the RESTCONF
draft
is easier to implement and it works for list and leaf-list siblings.


Andy



> >
> > Not only doesn't it work for siblings, but it depends on the order
> (@owner
> > followed by @value),
> > and JSON objects are not ordered.
>
> No, it doesn't, as you can see in the examples the "@value" member can
> appear at any place and the order of tags is also irrelevant.
>
> The only restriction is that no tag can have the key "@value".
>
> >
> >
> >
> >> 2. Properties
> >>
> >> For a property "foo", every JSON value can be changed into a "@foo"
> >> object, e.g.
> >>
> >> {
> >>   "@foo": 42
> >> }
> >>
> >> Such property objects may nest, e.g.
> >>
> >> {
> >>   "@bar":
> >>   {
> >>     "@foo": 42
> >>   }
> >> }
> >
> >
> >
> > why are properties needed?
>
> They are not strictly needed, only their encoding is much nicer, and I
> assume quite often XML attributes are supposed to be used for such binary
> properties, such as "protect", "deactivate" etc.
>
> So the examples above could also be written
>
> "@tagged-value": {
>   "@value": 42,
>   "@foo": true
> }
>
> and
>
> "@tagged-value": {
>   "@value": 42,
>   "@foo": true,
>   "@bar": true
> }
>
>
> > why do we need attributes within attributes?
>
> To be able to express that a single value has multiple properties.
>
> Lada
>
> >
> >
> > Both constructs work for list and leaf-list entries, and may be also
> >> combined.
> >>
> >> > A robust deterministic mapping is required, ad-hoc or not. Perhaps an
> >> > identity registration
> >> > scheme is good enough, since it provides a module-name for the
> attribute
> >> > name.
> >> > (i.e., the tool needs to know all the identities derived-from the
> >> > 'metadata' base identity)
> >> >
> >> >   module foo-mod {
> >> >     ...
> >> >     import nexconf-ex { prefix nx; }
> >> >
> >> >     identity owner {
> >> >        base nx:metadata;
> >> >     }
> >> >   }
> >>
> >> I would prefer either to define global attributes outside YANG, or to
> >> introduce a new top-level statement for them in YANG 1.1, e.g.
> >> "global-attribute".
> >
> >
> >
> >>
> >>
> > Lada
> >>
> >>
> > Andy
>
> --
> Ladislav Lhotka, CZ.NIC Labs
> PGP Key ID: E74E8C0C
>