[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [YANG] import statement
Juergen Schoenwaelder wrote:
> On Sat, May 03, 2008 at 04:00:37PM +0200, Ladislav Lhotka wrote:
>
>> Then the one and only way for utilizing the imported name "foo-cont" in
>> module bar is in
>>
>> augment /foo:foo-cont {
>> ...
>> }
>>
>> which results in placing (possibly augmented) copy of the "foo-cont"
>> container at the location of the augment statement. Or am I missing
>> something?
>
> You are missing something. ;-) Here is what the YANG ID says (section
> 7.15):
>
> The "augment" statement allows a module or submodule to add to the
> schema tree defined in another module or submodule.
>
> And section 3:
>
> o augment: Adds new nodes to a previously defined node.
>
> And section 4.2.8:
>
> YANG allows a module to insert additional nodes into data models,
> including both the current module (and its submodules) or an external
> module. This is useful e.g. for vendors to add vendor-specific
> parameters to standard data models in an interoperable way.
>
> The "augment" statement defines the location in the data model
> hierarchy where new nodes are inserted, and the "when" statement
> defines the conditions when the new nodes are valid.
>
> There are also examples. An augment of foo-cont simply sticks nodes
> into the foo-cont container; there is no new instantiation of
> foo-cont.
>
There is one somewhat non-intuitive aspect of augment,
which is demonstrated in the netconf.yang module. E.g:
grouping RpcOperationSourceType {
description "NETCONF 'source' Parameter contents.";
uses CommonConfigSourceType;
augment config-source {
leaf url {
description
"URL pointing to config data. Only available
if 'url' capability supported.";
type ConfigURIType;
}
anyxml config {
description "Inline configuration data";
}
}
}
Implementation notes:
For local (i.e., same namespace) augments, you need to expand
any uses-stmts first, and then apply the augment-stmt.
It looks strange to augment stuff that isn't there (yet),
but that is the nature of grouping/uses.
There is also a 'ripple-effect' with groupings,
uses, and augment, because they can all be nested within
nodes, notifications, and rpcs, and there is no clause order
in YANG (so your code better not be sensitive to forward
references or the different ordering permutations that can occur).
Processing the tree correctly requires more than one pass, bottom to top.
> /js
>
Andy
_______________________________________________
YANG mailing list
YANG at ietf.org
https://www.ietf.org/mailman/listinfo/yang