Subject: [YANG] uses statement

From: Andy Bierman <[email-masked]>
Date: Thu, 20 Dec 2007 11:10:59 -0800

Hi,

Section 7.11 para 2 says:

    The effect of a "uses" reference to a grouping is the same as if the
    "uses" statement was replaced with the contents of the "grouping"
    statement's content and updated according to the refinement
    statements.  Thus, the identifiers defined the grouping are copied
    into the current module, even if the grouping is imported from some
    other module.

This is not entirely true.
The grouping that is being used may be in another module.
The grouping statement is validated and 'resolved' within
the context of the grouping-stmt, not the uses-stmt.

-----------------

Module x:

  import foo { prefix foo; }

  typedef KnobType {
    type enumeration {
      enum zero;
      enum one;
      enum seven { value 7; }
    }
  }

  grouping group1 {
    leaf a { type int32; }
    leaf b { type KnobType; }
    leaf c { type foo:KnobType; }
  }

Module y:

  import x { prefix x; }
  import z { prefix z; }

  container con1 {
    uses x:group1;
    leaf d { type z:KnobType; }
  }

----------------

1) Both module x and y are valid YANG module fragments
2) The 'KnobType' data type is evaluated in the context of module 'x'
    so leaf 'b' and 'c' in 'group1' are always bound to the same data type
    no matter where the uses-stmt is located.
3) Although 'group1' is valid in module 'x', it would not be valid
    in module 'y', because 'KnobType' is not locally defined and
    would need a prefix (x:KnobType).
4) Since the 'type' field is not allowed to be refined, this 'type source'
    ambiguity is not a problem.
5) leaf 'c' is correctly bound to type foo:KnobType, and causes an
    implicit import of module foo into module y.
6) I'm not sure what the replacement text should be, so I thought I would
    ask this list

Andy

_______________________________________________
YANG mailing list
[email-masked]
https://www1.ietf.org/mailman/listinfo/yang

---

From: Martin Bjorklund <[email-masked]>
Date: Thu, 27 Dec 2007 08:41:15 +0100 (CET)

> the context of the grouping-stmt, not the uses-stmt.

Yes, you are right.

> 6) I'm not sure what the replacement text should be, so I thought I would

We'll have to figure this one out...

/martin