Re: [core] YANG list to CBOR mapping
Michel Veillette <Michel.Veillette@trilliantinc.com> Thu, 19 November 2015 13:40 UTC
Return-Path: <Michel.Veillette@trilliantinc.com>
X-Original-To: core@ietfa.amsl.com
Delivered-To: core@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id E34D51AD481 for <core@ietfa.amsl.com>; Thu, 19 Nov 2015 05:40:41 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.902
X-Spam-Level:
X-Spam-Status: No, score=-1.902 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, 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 lBIgPsnQyltv for <core@ietfa.amsl.com>; Thu, 19 Nov 2015 05:40:39 -0800 (PST)
Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0102.outbound.protection.outlook.com [207.46.100.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2ACE91AD49D for <core@ietf.org>; Thu, 19 Nov 2015 05:40:38 -0800 (PST)
Received: from BLUPR06MB1763.namprd06.prod.outlook.com (10.162.224.149) by BLUPR06MB1762.namprd06.prod.outlook.com (10.162.224.148) with Microsoft SMTP Server (TLS) id 15.1.325.17; Thu, 19 Nov 2015 13:40:35 +0000
Received: from BLUPR06MB1763.namprd06.prod.outlook.com ([10.162.224.149]) by BLUPR06MB1763.namprd06.prod.outlook.com ([10.162.224.149]) with mapi id 15.01.0325.019; Thu, 19 Nov 2015 13:40:35 +0000
From: Michel Veillette <Michel.Veillette@trilliantinc.com>
To: "consultancy@vanderstok.org" <consultancy@vanderstok.org>, Core <core@ietf.org>
Thread-Topic: [core] YANG list to CBOR mapping
Thread-Index: AQHRIrIaNU9q4tL9iE+AdF+qow8vM56jT5XA
Date: Thu, 19 Nov 2015 13:40:35 +0000
Message-ID: <BLUPR06MB1763747508578EC9B3B9B238FE1B0@BLUPR06MB1763.namprd06.prod.outlook.com>
References: <170106a36217a736a4b55991c4a5cf6a@xs4all.nl>
In-Reply-To: <170106a36217a736a4b55991c4a5cf6a@xs4all.nl>
Accept-Language: fr-CA, en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: spf=none (sender IP is ) smtp.mailfrom=Michel.Veillette@trilliantinc.com;
x-originating-ip: [24.225.215.88]
x-microsoft-exchange-diagnostics: 1; BLUPR06MB1762; 5:kxuwUk3+yIiK9E3wlZd86Fdm8clh0lgD5S1J+PjyP6yHCxEoFr29mann4gDQv5/Y9hlLc0gR/kIDIvH5/rgIHzeEgOHx+dK6ieJVGKF+9OoKgBYEzghnu2qKbHkohsEc508+zW/FEiGpMTdlB4bEQA==; 24:EZ4meOsRdFOHA9X7IY+szBOFr6JBUyYLRY7G5d/Fy+ABqBVxJwQt5srXNETV7ctQf8UeruSp00br03cjpBIc3HUB86Ps8Mh0w5mVDuR983E=; 20:DVLg+N2ndGENEtKQIIMlSph0bz7No20Dn2lt3fpxYxCxzCBW6fTKL61uLtYAzh5qtm6ZxjVPxJhHOBASZDCcQA==
x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR06MB1762;
x-microsoft-antispam-prvs: <BLUPR06MB1762176A99535137637601F6FE1B0@BLUPR06MB1762.namprd06.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:(256376046250027);
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(10201501046)(3002001); SRVR:BLUPR06MB1762; BCL:0; PCL:0; RULEID:; SRVR:BLUPR06MB1762;
x-forefront-prvs: 07658B8EA3
x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(189002)(199003)(377424004)(377454003)(13464003)(38414003)(106356001)(189998001)(97736004)(11100500001)(5001770100001)(105586002)(106116001)(15974865002)(99286002)(19580395003)(40100003)(66066001)(5007970100001)(86362001)(5001960100002)(19580405001)(5004730100002)(81156007)(5002640100001)(586003)(122556002)(5003600100002)(10400500002)(2501003)(5008740100001)(74316001)(87936001)(2900100001)(2950100001)(102836003)(15395725005)(561944003)(77096005)(15975445007)(50986999)(76176999)(76576001)(54356999)(6116002)(101416001)(33656002)(3846002)(92566002); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR06MB1762; H:BLUPR06MB1763.namprd06.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en;
received-spf: None (protection.outlook.com: trilliantinc.com does not designate permitted sender hosts)
spamdiagnosticoutput: 1:23
spamdiagnosticmetadata: NSPM
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-OriginatorOrg: trilliantinc.com
X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Nov 2015 13:40:35.7213 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 4f6fbd13-0dfb-4150-85c3-d43260c04309
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR06MB1762
Archived-At: <http://mailarchive.ietf.org/arch/msg/core/TlVyQwUksqFKO7dBX_Xvf_lV1SY>
Cc: "lhotka@nic.cz" <lhotka@nic.cz>
Subject: Re: [core] YANG list to CBOR mapping
X-BeenThere: core@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "Constrained RESTful Environments \(CoRE\) Working Group list" <core.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/core>, <mailto:core-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/core/>
List-Post: <mailto:core@ietf.org>
List-Help: <mailto:core-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/core>, <mailto:core-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 19 Nov 2015 13:40:42 -0000
Hi Peter The list example show why CoOL propose a direct mapping (YANG -> CBOR) instead of a two steps mapping (YANG -> JSON -> CBOR) as proposed by CoMI. Two aspects of your proposal for lists are invalid in JSON. - The use of an integer as object name - The use of an object as object value See http://jsonlint.com/ for testing compliance. Your proposed solution effectively seem to make sense but this solution is possible only in the context of a direct mapping (YANG -> CBOR) CoOL didn't "ignore the yang-json draft", it use it as a template. The two steps mapping (YANG -> JSON -> CBOR) do not allow to take full advantage of the specificities of CBOR. This is true for the list, true for the bits datatype and probably true for other datatypes like enumeration , identityref, instance-identifier, leafref The direct mapping will also allow the use of the currently discussed deterministic map for container. I hope this provide more background about why CoOL propose a direct mapping and the necessity of this approach. About your proposal to submit this work the netmod wg, I personally prefer to perform all this work (the 4 or 6 drafts) under the core group. The CORE group is where the CBOR expertise is which is critical for this draft. Regards, Michel Veillette System Architecture Director Trilliant Inc. Tel: 450-375-0556 ext. 237 michel.veillette@trilliantinc.com www.trilliantinc.com -----Original Message----- From: core [mailto:core-bounces@ietf.org] On Behalf Of peter van der Stok Sent: November-19-15 5:06 AM To: Core <core@ietf.org> Cc: lhotka@nic.cz Subject: [core] YANG list to CBOR mapping Hi CoOL authors, This e_mail complements my earlier e-mail on YANG to CBOR mapping, and explains the proposed list encoding. Both the draft yang-json and the CoOL draft encode a list as an array. In the yang-json case as a JSON array, and in the CoOL case as major type 4 of major type 5 objects. This encoding prevents the selection of list instances on the basis of the key values from the payload alone. In CoMI the list is encoded as a major type 5 of major type 5 objects. This deviation from the yang-json mapping is motivated by the wish to transport individual list instances and identify the instances in the payload from the key values. This is especially important in case of PATCH operation on list instances. Two cases are to be looked at: (1) the list definition specifies one or more key elements, and (2) the list definition does not specify a key element. We will start with a list containing key elements. It is the wish to transport only those list elements with a unique key value, either to support a PATCH or a FETCH command. Therefore it is required that the payload allows the selection and identification of these list element on the basis of their key values. Using the diagnostic JSON notation used for CBOR diagnostics, the payload containing a number of elements with key values should look like a JSON object with the structure list-name: {key: value}. Both key and value are composed of JSON objects separated by commas. For example consider the following YANG list specification: module foo { namespace http://example.com/book; prefix “fo”; revision 2015-06-07; list B { key “key1 key2”; leaf key1 {type string;} leaf key2 {type string;} leaf coll {type int32;} leaf counter {type int32;} } } Consider the transport of two instances specified by <“key1” = “book1”, “key2” = “author2”> and by <“key1” = “book5”, “key2” = “author3”> out of a larger set of instances. The representation is different from the yang-json one for the reasons explained above. The payload will look like: {"B" :{ {"key1" : "book1", "key2" : "author2"} : {"coll" : 500, "counter": 66} , {"key1" : "book5", "key2" : "author3"} : {"coll" : 444, "counter": 11} } } Which translated to CBOR yields: a1 # map(1) 61 # text(1) 42 # "B" a2 # map(2) a2 # map(2) 64 # text(4) 6b657931 # "key1" 65 # text(5) 626f6f6b31 # "book1" 64 # text(4) 6b657932 # "key2" 67 # text(7) 617574686f7232 # "author2" a2 # map(2) 64 # text(4) 636f6c6c # "coll" 19 01f4 # unsigned(500) 67 # text(7) 636f756e746572 # "counter" 18 42 # unsigned(66) a2 # map(2) 64 # text(4) 6b657931 # "key1" 65 # text(5) 626f6f6b35 # "book5" 64 # text(4) 6b657932 # "key2" 67 # text(7) 617574686f7233 # "author3" a2 # map(2) 64 # text(4) 636f6c6c # "coll" 19 01bc # unsigned(444) 67 # text(7) 636f756e746572 # "counter" 0b # unsigned(11) The corresponding yang-json draft encoding - that allows transport of a selection of instances- does not specify the key fields and would have looked like: {"B" : [ {"key1" : "book1", "key2" : "author2”, "coll" : 500, "counter": 66 } , {"key1" : "book5", "key2" : "author3", "coll" : 444, "counter": 11, } ] } Suppose there are no key elements specified. In that case it is impossible to specify the wanted list elements, and always the whole list must be transported. In the case of a list without key specification is is best to use major type 4 composed of major type 5 to transport the list, as is specified in yang-json draft. Consider the following YANG list Module foo{ Namespace http://example.com/book; Prefix “bo” Revision 2015-06-7 List B { Leaf title {type string;} Leaf author {type string;} Leaf coll {type int32} Leaf counter {type int32} } } Suppose the list contains two elements. The transport payload of the two elements looks like: {"B" :[ {"title" : "book1", "author" : "author2", "coll" : 500, "counter": 66} , {"title" : "book5", "author" : "author3", “coll" : 444, "counter": 11} ] } This payload is identical to the yang-json payload. Which yields the corresponding CBOR code. a1 # map(1) 61 # text(1) 42 # "B" 82 # array(2) a4 # map(4) 65 # text(5) 7469746c65 # "title" 65 # text(5) 626f6f6b31 # "book1" 66 # text(6) 617574686f72 # "author" 67 # text(7) 617574686f7232 # "author2" 64 # text(4) 636f6c6c # "coll" 19 01f4 # unsigned(500) 67 # text(7) 636f756e746572 # "counter" 18 42 # unsigned(66) a4 # map(4) 65 # text(5) 7469746c65 # "title" 65 # text(5) 626f6f6b35 # "book5" 66 # text(6) 617574686f72 # "author" 67 # text(7) 617574686f7233 # "author3" 64 # text(4) 636f6c6c # "coll" 19 01bc # unsigned(444) 67 # text(7) 636f756e746572 # "counter" 0b # unsigned(11) -- Peter van der Stok vanderstok consultancy mailto: mailto:consultancy@vanderstok.org _______________________________________________ core mailing list mailto:core@ietf.org https://www.ietf.org/mailman/listinfo/core
- [core] YANG list to CBOR mapping peter van der Stok
- Re: [core] YANG list to CBOR mapping Michel Veillette
- Re: [core] YANG list to CBOR mapping Michel Veillette
- Re: [core] YANG list to CBOR mapping peter van der Stok
- Re: [core] YANG list to CBOR mapping Michel Veillette
- Re: [core] YANG list to CBOR mapping Carsten Bormann
- Re: [core] YANG list to CBOR mapping peter van der Stok