Re: [netmod] [Anima] mcr's YANG question raised during the ANIMA WG session

Jan Lindblad <janl@tail-f.com> Thu, 04 August 2022 14:52 UTC

Return-Path: <janl@tail-f.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 79868C157B49; Thu, 4 Aug 2022 07:52:56 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.908
X-Spam-Level:
X-Spam-Status: No, score=-1.908 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1zrhzcSKKxcQ; Thu, 4 Aug 2022 07:52:55 -0700 (PDT)
Received: from mail.tail-f.com (mail.tail-f.com [46.21.102.45]) by ietfa.amsl.com (Postfix) with ESMTP id 1A19CC14CF01; Thu, 4 Aug 2022 07:52:54 -0700 (PDT)
Received: from smtpclient.apple (213-67-237-150-no99.tbcn.telia.com [213.67.237.150]) by mail.tail-f.com (Postfix) with ESMTPSA id AABBB1AE0332; Thu, 4 Aug 2022 16:52:52 +0200 (CEST)
From: Jan Lindblad <janl@tail-f.com>
Message-Id: <C4E85A69-B917-439E-95B2-C2B81DFCE98C@tail-f.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_E324E1AA-3A78-4B56-9F40-A992F953704C"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Date: Thu, 04 Aug 2022 16:52:52 +0200
In-Reply-To: <DU0PR10MB5196E745ED557F3474EE6D5AF39F9@DU0PR10MB5196.EURPRD10.PROD.OUTLOOK.COM>
Cc: "Anima@ietf.org" <anima@ietf.org>, "netmod@ietf.org" <netmod@ietf.org>
To: "Fries, Steffen" <steffen.fries@siemens.com>, Michael Richardson <mcr+ietf@sandelman.ca>
References: <DU0PR10MB5196F26C92DD2F266A4FAC28F3949@DU0PR10MB5196.EURPRD10.PROD.OUTLOOK.COM> <365823.1658933390@dooku> <DU0PR10MB5196ADB3702B7417B0589555F3979@DU0PR10MB5196.EURPRD10.PROD.OUTLOOK.COM> <446675.1659033968@dooku> <DU0PR10MB51966008D0EA49AC6FCD3FB9F3999@DU0PR10MB5196.EURPRD10.PROD.OUTLOOK.COM> <539974.1659103385@dooku> <YuhrI/iINFJxPOC7@faui48e.informatik.uni-erlangen.de> <32336.1659550668@localhost> <58217DD1-D5C2-4C99-BDF9-5BA5B252AE56@tail-f.com> <DU0PR10MB5196E745ED557F3474EE6D5AF39F9@DU0PR10MB5196.EURPRD10.PROD.OUTLOOK.COM>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/iXDL5LiLV328zXVdp1mzMJIkizY>
Subject: Re: [netmod] [Anima] mcr's YANG question raised during the ANIMA WG session
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 04 Aug 2022 14:52:56 -0000

Steffen, 

I'll make a sketch here, let me know if you have questions.

One ("maximum groupings") way of dealing with this would be:

module A {
  grouping a-base-plate { ... }
}

module B {
  import A { prefix a; }
  
  grouping b-secret-sauce { ... }

  grouping b-mounted-in-a {
    uses a:a-base-plate {
      augment grafting-point-in-base {
        uses b-secret-sauce;
      }
    }
  }
}

module C {
  import A { prefix a; }

  groping c-cool-stuff { ... }

  grouping c-mounted-in-a {
    uses a:a-base-plate {
      augment grafting-point-in-base {
        uses c-cool-stuff;
      }
    }
  }
}
    
module D {
  import A { prefix a; }
  import B { prefix b; }
  import C { prefix c; }

  grouping d-full-echilada {
    uses a:a-base-plate {
      augment grafting-point-in-base {
        uses b:b-secret-sauce;
      }
      augment grafting-point-in-base {
        uses c:c-cool-stuff;
      }
    }
  }
}

