Re: [yang-doctors] Checking for parent path in grouping

Martin Bjorklund <mbj@tail-f.com> Wed, 03 April 2019 06:03 UTC

Return-Path: <mbj@tail-f.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 42587120395 for <yang-doctors@ietfa.amsl.com>; Tue, 2 Apr 2019 23:03:43 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_PASS=-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 UdUhUSdey79e for <yang-doctors@ietfa.amsl.com>; Tue, 2 Apr 2019 23:03:41 -0700 (PDT)
Received: from mail.tail-f.com (mail.tail-f.com [46.21.102.45]) by ietfa.amsl.com (Postfix) with ESMTP id 8398B120019 for <yang-doctors@ietf.org>; Tue, 2 Apr 2019 23:03:41 -0700 (PDT)
Received: from localhost (h-4-215.A165.priv.bahnhof.se [158.174.4.215]) by mail.tail-f.com (Postfix) with ESMTPSA id A026A1AE02BD; Wed, 3 Apr 2019 08:03:38 +0200 (CEST)
Date: Wed, 03 Apr 2019 08:03:38 +0200
Message-Id: <20190403.080338.1391266080087302511.mbj@tail-f.com>
To: acee@cisco.com
Cc: yang-doctors@ietf.org
From: Martin Bjorklund <mbj@tail-f.com>
In-Reply-To: <D8075959-82D6-44B3-B54C-5703EF544961@cisco.com>
References: <D8075959-82D6-44B3-B54C-5703EF544961@cisco.com>
X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO)
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/9GmFdjlNpk2WWq91Qmpq6dF5aRM>
Subject: Re: [yang-doctors] Checking for parent path in grouping
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: Wed, 03 Apr 2019 06:03:43 -0000

"Acee Lindem (acee)" <acee@cisco.com> wrote:
> Is there a way to check for particular parent path so that a container
> or leaf in a grouping would be present ONLY when it is “used” from a
> particular path? For example:
> 
> grouping foo {
>   container foo {
>     container red {
>          when “../../red-parent”;
>     }
>     container blue {
>           when “../../blue-parent”;
>      }
>    }
> }
> 
> 
> container red-parent {
>   uses foo;
> }
>  container blue-parent {
>    uses foo;
> }
> 
> It compiled fine using pyang but the check didn’t exclude the
> container with the non-matching parent from the path in the formatted
> tree (pyang -f tree output).

As you noted it works, but since the "when" expressions are evaluated
at runtime, you'll see both "red" and "blue" in both parents in the
tree output - they are present in the schema, but their when
expressions will always be false.


/martin