[yang-doctors] List key model definition order and results w/ pyang/yanglint

Ebben Aries <exa@juniper.net> Thu, 25 January 2018 03:17 UTC

Return-Path: <exa@juniper.net>
X-Original-To: yang-doctors@ietfa.amsl.com
Delivered-To: yang-doctors@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id C2F4012D7F7 for <yang-doctors@ietfa.amsl.com>; Wed, 24 Jan 2018 19:17:33 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.7
X-Spam-Level:
X-Spam-Status: No, score=-2.7 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=juniper.net
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 59RE7NizBasI for <yang-doctors@ietfa.amsl.com>; Wed, 24 Jan 2018 19:17:31 -0800 (PST)
Received: from mx0a-00273201.pphosted.com (mx0a-00273201.pphosted.com [208.84.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id AE5AB1289B0 for <yang-doctors@ietf.org>; Wed, 24 Jan 2018 19:17:31 -0800 (PST)
Received: from pps.filterd (m0108158.ppops.net [127.0.0.1]) by mx0a-00273201.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0P3ELc5003416; Wed, 24 Jan 2018 19:17:30 -0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juniper.net; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=PPS1017; bh=JrhPfOaQqWLOkFCa/Vuq+2HBL+5qti43cHqyCxLnQbY=; b=ErFD0YNngcGoozHc3Epsy2r/YClDBGyxw39R+wVvF+fNVYkt5nDWetxUiQRBtyqziQTq Mo0PPBOcyVLszvv/O2jKlvASQ0Ns8fG0VblVBg8zCHVxJqeNq42qx03JIxmEp8lzFtf0 wv51oH0IFQLHYniYSd8xys3dk6pkagv3wP5v6GcuYWa8KYYvUKeUOuoTB03hzpWrxPT8 vWkWGRjVR5m4nMtepnpf5uJv8H/kHluWtZd3hmqfd5cHgSTnQC9ozHPr5uclwkHlDzOG bpDdskTsY/UugU64jNq5vnIP9/y8onaHM0YUvq4Fw/rk0Q3evGgeFEfU6H64jNi+GeBM JA==
Received: from nam01-by2-obe.outbound.protection.outlook.com (mail-by2nam01lp0176.outbound.protection.outlook.com [216.32.181.176]) by mx0a-00273201.pphosted.com with ESMTP id 2fq74ar095-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 24 Jan 2018 19:17:30 -0800
Received: from SN4PR0501CA0079.namprd05.prod.outlook.com (10.171.32.145) by CY4PR05MB3608.namprd05.prod.outlook.com (10.171.244.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.5; Thu, 25 Jan 2018 03:17:29 +0000
Received: from DM3NAM05FT054.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::206) by SN4PR0501CA0079.outlook.office365.com (2603:10b6:803:22::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.464.6 via Frontend Transport; Thu, 25 Jan 2018 03:17:28 +0000
Received-SPF: SoftFail (protection.outlook.com: domain of transitioning juniper.net discourages use of 66.129.239.15 as permitted sender)
Received: from P-EMFE01C-SAC.jnpr.net (66.129.239.15) by DM3NAM05FT054.mail.protection.outlook.com (10.152.98.168) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.20.444.7 via Frontend Transport; Thu, 25 Jan 2018 03:17:28 +0000
Received: from smtp.juniper.net (10.163.2.159) by P-EMFE01C-SAC.jnpr.net (172.24.192.21) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 24 Jan 2018 19:16:51 -0800
Date: Wed, 24 Jan 2018 20:16:50 -0700
From: Ebben Aries <exa@juniper.net>
To: yang-doctors@ietf.org
Message-ID: <20180125031650.jzdswdgpspontven@smtp.juniper.net>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
X-EOPAttributedMessage: 0
X-MS-Office365-Filtering-HT: Tenant
X-Forefront-Antispam-Report: CIP:66.129.239.15; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(376002)(396003)(346002)(39860400002)(39380400002)(2980300002)(189003)(199004)(2351001)(69596002)(106466001)(5660300001)(336011)(105596002)(53416004)(6306002)(26005)(77096007)(55016002)(53936002)(6916009)(478600001)(97736004)(186003)(86362001)(47776003)(59450400001)(305945005)(356003)(7696005)(966005)(2906002)(3716004)(1076002)(104016004)(4326008)(23726003)(316002)(16586007)(68736007)(46406003)(81166006)(81156014)(8936002)(50466002)(8676002)(97756001)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR05MB3608; H:P-EMFE01C-SAC.jnpr.net; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en;
X-Microsoft-Exchange-Diagnostics: 1; DM3NAM05FT054; 1:jz8XcD2Za4ZTBHAFWsuYGwi3UsDHVefSozKGpeJVIAO4I4psijAd3v+KyLukyh5W8zGU+IdGxnUdiDFXeOgGX3bhZVhroTVPFjQUnD1/kvqegSOQ2pWc0HHMbsouDutS
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: c487a927-bee4-48c6-d468-08d563a22a4a
X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:CY4PR05MB3608;
X-Microsoft-Exchange-Diagnostics: 1; CY4PR05MB3608; 3:LXsF14/NHvMeIDJ6TyfBSWTsW3R2kDU6iQaoxijPj65vsBFm5YzFgA6Dyj7ywF6HG76WUIYdRH+Xw6GdMd2M77sotwJXB8L/k6H8A/aC60aWDyhm8cq2TT+BfCKNrAHUMNMDgJkgwsQExdC2/tlNXizNNVqz4SzwQwAoRKpVb+J/CUfN9i/jXuSiyhHKK0J1d+cl+kjYt8mYhyN7nawhMIUHZqfI5bj1UqrmteoPToMEE8gxVIcC48Xiv+VL/d3Iqf6z1GprtcDJM0HZKVY5rKV6c53T2o3Hh00MWNloawwPkNYDf1+YLlF33BpzVva83eoc127bhhBz8WX7/zo0ajZuiD04NI38zH3ByTwIYKA=; 25:7oPQ8w/Hr0wgEVrbg5yvzrqLmesDUgo2uG7GSFycTnbsWwTnZc+1Oo0iH76WqE3BSj7L30kdiRxit4Sv1HtqcruJwUR6DTwbxgNwKvkP7YXWfIzIyK2rgAr9mFTD/4lC5AzTO3EmHjC/yzBLtJYcq0ZsbcF3GSu2TWPNQz3xdjaMyR7/07wguzoSSpwtsAyzQW7zZkGvcnolnb0ur8xJZjHKn//2Fn+IGzAxlwfD2HYsnghnMZg9Une81us060YOt6brFFjwOk6wauD5pHjhcXiucZ5J1mLkzwfQbjJbNPvphojt5EtXr0J+5RVDym7eYJIrFLeFfxuM68vE47ltHQ==
X-MS-TrafficTypeDiagnostic: CY4PR05MB3608:
X-Microsoft-Exchange-Diagnostics: 1; CY4PR05MB3608; 31:2QoGlFt4BVBsOGBjineu6urCAowybtrXX9ygWPt6B1LNSo4cX7Jj1ihyaUbDFLiv5N09Ck5GDE3humni1iqUr+7vPt320uzZm2Gda3A159PWJEbT3L+lG1qowWng+Yv9493aXelJYbGrJO+2gZbXTUOLoT0dJ43EzdICvuk0TXRFDcI9Gu/+mmrbb0i3lg5/2e4cqk+THHHCmdi4L++LbwejGBRqRAAAWsu/CHFKPMs=; 20:92AktN8IOS63krCSA80N1zyhHAgzxTylZGGuER+q+STg70aNaSznQfk6SrGBvB+U8BEgEs03h70dxzDhxJ4lTqjIn1iXxb7Rc2+OWRlF6XGQC8p99MD6fS310+Cf3zOp8bneCwPHe8ZSNlYpk+OxmcoRWWJFN7HAeD887bpIEIHFFeaf4rEY+iEEhUMSEq+rDdRtLbFKzlc/SSHkmuSaPOJU5CD/G6zmkiQ+UXpCChmGOHQUDsrKfcnwVTHRdARKybe04AT2EabdvpiA7fW5qa4lfWTTVYrqHVF0SJ23BWLBBxh0alUUnNLkrp3YROIF+wNWUYPiibunZvg5hHR+b+l3pQSUkpLTz09Aui/PvR1C5fXgHcC28R9s4lbMTqLqDLlXMEUXDHApMWWTIUnnRtyT1HTZqGzLBvG0ePTp3pyROCAb3KBlHPH+BJz6kz6aeeKVq6He/GDwXCod7S2C9CYml5jUnuzm7Ob/1PiAc7YskWps98OZCp6S6h/VijJl
X-Microsoft-Antispam-PRVS: <CY4PR05MB36080AAFEB8972FE64E616DCA8E10@CY4PR05MB3608.namprd05.prod.outlook.com>
X-Exchange-Antispam-Report-Test: UriScan:(131327999870524);
X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(3231023)(2400081)(944501161)(6055026)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:CY4PR05MB3608; BCL:0; PCL:0; RULEID:; SRVR:CY4PR05MB3608;
X-Microsoft-Exchange-Diagnostics: 1; CY4PR05MB3608; 4:qtPFpT6Yy0q92J+6MjlroRU2HN5wxFQxqUhGFIZ9x9ij6EPg3Htrx/qzzEArKUBtq53yt2mlFmby+yPw9wl/O+OHaVnaQ1zZYeHOAfQV5c3KlockD9PPVEtZkHSrKWfd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5ZaXER4Ln1RYUu71RRLBqnlgQAa/67HBhCL2Ocfr1BVqwI/30mM7GiefbqMnc6sIGKS2KP2HnoAeUsGARWiDCFLWc7bCP8bYD6L/uKlbZ02QGWyC9VoqCTkra1Cex+Dyh8fGEgf6Cg4O49XVOMMW
SpamDiagnosticOutput: 1:99
SpamDiagnosticMetadata: NSPM
X-OriginatorOrg: juniper.net
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2018 03:17:28.5067 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: c487a927-bee4-48c6-d468-08d563a22a4a
X-MS-Exchange-CrossTenant-Id: bea78b3c-4cdb-4130-854a-1d193232e5f4
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=bea78b3c-4cdb-4130-854a-1d193232e5f4; Ip=[66.129.239.15]; Helo=[P-EMFE01C-SAC.jnpr.net]
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR05MB3608
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-25_01:, , signatures=0
X-Proofpoint-Spam-Details: rule=outbound_spam_notspam policy=outbound_spam score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801250042
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/TZ1MXfk1D7ZA0ZA8Y-hWLmJL9W0>
Subject: [yang-doctors] List key model definition order and results w/ pyang/yanglint
X-BeenThere: yang-doctors@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Email list of the yang-doctors directorate <yang-doctors.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/yang-doctors/>
List-Post: <mailto:yang-doctors@ietf.org>
List-Help: <mailto:yang-doctors-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 25 Jan 2018 03:17:34 -0000

Possibly bringing up a subject that may have been discussed before but
could not find anything on it so sending to the group.

RFC 6020 and 7950 both have the same wording on the subject around list
keys per

https://tools.ietf.org/html/rfc6020#section-7.8.2
https://tools.ietf.org/html/rfc7950#section-7.8.2

>From a model definition standpoint, there is nothing mandatory
surrounding that list keys be the first leaf definitions underneath.

>From a content encoding standpoint, the following XML Mapping Rules in
https://tools.ietf.org/html/rfc6020#section-7.8.5 do dictate an order
that the keys be defined before other subelements.  JSON obviously does
not utilize the same encoding technique.

   The list's key nodes are encoded as subelements to the list's
   identifier element, in the same order as they are defined within the
   "key" statement.

   The rest of the list's child nodes are encoded as subelements to the
   list element, after the keys.  If the list defines RPC input or
   output parameters, the subelements are encoded in the same order as
   they are defined within the "list" statement.  Otherwise, the
   subelements are encoded in any order.

Given the following simple example:

module test {
    namespace "http://test";
    prefix test;

    container foo {
        leaf bar {
            type string;
        }
        list car {
            key "far mar";

            leaf par {
                type string;
            }
            leaf far {
                type string;
            }
            leaf mar {
                type string;
            }
            leaf nar {
                type string;
            }
        }
    }
}

leaf 'par' here is defined before the 'far' and 'mar' keys, however if
we render out a sample-xml-skeleton with pyang, we do not take into
account the XML encoding rules defined in Section 7.8.5 and merely keep
the order as defined in the model.

$ pyang test.yang --strict -f sample-xml-skeleton
<?xml version='1.0' encoding='UTF-8'?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <foo xmlns="http://test">
    <bar />
    <car>
      <par />
      <far />
      <mar />
      <nar />
    </car>
  </foo>
</data>

With yanglint, given the following XML document

$ cat test.xml
<foo xmlns="http://test">
    <bar>BAR</bar>
    <car>
        <par>PAR</par>
        <far>FAR</far>
        <mar>MAR</mar>
        <nar>NAR</nar>
    </car>
</foo>

The rendered XML output will actually reorder the list keys to be first

$ yanglint -f xml test.yang test.xml
<foo xmlns="http://test">
  <bar>BAR</bar>
  <car>
    <far>FAR</far>
    <mar>MAR</mar>
    <par>PAR</par>
    <nar>NAR</nar>
  </car>
</foo>

Personally, from a BCP standpoint, defining list keys first eases
readability and want to solicit others thoughts on this (rather than
nested down in the list or via a grouping reference further down).
Generation to yin does not rearrange in either pyang or yanglint which
means any processing of yin would need to undergo some reordering
possibly depending on how it is absorbed.

For the JSON encoding case, there may be no strict ordering but
following a BCP where folks *should* send list keys before other
elements can ease implementation efforts in many cases.  It is also
likely that payloads will generally be constructed in the order in which
they are defined in the model.

So either I see making the definition of such either mandatory or at a
bare minimum pyang sample-xml-skeleton output to take into account
ordering list key leafs prior to other subelements.

Thx

/ebben