[yang-doctors] A compact way to compare a type in YANG

Scott Mansfield <scott.mansfield@ericsson.com> Mon, 16 March 2020 10:41 UTC

Return-Path: <scott.mansfield@ericsson.com>
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 E31A43A2291 for <yang-doctors@ietfa.amsl.com>; Mon, 16 Mar 2020 03:41:37 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.1
X-Spam-Level:
X-Spam-Status: No, score=-2.1 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=ericsson.com
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 euLCFT2zYvCG for <yang-doctors@ietfa.amsl.com>; Mon, 16 Mar 2020 03:41:35 -0700 (PDT)
Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2058.outbound.protection.outlook.com [40.107.223.58]) (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 7506E3A228E for <yang-doctors@ietf.org>; Mon, 16 Mar 2020 03:41:35 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ee3aHtCAv9+sx9o2A3T9U7vcVwllLgyWyOQHCqxPrBueJtoBMwr58Xmdo6GelmGPSRNS66ZjeOQibKQzB5enU1ae4LG9vvBI9Ym/91DdXLCkl92cAjBM9HfVzzXvhgAgd6zMnEFT+lXGeRJUObmHK4D0ALfJ5jpLMJ2ZTQzoR6LDopYfDqEcHsS+gFeJ25g3aEc6IpDhYdXbtqdbIAU2OCzQBj4sNNqmAFQepKw8t6f28N5aA1iD+Qag6TqJ+Yb6Iqdi402vs3xy5YaFGojeUhKgqfFoBrCqsZfy70ha7o0aR6sfKdZSBEsSdAeVbds//5Ng45u5jw41iI9y4h4R7Q==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2CldtjjJSkpFpuz+REa39RdI6oc03TSzglKMC1lld0M=; b=Le8TtXWtZQ9QH5UqwohP2PKtt/JNvkixIT+mfdpkVkqmja1N8/5eSu3eHuKz1+XKm2vy6A1UwuVL32tY6W7Hm0KTwIeHnIxM23T/IZ7PGiw+/VliOUyGnKWUjSAxAsHx/uIuhBOD2GBSKBL1H+6EemmxWAoQGIspgHMLklBbF1ltPNoD3f3aL5MiVL78FGcXg6s62TJkFPXcR+4zevixLLergKN26mDY6LvK4NQLERwYClsPKGkEETQW5OcbqvvUu/bDxR+3ljK5h2MTIfbYR4tbW3KJaC/jzb0Szvuasz5IFZIKC3GOPikY78AtVmAY7/rEaL+B2TQaikUJZLfKYA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ericsson.com; dmarc=pass action=none header.from=ericsson.com; dkim=pass header.d=ericsson.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2CldtjjJSkpFpuz+REa39RdI6oc03TSzglKMC1lld0M=; b=GFOkyEaDpOjdBGcv9N1daSVvLNzLlC8r/v8AwKqwJ8qSfDIEs++EHOwsDAiQeWLYwV6fgSjFU3fGrFtQ5XHTQ8H3ub+EzY/D0ekCPw2QtlSdDth+nFoGB/o19cQ5/rj8r499rZCewDlGOZQWbAcNsRfBVwyphx9ysFEtRCNgHo4=
Received: from DM5PR15MB1772.namprd15.prod.outlook.com (2603:10b6:4:56::18) by DM5PR15MB1723.namprd15.prod.outlook.com (2603:10b6:4:5a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.14; Mon, 16 Mar 2020 10:41:30 +0000
Received: from DM5PR15MB1772.namprd15.prod.outlook.com ([fe80::1019:6edc:ff3e:4407]) by DM5PR15MB1772.namprd15.prod.outlook.com ([fe80::1019:6edc:ff3e:4407%9]) with mapi id 15.20.2814.021; Mon, 16 Mar 2020 10:41:30 +0000
From: Scott Mansfield <scott.mansfield@ericsson.com>
To: "yang-doctors@ietf.org" <yang-doctors@ietf.org>
Thread-Topic: A compact way to compare a type in YANG
Thread-Index: AdX7fruOjGZs2vgKT+ejQsikh43dzA==
Date: Mon, 16 Mar 2020 10:41:29 +0000
Message-ID: <DM5PR15MB1772345A25C69265D681A5258BF90@DM5PR15MB1772.namprd15.prod.outlook.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
authentication-results: spf=none (sender IP is ) smtp.mailfrom=scott.mansfield@ericsson.com;
x-originating-ip: [24.154.234.238]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: cbccc89a-40b7-4b12-cc85-08d7c9969651
x-ms-traffictypediagnostic: DM5PR15MB1723:
x-microsoft-antispam-prvs: <DM5PR15MB172335980054524CA88B95FC8BF90@DM5PR15MB1723.namprd15.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:9508;
x-forefront-prvs: 03449D5DD1
x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(136003)(366004)(39850400004)(396003)(199004)(8676002)(6506007)(33656002)(81156014)(81166006)(71200400001)(8936002)(316002)(6916009)(26005)(55016002)(2906002)(7696005)(9686003)(66946007)(186003)(76116006)(86362001)(52536014)(66616009)(5660300002)(66446008)(64756008)(66476007)(66556008)(478600001)(44832011)(43043002)(357404004); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR15MB1723; H:DM5PR15MB1772.namprd15.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1;
received-spf: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts)
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: mLnVeDtRjqXu5TbTTh/tJgcycfMkAH4/TMTg6eyFDw7yTtBZB0nN4LPf4bA/pa4NPAeGJEJNEl8YrEgHPAFmAm23ZXfmXDgV6/4Ds8H/QgavrCBJBEoSDqWZ8UwDCXRqSu2LbRD6si3tZ3FqthIjEFrmgFKXD4u7phT5U8UNMpDWWrooFvAdAsvN7YT8+xXZNEGLoEVFZeARucfsv9OTFF9TD+I7OcNJz1ai8B//a74VthXxdHxZedmn7epak2NC65v89VMGQ/GqcwEpC+2Q0k7EKlLzto2UbcSVi724r//gTVjkL4z/d0z6ALThWDl8ArPTBVYlT1BU0l02XZex6ZbjRU4JrTYqlc1Xu1HHvjcdEbu6mRMDSLts0QLmtGlFcBbPSqLgIdkO0/D29u4cF2qlBB2svb2zHJ4PME0UbQtSCLKYjfLjVPq0Knd224pPi0F/6wQNjN5LzvzPs1/5jJr+1NmpngLeHd/2zweKKZjqZccyuR23Dp6Px9J8DoqlYOHWnQmc2QElpbSm0TGETw==
x-ms-exchange-antispam-messagedata: YaVnEGJholMjxpGYGwQnR5HBO2ODoE92z2jt+50GN8NpU9VBVZoou1AuWgKYkw7xZ1YmaUhOiusOmj1dEEPXXVINfR9eEFR5Zf34xlrzYoGaH1Q2lTvVRsRtWYGGzbNsYkf2f3PiDz5FboakcnssSA==
x-ms-exchange-transport-forked: True
Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="SHA1"; boundary="----=_NextPart_000_04BC_01D5FB5D.EAFC6F00"
MIME-Version: 1.0
X-OriginatorOrg: ericsson.com
X-MS-Exchange-CrossTenant-Network-Message-Id: cbccc89a-40b7-4b12-cc85-08d7c9969651
X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Mar 2020 10:41:29.8715 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 92e84ceb-fbfd-47ab-be52-080c6b87953f
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: /HAjeKLyl0JgeGnYJCcae8AEhUoUdr3ttDnEmet349R9QIrmsewYeulxmULM60acKNnZ6S4WWWvu/jBRIg8qEWLvtBJdX/YrBi20UnBfT1w=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR15MB1723
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/6w049pvYnnZJ66nkeGJfjszoUMM>
Subject: [yang-doctors] A compact way to compare a type in YANG
X-BeenThere: yang-doctors@ietf.org
X-Mailman-Version: 2.1.29
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: Mon, 16 Mar 2020 10:41:38 -0000

Yang Doctors,

 

The IEEE has been working on the IEEE 802.1 bridge model and while updating
some when statements in  YANG models ieee802-dot1q-bridge and
ieee802-dot1q-pb to select conditions for certain types of bridge components
we had a question. 

 

The pertinent part of the bridge tree is this:

 

module: ieee802-dot1q-bridge

  +--rw bridges

     +--rw bridge* [name]

        +--rw name           dot1qtypes:name-type

        +--rw address        ieee:mac-address

        +--rw bridge-type    identityref

        +--ro ports?         uint16

        +--ro up-time?       yang:zero-based-counter32

        +--ro components?    uint32

        +--rw component* [name]

           +--rw name                     string

           +--rw id?                      uint32

           +--rw type                     identityref <- This is the type we
want to test.

           +--rw address?                 ieee:mac-address

 

 

 

And later in the same file an augmented interface tree looks like  this:

 

 

augment /if:interfaces/if:interface:

    +--rw bridge-port

       +--rw bridge-name?                           -> /bridges/bridge/name

       +--rw component-name?                        ->
/bridges/bridge[dot1q:name=current()/../bridge-name]/component/name

 

 

In several places we are using a when statement with an xpath condition
while in the interface tree context: (This is what it looks like in the
ieee802-dot1q-pb module)

when

 
"/dot1q:bridges/dot1q:bridge[dot1q:name=current()/../dot1q:bridge-name]/dot1
q:component[dot1q:name=current()/../dot1q:component-name]/dot1q:type =
'dot1q:c-vlan-component'

 

We had a discussion on our Yangsters meeting this seem rather cumbersome and
whether the component type value could be locally instantiated with the
value of the respective component type to reduce the when statement to: 

 

when " ../dot1q:component-type = 'dot1q:c-vlan-component' "

 

The suggestion was adding this:

 

      leaf component-type {

        type leafref {

          path
"/dot1q:bridges/dot1q:bridge[dot1q:name=current()/../bridge-name]/dot1q:comp
onent[dot1q:name=current()/../component-name]/dot1q:type";  

        }

        description

          "Used to reference the Component type.";

      }

 

However I don't think this works it seems to only make the leafref type of
component-type the same as the dot1q type of ../component/type which is an
identityref. (type-of-component) . Other attempts to make this work failed
too.

 

Does YANG offer another mechanism for a more compact form to do what we
want? 

 

Thanks for your consideration!

 

Regards,

-scott.