Re: [yang-doctors] question regarding conditional/optional statements

Kent Watsen <kwatsen@juniper.net> Wed, 16 August 2017 21:58 UTC

Return-Path: <kwatsen@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 04DF3132710 for <yang-doctors@ietfa.amsl.com>; Wed, 16 Aug 2017 14:58:56 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.01
X-Spam-Level:
X-Spam-Status: No, score=-3.01 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-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=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 7vXHxQ36xuFa for <yang-doctors@ietfa.amsl.com>; Wed, 16 Aug 2017 14:58:53 -0700 (PDT)
Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0120.outbound.protection.outlook.com [104.47.41.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id F36D5132031 for <yang-doctors@ietf.org>; Wed, 16 Aug 2017 14:58:52 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juniper.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=m7vzuMMHxsH75zFDaULab3cmwQiQXnGXEVBKFWFdUec=; b=GzjKCjoZvNAXRrkIuMxOJAC8axxLm7/+0M+G/G4pHGtwlwojy7LR4PGlEln9BZNyPSIHPKeLCzZPJDuk6Qyb1Z2unEey+aMQbUh24Rj83wpSzxn4AkrLVk+mi+zl527Di/1qcJL2SQzgQdC1sJGqGbepW16g225cl6PKnPfXWLw=
Received: from BN3PR0501MB1442.namprd05.prod.outlook.com (10.160.117.151) by BN3PR0501MB1202.namprd05.prod.outlook.com (10.160.113.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.12; Wed, 16 Aug 2017 21:58:50 +0000
Received: from BN3PR0501MB1442.namprd05.prod.outlook.com ([10.160.117.151]) by BN3PR0501MB1442.namprd05.prod.outlook.com ([10.160.117.151]) with mapi id 15.01.1362.018; Wed, 16 Aug 2017 21:58:50 +0000
From: Kent Watsen <kwatsen@juniper.net>
To: Ing-Wher Chen <Ing-Wher_Chen@jabil.com>, "yang-doctors@ietf.org" <yang-doctors@ietf.org>
CC: Norm Strahle <nstrahle@juniper.net>, "Aseem Choudhary (asechoud)" <asechoud@cisco.com>
Thread-Topic: [yang-doctors] question regarding conditional/optional statements
Thread-Index: AQHTFtrXli29k6yzDEuI5GnXs/zH7g==
Date: Wed, 16 Aug 2017 21:58:50 +0000
Message-ID: <5FACD324-EF46-40BD-B7E6-2F546D31A1A4@juniper.net>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
user-agent: Microsoft-MacOutlook/f.20.0.170309
authentication-results: spf=none (sender IP is ) smtp.mailfrom=kwatsen@juniper.net;
x-originating-ip: [66.129.241.13]
x-ms-publictraffictype: Email
x-microsoft-exchange-diagnostics: 1; BN3PR0501MB1202; 6:rKKMe1AoJsgj1gHiwDsmVnq4uCX2Z40wjgknT4syJPZVRS9IRYTCCXyhDzfhxAiVO3Law5KOjEyshe/mbtYHvyYy5HTm9jiQ3bFoeWYsjjPU2gUJz6O/JGsxkFClvW8dvFlGem3fnUn7TsjiaOP0/gPIEvbNufrKYhPzF2mU2a9sZ60tPnN6Hu/rQToYEPvdP4Lx3NIu02pybwaResq/08IandQLq4sLvSOyLFYdYEUEfHo+cTjoyP8vjECj2QpX5CKTgVLkTz+OdNGbe3QY+yvlP4nFIX3bDlyhwodlyAmXr7r2HCyHQDyxgpo6VXutDlPmP76hYit2kNxKkSjmIA==; 5:8Pi+Unij5ofTQL6MbsoeCIwtJQpo7oC2ETo5ZC3T3zEooFbGD8t/Xibb1dSw3M88dHBdEL/nUc4Cn8scWU9vMLXVWHBUmJ2j2MNBEZUgwT2UEKA13yEsOPomr81kcxW/NKfbw/L/n1dpw7DD+YMjAw==; 24:9Dkos7Vd4jpfP9uTnuRyaKO6p1sH3ueAoa8aICZHd+mUp8R2StnzuZzmxau6Qs4uRNIPpfc1BfEBYoz/6PemwRIeu9lWFOl7fvsW4KKI5uI=; 7:zscBvPOSvCt4SjC6juZtyoX8E9clzEofqk2tEvu18YuDTKLnWkjL0YN/L0Ss51U04jVQrU81w1TuaezDiz0j2sK02ARiQLnCU3XdyS8bnR7lbg/f7WBGu+N2ArfG4VnEUhXSAsYpDLXkv38Z41gmIwD5JE73Loqa3vGhBlVhVkYq3noG+16VOFsPep44cUJk4NtiYOQI3V6GPjc8DmGuq23ej8xUatmfkwt/sP2Dark=
x-ms-office365-filtering-correlation-id: e1564a63-8207-4e82-b8d8-08d4e4f1fa6d
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BN3PR0501MB1202;
x-ms-traffictypediagnostic: BN3PR0501MB1202:
x-exchange-antispam-report-test: UriScan:(21748063052155)(21534305686606);
x-microsoft-antispam-prvs: <BN3PR0501MB1202208DE89A9AEA6AFCA981A5820@BN3PR0501MB1202.namprd05.prod.outlook.com>
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123562025)(20161123558100)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN3PR0501MB1202; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN3PR0501MB1202;
x-forefront-prvs: 0401647B7F
x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(189002)(377454003)(199003)(24454002)(50986999)(6246003)(33656002)(7736002)(2900100001)(82746002)(54356999)(14454004)(86362001)(6116002)(102836003)(3846002)(101416001)(6486002)(77096006)(106356001)(105586002)(6436002)(66066001)(189998001)(83506001)(2501003)(68736007)(478600001)(83716003)(36756003)(97736004)(3660700001)(25786009)(6506006)(5660300001)(99286003)(6512007)(236005)(2906002)(4326008)(81156014)(4001350100001)(8936002)(229853002)(53936002)(54896002)(6306002)(81166006)(8676002)(54906002)(3280700002); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR0501MB1202; H:BN3PR0501MB1442.namprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en;
received-spf: None (protection.outlook.com: juniper.net does not designate permitted sender hosts)
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: multipart/alternative; boundary="_000_5FACD324EF4640BDB7E62F546D31A1A4junipernet_"
MIME-Version: 1.0
X-OriginatorOrg: juniper.net
X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Aug 2017 21:58:50.4734 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: bea78b3c-4cdb-4130-854a-1d193232e5f4
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0501MB1202
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/uDuGgQtUN9LtaqppLBxxXdd6hvI>
Subject: Re: [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 21:58:56 -0000

Helen,

The downside to option #1 is a potentially large number of features that would have to be listed in Yang Library, right?  How many features are we talking about?  Since your third example uses an int32, no more than 32?   That doesn't sound excessive to me.  The space-savings isn't much, unless we're talking about itty-bitty IoT devices (hopefully running CoAP).

Kent

On 8/16/17, 2:09 PM, "yang-doctors on behalf of Ing-Wher Chen" <yang-doctors-bounces@ietf.org<mailto:yang-doctors-bounces@ietf.org> on behalf of Ing-Wher_Chen@jabil.com<mailto:Ing-Wher_Chen@jabil.com>> wrote:


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