[yang-doctors] when statement of an optional leaf? Does it make an optional leaf?

Benoit Claise <bclaise@cisco.com> Tue, 17 March 2020 15:03 UTC

Return-Path: <bclaise@cisco.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 1D4803A00C9 for <yang-doctors@ietfa.amsl.com>; Tue, 17 Mar 2020 08:03:12 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -9.6
X-Spam-Level:
X-Spam-Status: No, score=-9.6 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_MED=-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, USER_IN_DEF_DKIM_WL=-7.5] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cisco.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 NddV06I__hYN for <yang-doctors@ietfa.amsl.com>; Tue, 17 Mar 2020 08:03:10 -0700 (PDT)
Received: from aer-iport-2.cisco.com (aer-iport-2.cisco.com [173.38.203.52]) (using TLSv1.2 with cipher DHE-RSA-SEED-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id CBB023A0043 for <yang-doctors@ietf.org>; Tue, 17 Mar 2020 08:03:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=9590; q=dns/txt; s=iport; t=1584457390; x=1585666990; h=to:cc:from:subject:message-id:date:mime-version; bh=60lYgc9t9SroLETkB/6kqygHMC2cMAFaTRdgZ1q5nKA=; b=CJ2ngG64bSAm3K5P/XdtzJvD/uBPTA79org6XNVUQW9mARftFx/DCBE/ wmJNfVcPmVTA9divLBOiiZbRgODR8GmIM9/w6n6vUtm56xLSS8RVGaXgF GDTArizwadpHk8VK7SIvRN7pjcmBKRnBletKXRDFV570APD9UY9VOQvxh Q=;
X-IronPort-AV: E=Sophos; i="5.70,564,1574121600"; d="scan'208,217"; a="24495174"
Received: from aer-iport-nat.cisco.com (HELO aer-core-2.cisco.com) ([173.38.203.22]) by aer-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 17 Mar 2020 15:03:08 +0000
Received: from [10.55.221.38] (ams-bclaise-nitro5.cisco.com [10.55.221.38]) (authenticated bits=0) by aer-core-2.cisco.com (8.15.2/8.15.2) with ESMTPSA id 02HF35Cq008108 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 17 Mar 2020 15:03:07 GMT
To: YANG Doctors <yang-doctors@ietf.org>
Cc: Eric Vyncke <evyncke@cisco.com>, "Jean Quilbeuf -X (jquilbeu - LIANEO at Cisco)" <jquilbeu@cisco.com>
From: Benoit Claise <bclaise@cisco.com>
Message-ID: <50f02dc5-850d-90c5-9cad-48a062fe686c@cisco.com>
Date: Tue, 17 Mar 2020 16:03:05 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="------------29C7CD9807C7DB2579F86B7F"
Content-Language: en-US
X-Authenticated-User: bclaise
X-Outbound-SMTP-Client: 10.55.221.38, ams-bclaise-nitro5.cisco.com
X-Outbound-Node: aer-core-2.cisco.com
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/ao9HnfipwsfKKZrr7COFpk7h33w>
Subject: [yang-doctors] when statement of an optional leaf? Does it make an optional leaf?
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: Tue, 17 Mar 2020 15:03:12 -0000

YANG doctors,

$ pyang -f tree  ietf-service-assurance.yang
module: ietf-service-assurance
   +--ro assurance-graph-version?       yang:counter32
   +--ro assurance-graph-last-change?   yang:date-and-time
   +--rw subservices
      +--rw subservice* [type id]
         +--rw type                                identityref
         +--rw id                                  string
         +--ro last-change?                        yang:date-and-time
         +--ro label?                              string
         +--rw under-maintenance?                  boolean
         +--rw maintenance-contact string <===============================
         +--rw (parameter)?
         |  +--:(service-instance-parameter)
         |     +--rw service-instance-parameter
         |        +--rw service?         string
         |        +--rw instance-name?   string
         +--ro health-score?                       uint8
         +--rw symptoms
         |  +--ro symptom* [start-date-time id]
         |     +--ro id                     string
         |     +--ro health-score-weight?   uint8
         |     +--ro label?                 string
         |     +--ro start-date-time        yang:date-and-time
         |     +--ro stop-date-time?        yang:date-and-time
         +--rw dependencies
            +--rw dependency* [type id]
               +--rw type               -> /subservices/subservice/type
               +--rw id                 -> 
/subservices/subservice[type=current()/../type]/id
               +--rw dependency-type?   identityref

The YANG modules comes from 
https://datatracker.ietf.org/doc/draft-claise-opsawg-service-assurance-yang/
Have a look at 
https://raw.githubusercontent.com/YangModels/yang/ecb622b214e59c5f6312e915d4d65823a6485852/experimental/ietf-extracted-YANG-modules/ietf-service-assurance@2020-01-13.yang

The leafs in question:

           leaf under-maintenance {
             type boolean;
             default false;
             description
               "An optional flag indicating whether this particular subservice is under
               maintenance. Under this circumstance, the subservice symptoms and the
               symptoms of its dependencies in the assurance graph should not be taken
               into account. Instead, the subservice should send a 'Under Maintenance'
               single symptom.

               The operator changing the under-maintenance value must set the
               maintenance-contact variable.

               When the subservice is not under maintenance any longer, the
               under-maintenance flag must return to its default value and
               the under-maintenance-owner variable deleted.";
           }
           leaf maintenance-contact {
    when "../under-maintenance";
             type string;
             mandatory true;
             description
               "A string used to model an administratively assigned name of the
               resource that changed the under-maintenance value to 'true.

               It is suggested that this name contain one or more of the following:
               IP address, management station name, network manager's name, location,
               or phone number. In some cases the agent itself will be the owner of
               an entry. In these cases, this string shall be set to a string
               starting with 'monitor'.";
           }

In case of a leaf (maintenance-contact) with a when statement pointing 
to an optional leaf (under-maintenance), should the leaf 
(maintenance-contact) be marked as optional in the tree output?

Regards, Benoit