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 <[email protected] <mailto:[email protected]>> On 
> Behalf Of Jan Lindblad
> Sent: Donnerstag, 4. August 2022 12:23
> To: Michael Richardson <[email protected] <mailto:[email protected]>>
> Cc: [email protected] <mailto:[email protected]>; [email protected] 
> <mailto:[email protected]>
> 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
>  

_______________________________________________
Anima mailing list
[email protected]
https://www.ietf.org/mailman/listinfo/anima

Reply via email to