[yang-doctors] question regarding conditional/optional statements

Ing-Wher Chen <Ing-Wher_Chen@jabil.com> Wed, 16 August 2017 18:09 UTC

Return-Path: <Ing-Wher_Chen@jabil.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 680C213235E for <yang-doctors@ietfa.amsl.com>; Wed, 16 Aug 2017 11:09:32 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.91
X-Spam-Level:
X-Spam-Status: No, score=-2.91 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=jabil.onmicrosoft.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 jIO7kri-vTc8 for <yang-doctors@ietfa.amsl.com>; Wed, 16 Aug 2017 11:09:28 -0700 (PDT)
Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0135.outbound.protection.outlook.com [104.47.34.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 8BB29132357 for <yang-doctors@ietf.org>; Wed, 16 Aug 2017 11:09:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jabil.onmicrosoft.com; s=selector1-jabil-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Lw13dDdNWxWgktAxe+nVB7hbFCDX79GdiN+2HS60eq8=; b=yqPx/hGHrOeK8sfCMixTd7DjhNWop1HDBXGL/vkeHmQ3UAFCOVYs0gxq+ztTly8hD3OJ41HVLhP+t1ZOaFSVqaefQYZSFw8gmkbBISgyeUnCd9SgAfCGWJiAguaztDXHoQ0vJ/UTNa43s3WPXMhzv6vcHiNlpXKBW9vCvy+4/kU=
Received: from BN1PR0201MB0833.namprd02.prod.outlook.com (10.160.170.153) by BN1PR0201MB0835.namprd02.prod.outlook.com (10.160.170.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1341.21; Wed, 16 Aug 2017 18:09:27 +0000
Received: from BN1PR0201MB0833.namprd02.prod.outlook.com ([fe80::7125:7658:52e4:9350]) by BN1PR0201MB0833.namprd02.prod.outlook.com ([fe80::7125:7658:52e4:9350%16]) with mapi id 15.01.1341.020; Wed, 16 Aug 2017 18:09:27 +0000
From: Ing-Wher Chen <Ing-Wher_Chen@jabil.com>
To: "yang-doctors@ietf.org" <yang-doctors@ietf.org>
CC: "Aseem Choudhary (asechoud)" <asechoud@cisco.com>, Norm Strahle <nstrahle@juniper.net>
Thread-Topic: question regarding conditional/optional statements
Thread-Index: AdMWuspFVk5k9TDdRCeshA4HU2pVBg==
Date: Wed, 16 Aug 2017 18:09:27 +0000
Message-ID: <BN1PR0201MB0833B05FB5307BDEF2E8E3F5C3820@BN1PR0201MB0833.namprd02.prod.outlook.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-dg-ref: PG1ldGE+PGF0IG5tPSJib2R5Lmh0bWwiIHA9ImM6XHVzZXJzXGljaGVuXGFwcGRhdGFccm9hbWluZ1wwOWQ4NDliNi0zMmQzLTRhNDAtODVlZS02Yjg0YmEyOWUzNWJcbXNnc1xtc2ctMDgwMzQ4Y2YtODJhZS0xMWU3LTg3ZmMtMTg1ZTBmOWYwNmFhXGFtZS10ZXN0XDA4MDM0OGQxLTgyYWUtMTFlNy04N2ZjLTE4NWUwZjlmMDZhYWJvZHkuaHRtbCIgc3o9IjE5NjE1IiB0PSIxMzE0NzM4MDU2NDI5NTYyMzYiIGg9Ik01cVAzQWNRVTk1aGQ3dlAyV2pJRU5XdHZUOD0iIGlkPSIiIGJsPSIwIiBibz0iMSIvPjwvbWV0YT4=
authentication-results: spf=none (sender IP is ) smtp.mailfrom=Ing-Wher_Chen@jabil.com;
x-originating-ip: [98.191.72.170]
x-ms-publictraffictype: Email
x-microsoft-exchange-diagnostics: 1; BN1PR0201MB0835; 6:GHumYZf2mHW3i2RDdds5V4Ldu5zNte46Y/jv3fTG/fmCZqBe+YuOJDvn9cqcyP/Cp5f9nPFmsg6Y/vZk7t/Gy5WQbUU+GzIVo/mX74Cmr6PExORYkAG27qlz4r4LT/R/exLqPSFRvppOIVqUukl+UMYkjykfUo6fKiLwevlnXoGUZjxkoyHHgCIi8Ht5OuGp6+6W3FXPFUnF/tu7llOpmRDxbYkFt5esPSIewkiKdgNVlVMSsKgR0WjWAJL94DjGpPWtlOCUCtrCsatz5cRrkiOzuqu6wY5SUU380M+E08/Ffkh+Vu2IxKm/c5x+JJt+fjhT+4BLi7M/KSJsLsYHsw==; 5:ZsKjhg+/vMt7uBlsAqOFlPE/njntUI5gbQ7nFZjaOmCQy9cHU5cZ+8txcHhr9PgivaAIiuRE2QI96DMATdoaw7BESHH8yqRCJpa+3zTKoyBYwa+sWjlaJyB1cRP0IRByRfZhMKebGkx32zh6O7IFiw==; 24:uTXKZFrs0mU73Qri86R+C6CiTML7+AVGGve/1s5atX/OxkWhL0xSQIXhbLsFPPCyD4mTAeXgGRRjuFJypXaU3AdQsQaCx3cAdmevBW98YiY=; 7:giToVbNY9IBa/sQ1WkFYzBuGuwT468P2e0b1ef559ig+N27JQ+rLNq+M5GAp79U3s6gSnNdWaEWy+SqqRBRI9EgXDPJVt63sm8lptovrHmklr8wkgg5XeLzFq8BVAXBiKVuFlTWlMFlc1ODiUf3crXoK0cClLDascwWiMKykjL+HryK+cLxMKs3K1C1przcvwKdZ/cS8fzTzYePJhToFpbeMg4IThj4SsJzhUW2v728=
x-ms-exchange-antispam-srfa-diagnostics: SSOS;
x-ms-office365-filtering-correlation-id: ff192faa-1062-471e-a95e-08d4e4d1eee2
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BN1PR0201MB0835;
x-ms-traffictypediagnostic: BN1PR0201MB0835:
x-exchange-antispam-report-test: UriScan:(21748063052155);
x-microsoft-antispam-prvs: <BN1PR0201MB0835225E897C05BB51434C13C3820@BN1PR0201MB0835.namprd02.prod.outlook.com>
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123562025)(20161123555025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN1PR0201MB0835; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN1PR0201MB0835;
x-forefront-prvs: 0401647B7F
x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(105586002)(53936002)(86362001)(3280700002)(7736002)(6506006)(2501003)(478600001)(2906002)(101416001)(5640700003)(4326008)(189998001)(72206003)(2351001)(3660700001)(66066001)(5250100002)(25786009)(106356001)(54896002)(6306002)(110136004)(81166006)(3480700004)(97736004)(8936002)(74316002)(6436002)(81156014)(8676002)(99286003)(5630700001)(6116002)(102836003)(54906002)(9686003)(6916009)(5660300001)(8666007)(50986999)(790700001)(3846002)(54356999)(55016002)(7696004)(14454004)(33656002)(68736007)(2900100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BN1PR0201MB0835; H:BN1PR0201MB0833.namprd02.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en;
received-spf: None (protection.outlook.com: jabil.com does not designate permitted sender hosts)
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: multipart/alternative; boundary="_000_BN1PR0201MB0833B05FB5307BDEF2E8E3F5C3820BN1PR0201MB0833_"
MIME-Version: 1.0
X-OriginatorOrg: jabil.com
X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Aug 2017 18:09:27.2743 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: bc876b21-f134-4c12-a265-8ed26b7f0f3b
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0201MB0835
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/3QdeDZe6ryv2Rgd4HGI0Zd_YJgE>
Subject: [yang-doctors] question regarding conditional/optional statements
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: Wed, 16 Aug 2017 18:09:32 -0000

Hello YANG doctors,



We wish to define a YANG model with several counters.  The counters that we wish to model are the union of all the counters supported by our sample of vendors.  This means that the model will define some counters supported by both vendor_1 and vendor_2 (or more), but some counters will be supported only by one of the vendors.  We would like the model to allow each vendor to indicate the counters it supports.



We can think of 3 approaches below, and would like your feedback regarding which approach we should choose.  We're also open to suggestions of other approaches.



Option 1: Define an optional feature (if-feature) for each counter.

Sample:
  container queuing-statistics-opt-1 {
    config false;
    description
      "queue related statistics ";
    leaf output-pkts {
      if-feature "output-pkts";
      type uint64;
      description
        "Number of packets transmitted from queue ";
    }
    leaf output-bytes {
      if-feature "output-bytes";
      type uint64;
      description
        "Number of bytes transmitted from queue ";
    }
    leaf queue-size-pkts {
      if-feature "queue-size-pkts";
      type uint64;
      description
      "Number of packets currently buffered ";
    }
    /* etc. */
  }

Advantage: This is the standard approach built into the language to make a statement conditional.

Disadvantage: There are many counters, and each counter will be an optional feature, resulting in many optional features in the model.



Option 2: Define a leaf of the type bits, where each bit indicates that a particular counter is supported.

Example:
  container queuing-statistics-opt-2 {
    config false;
    description
      "queue related statistics ";
    leaf supported-counters {
      type bits {
        bit queue-output-pkts;
        bit queue-output-bytes;
        bit queue-size-pkts;
      }
    }
    leaf output-pkts {
      type uint64;
      description
        "Number of packets transmitted from queue ";
    }
    leaf output-bytes {
      type uint64;
      description
        "Number of bytes transmitted from queue ";
    }
    leaf queue-size-pkts {
      type uint64;
      description
      "Number of packets currently buffered ";
    }
    /* etc. */
  }

Advantage: This reduces the number of optional features in the model.

Disadvantage: The output that indicates which counters are supported might be too verbose to be user friendly.  This is not YANG's standard approach to make a statement conditional.



Option 3: Define a leaf of the type integer, where each bit in the integer indicates that a particular counter is supported.

Example:
  container queuing-statistics-opt-3 {
    config false;
    description
      "queue related statistics ";
    leaf supported-counters {
      type uint32;
      description
        "Bit 0 indicates whether output-pkts counter is supported
         Bit 1 indicates whether output-bytes counter is supported
         Bit 2 indicates whether queue-size-pkts counter is supported";
    }
    leaf output-pkts {
      type uint64;
      description
        "Number of packets transmitted from queue ";
    }
    leaf output-bytes {
      type uint64;
      description
        "Number of bytes transmitted from queue ";
    }
    leaf queue-size-pkts {
      type uint64;
      description
      "Number of packets currently buffered ";
    }

Advantage: The output, in the form of a single integer, that indicates which counters are supported is compact.

Disadvantage: The model is vague/implicit---the meaning of each bit in supported-counters is embedded in the description, rather than modeled explicitly.  This is also not YANG's standard approach to make a statement conditional.



Thanks,

Helen