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

Martin Björklund <mbj+ietf@4668.se> Tue, 17 March 2020 18:42 UTC

Return-Path: <mbj+ietf@4668.se>
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 485223A0A67 for <yang-doctors@ietfa.amsl.com>; Tue, 17 Mar 2020 11:42:34 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.101
X-Spam-Level:
X-Spam-Status: No, score=-0.101 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_NAKED_TO_NUMERO=1.999, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=4668.se header.b=kJyvKhQa; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=2Y84zGZM
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 uIp88URYvpwe for <yang-doctors@ietfa.amsl.com>; Tue, 17 Mar 2020 11:42:32 -0700 (PDT)
Received: from wnew2-smtp.messagingengine.com (wnew2-smtp.messagingengine.com [64.147.123.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id C63573A0A57 for <yang-doctors@ietf.org>; Tue, 17 Mar 2020 11:42:32 -0700 (PDT)
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.west.internal (Postfix) with ESMTP id B7341850; Tue, 17 Mar 2020 14:42:31 -0400 (EDT)
Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 17 Mar 2020 14:42:32 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=4668.se; h=date :message-id:to:cc:subject:from:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=fm1; bh= 2RBEOHibRjWL29YlRNV7hLHnE3UPXJ76gzlz1m7a8Q0=; b=kJyvKhQaNUSy+L8G FRVJSJ9sgzGFKNIoH9yfWB+401+w6eTzFQNtSG0SqpoH9blzr4K0n2G6I4+MPC0Q KNYuYvbRV+SBC/Ab3CLqip3wByHeV818J0ZamSBIPZ7+Q1e4v3GWdUVkJ4r1R94Z R0v4uOJ9hL3SjjrS4v+83OmvkAHuARxjhW2KCQRdz71QvQfdeaIEnKso6ITp7S1Z GdoweGOGhOEgjNORDOTGOltcNq92/maJKXDwMTC2+29Zle1WNztbDG6RqOp+Gca4 JQ/E4acn0dwLit1zVDUMZjrmKAn+9cjWLCqUB2np34bHvsTk67bPzSkqd7cNOSY9 2sXWVQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=2RBEOHibRjWL29YlRNV7hLHnE3UPXJ76gzlz1m7a8 Q0=; b=2Y84zGZMTPCzmrJSbf6/Oun8n5wp4qpeCiMbg+esPODC32ZbdUhlvr8Pj jP9FlS6Q1VyCQvC9hD5odTiJeZxgnYuObCJRP2DrAJ60M4Zv+KPRnk+eRs4hR/LO a9WLtGgg2ECabEX8fBaEibYZ+3+Y7MHbuDo4RCoC8YexCHSDltD1EhqR4lv5JRN4 Ryco1wQOP31xgwOHa6C2O4o6wTSmtsj9OSZdvzWfecVtrjYtoIagnHmsXlKU1wXx oQX89V9/7bc7/phdUjGEBqu6na/O5S6gt2m9M2+zMoL5i6aaflCMuHQKElqWcFBO JRP76cIfPWeUAkQY5CeISNhPT1Xfw==
X-ME-Sender: <xms:FhpxXqB-xXJqDSmNZ-PW-TQfiqPbHB0i4nKoNNi9Qawx0p6IlITUMg>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrudefhedguddtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffkvffuhfgjfhfogggtgfesth hqredtredtudenucfhrhhomhepofgrrhhtihhnuceujhpnrhhklhhunhguuceomhgsjhdo ihgvthhfseegieeikedrshgvqeenucffohhmrghinhepihgvthhfrdhorhhgpdhgihhthh husghushgvrhgtohhnthgvnhhtrdgtohhmnecukfhppeduheekrddujeegrdegrdeggeen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmsghjod hivghtfhesgeeiieekrdhsvg
X-ME-Proxy: <xmx:FhpxXlR50C8b306B8DAcQ1bxYoDfkfIsSEsWnvWKfWPa7FXnYIK7Fg> <xmx:FhpxXps_Zel7Lg2sFN0C4iKQjuX34Fu6IoQcxSxb3sGVyFhtJLU1zg> <xmx:FhpxXp3NLXKjayTsLSAppF6RRi1Ul6-liey2qZL4W5iroRZPIMhyKw> <xmx:FhpxXrn9YbA77BxsiueE2YgYccf-x9P87uMrpZBCrEztWFZ1Jvtr-xzI3Ow>
Received: from localhost (unknown [158.174.4.44]) by mail.messagingengine.com (Postfix) with ESMTPA id 8883E3061856; Tue, 17 Mar 2020 14:42:29 -0400 (EDT)
Date: Tue, 17 Mar 2020 19:42:27 +0100
Message-Id: <20200317.194227.901858575906585602.id@4668.se>
To: bclaise=40cisco.com@dmarc.ietf.org
Cc: lhotka@nic.cz, yang-doctors@ietf.org, evyncke@cisco.com, jquilbeu@cisco.com
From: Martin Björklund <mbj+ietf@4668.se>
In-Reply-To: <c5f81ba6-31df-2114-9568-32c941d117de@cisco.com>
References: <50f02dc5-850d-90c5-9cad-48a062fe686c@cisco.com> <87imj2opwc.fsf@nic.cz> <c5f81ba6-31df-2114-9568-32c941d117de@cisco.com>
X-Mailer: Mew version 6.8 on Emacs 25.2
Mime-Version: 1.0
Content-Type: Text/Plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/fwkZmDj8YgW62YwjjyzyiqkDc1U>
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 18:42:35 -0000

Hi,

Benoit Claise <bclaise=40cisco.com@dmarc.ietf.org> wrote:
> Hi Lada,
> 
> Thanks for the XPath correction.
> When I apply this change, I still see the maintenance-contact as
> mandatory.

maintenance-contact has a "mandatory true" statement.  The "when"
statement doesn't change that.  Hence it is marked as mandatory in the
tree diagram.  "when" statements are not visible in tree diagrams.


/martin


> 
> $ 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
> 
> I guess the validation is not clever enough to combine "mandatory
> true" and Xpath (when "../under-maintenance='true'") from
> maintenance-contact with the optional under-maintenance leaf ... to
> conclude that maintenance-contact is actually optional.
> 
> Regards, Benoit
> > 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
> 
> _______________________________________________
> yang-doctors mailing list
> yang-doctors@ietf.org
> https://www.ietf.org/mailman/listinfo/yang-doctors