Re: [netmod] attributes in draft-lhotka-netmod-yang-json
Andy Bierman <andy@yumaworks.com> Sun, 23 March 2014 10:53 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 753CD1A0950 for <netmod@ietfa.amsl.com>; Sun, 23 Mar 2014 03:53:08 -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 r4bXatOLpyt3 for <netmod@ietfa.amsl.com>; Sun, 23 Mar 2014 03:53:06 -0700 (PDT)
Received: from mail-qc0-f173.google.com (mail-qc0-f173.google.com [209.85.216.173]) by ietfa.amsl.com (Postfix) with ESMTP id 219C31A0639 for <netmod@ietf.org>; Sun, 23 Mar 2014 03:53:05 -0700 (PDT)
Received: by mail-qc0-f173.google.com with SMTP id r5so4768179qcx.32 for <netmod@ietf.org>; Sun, 23 Mar 2014 03:53:05 -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=KnsceS2tV/tMWxx/bcNDaZItMzJuAQEkGX/IHEIZoco=; b=akLzZwyVhwlcb5oHP5JTAHs2SZGSFH+myNqE0OGsJZ2Nz4UCXXtylY0drOEDEws21H SJ1bjJ8HiDVNlaxyROKhuh7vZ7U1INkKGqyiWi+EM1wRZurx/JzvEHfWMBsiqNJYIQxO eAfMhZS9/u5MfMpNZZbtbr6bE5c/EsPnwZkqbPJejUpoRNQqBmJpToUBwWosQdO1LfWm +L4XdMk9qRET53YdBl6uKnuRbJwfvoZQvHlNAco5DqC3Ez9eLxnujODkrbyXSucTLSta 3QrRKkdjUd2ftQW56dPfkQ4vw1OYRP0qzA0WHVZqc+wg6gkvOeneiItj0iPMScQSo+6D u0Bg==
X-Gm-Message-State: ALoCoQnKLjr81Fweu9bRSRw9AgDLaOCbs0PkPvqjl9R8Miw1gTQD68M6UFwxYMGMh3r7HAc7DN0s
MIME-Version: 1.0
X-Received: by 10.224.72.12 with SMTP id k12mr873731qaj.81.1395571985309; Sun, 23 Mar 2014 03:53:05 -0700 (PDT)
Received: by 10.140.104.194 with HTTP; Sun, 23 Mar 2014 03:53:05 -0700 (PDT)
In-Reply-To: <20140323.110741.449355686.mbj@tail-f.com>
References: <m2bnwy7j0c.fsf@nic.cz> <CABCOCHRFjzj40nWtckJRPCbxCMSwojadRh0rBb27qMRyHx8MHA@mail.gmail.com> <m2ob0xb697.fsf@nic.cz> <20140323.110741.449355686.mbj@tail-f.com>
Date: Sun, 23 Mar 2014 03:53:05 -0700
Message-ID: <CABCOCHT3pr0XUXDXvM=rDj3i=t6i_7nQbkO4BQGDiqRzdRPutQ@mail.gmail.com>
From: Andy Bierman <andy@yumaworks.com>
To: Martin Bjorklund <mbj@tail-f.com>
Content-Type: multipart/alternative; boundary="047d7bea2f027172cd04f543ec42"
Archived-At: http://mailarchive.ietf.org/arch/msg/netmod/GF-ASx-GxQgA6LL-gzEv4JjCxiY
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 10:53:08 -0000
On Sun, Mar 23, 2014 at 3:07 AM, Martin Bjorklund <mbj@tail-f.com> wrote: > 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. > > > > > > > > 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. > > > > 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 > > } > > } > > > > Both constructs work for list and leaf-list entries, and may be also > combined. > > This makes both client and server programming much more complex. The > whole point of using JSON is supposedly that it maps well to built-in > datastructures in modern languages. This property makes parsing > trivial, and makes it easy to get values. For example: > > res = json_parse(...) > if res['ssh']['enabled']: > ... > > now, with the proposed encoding, I have to be prepared for 'ssh' being > a '@tagged-value', and '@enabled' being a tagged-value, and > combinations thereof: > > if res['ssh']['enabled'] > or res['@tagged-value']['ssh']['enabled'] > or res['@tagged-value']['ssh']['@tagged-value']['enabled'] > or ... > > As I write this I realize that I don't really understand your > proposal..., so the code above is not correct - but the point is the > same; as soon as you allow multiple encodings you make coding much > more complex. > > I agree this is getting too complicated. > Maybe the original JSON mapping idea is the only one that works; i.e., > map pure YANG data to JSON. No meta data. A protocol that needs meta > data should not use JSON; use XML instead. > > Clearly the protocol cannot rely on attributes if they are not supported in some encoding schemes. Only schemes that can map 100% of the protocol messages can be considered. I am OK with leaving attributes out of RESTCONF (so they can be left out of the YANG to JSON mapping). > /martin > Andy
- [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