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

Ladislav Lhotka <lhotka@nic.cz> Tue, 17 March 2020 17:24 UTC

Return-Path: <lhotka@nic.cz>
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 E8A9E3A0903 for <yang-doctors@ietfa.amsl.com>; Tue, 17 Mar 2020 10:24:59 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.897
X-Spam-Level:
X-Spam-Status: No, score=-1.897 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
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 bTTQqokjmdhX for <yang-doctors@ietfa.amsl.com>; Tue, 17 Mar 2020 10:24:57 -0700 (PDT)
Received: from trail.lhotka.name (trail.lhotka.name [77.48.224.143]) by ietfa.amsl.com (Postfix) with ESMTP id 7FDBE3A0901 for <yang-doctors@ietf.org>; Tue, 17 Mar 2020 10:24:56 -0700 (PDT)
Received: by trail.lhotka.name (Postfix, from userid 109) id 3D724860063; Tue, 17 Mar 2020 18:22:37 +0100 (CET)
Received: from localhost (unknown [172.29.2.100]) by trail.lhotka.name (Postfix) with ESMTPSA id BDFC3860053; Tue, 17 Mar 2020 18:22:34 +0100 (CET)
From: Ladislav Lhotka <lhotka@nic.cz>
To: Benoit Claise <bclaise=40cisco.com@dmarc.ietf.org>, YANG Doctors <yang-doctors@ietf.org>
Cc: Eric Vyncke <evyncke@cisco.com>, "Jean Quilbeuf -X (jquilbeu - LIANEO at Cisco)" <jquilbeu@cisco.com>
In-Reply-To: <50f02dc5-850d-90c5-9cad-48a062fe686c@cisco.com>
References: <50f02dc5-850d-90c5-9cad-48a062fe686c@cisco.com>
Date: Tue, 17 Mar 2020 18:24:51 +0100
Message-ID: <87imj2opwc.fsf@nic.cz>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/4gpMYaU6-120vuiBnh6THU7j7qQ>
Subject: Re: [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 17:25:00 -0000

Hi Benoit,

"maintenance-contact" may remain mandatory - due to its default value, "under-maintenace" is always present, as far as XPath evaluation is concerned.

But because of this, your when expression probably doesn't have the effect that you expect: it will always be true. I think it needs to be changed to

    when "../under-maintenance = 'true'";

Lada

Benoit Claise <bclaise=40cisco.com@dmarc.ietf.org> writes:

> 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
> _______________________________________________
> yang-doctors mailing list
> yang-doctors@ietf.org
> https://www.ietf.org/mailman/listinfo/yang-doctors

-- 
Ladislav Lhotka 
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67