The same structure could also be built without groupings, just using augment, but as I understand it, the point here was to build some rc:yang-data structures, and then I guess the grouping approach is the way. The "X-mounted-in-a" groupings could be skipped entirely if nobody is interested in using B or C directly in a pre-packaged form.

Best Regards,
/jan



> Hi Jan, 
>  
> Thank you for the test. 
>  
>  
> From: Anima <anima-bounces@ietf.org <mailto:anima-bounces@ietf.org>> On Behalf Of Jan Lindblad
> Sent: Donnerstag, 4. August 2022 12:23
> To: Michael Richardson <mcr+ietf@sandelman.ca <mailto:mcr+ietf@sandelman.ca>>
> Cc: Anima@ietf.org <mailto:Anima@ietf.org>; netmod@ietf.org <mailto:netmod@ietf.org>
> Subject: Re: [Anima] [netmod] mcr's YANG question raised during the ANIMA WG session
>  
> Michael,
>  
> I had a look at your test example. The example is invalid, but pyang fails to detect the error and overwrites some internal structures, with the result below. The root cause of the problem is this:
>  
> module ietf-voucher-D {
> ...
>   uses b:voucher-request-prm-grouping {
>     augment "voucher" { }
>   }
> 
>   uses c:voucher-request-constrained-grouping {
>     augment "voucher" { }
>   }
> }
> 
> Each one of the two uses statement brings in a "container voucher" (with partly different content) at this point in the schema. That is an attempt at a duplicate definition of voucher, which is an error. Pyang misses this, and overwrites one voucher object with the next, losing some of the content.
>  
> By placing the two uses statements into separate containers, pyang is able to successfully make a tree:
>  
> module: ietf-voucher-D
>   +--rw x1
>   |  +--rw voucher
>   |     +--rw created-on?                                yang:date-and-time
>   |     +--rw expires-on?                                yang:date-and-time
>   |     +--rw assertion?                                 enumeration
>   |     +--rw serial-number                              string
>   |     +--rw idevid-issuer?                             binary
>   |     +--rw pinned-domain-cert?                        binary
>   |     +--rw domain-cert-revocation-checks?             boolean
>   |     +--rw nonce?                                     binary
>   |     +--rw last-renewal-date?                         yang:date-and-time
>   |     +--rw prior-signed-voucher-request?              binary
>   |     +--rw proximity-registrar-cert?                  binary
>   |     +--rw agent-signed-data?                         binary
>   |     +--rw agent-provided-proximity-registrar-cert?   binary
>   |     +--rw agent-sign-cert*                           binary
>   +--rw x2
>      +--rw voucher
>         +--rw created-on?                        yang:date-and-time
>         +--rw expires-on?                        yang:date-and-time
>         +--rw assertion                          enumeration
>         +--rw serial-number                      string
>         +--rw idevid-issuer?                     binary
>         +--rw pinned-domain-cert?                binary
>         +--rw domain-cert-revocation-checks?     boolean
>         +--rw nonce?                             binary
>         +--rw last-renewal-date?                 yang:date-and-time
>         +--rw proximity-registrar-pubk?          binary
>         +--rw proximity-registrar-pubk-sha256?   binary
>         +--rw proximity-registrar-cert?          binary
>         +--rw prior-signed-voucher-request?      binary
>  
> Normally in YANG, it wouldn't be hard to to let modules "B" and "C" augment module "A" independently. But here you are working with groupings in such a way that both "B" and "C" build up a complete grouping with everything in "A". When "D" tries to use both "B" and "C", there is inevitably unwanted duplication. If instead, "B" and "C" just defined their little contributions, "D" could import groupings from "A", "B" and "C" and compose them as desired.
>  
> [stf] Just to be sure, you said you would recommend to avoid the “use” statement, which leads to duplication when creating “D”. I understand this for the inclusion case.
> If we use voucher B stand alone without the “use” statement wouldn’t we miss  a part of the voucher? Or would you recommend to move the use out of the grouping?
>  
> Regards
> Steffen
>  
>  
> Best Regards,
> /jan
>