Re: [YANG] import statement

Andy Bierman <ietf@andybierman.com> Sat, 03 May 2008 15:14 UTC

Return-Path: <yang-bounces@ietf.org>
X-Original-To: yang-archive@optimus.ietf.org
Delivered-To: ietfarch-yang-archive@core3.amsl.com
Received: from core3.amsl.com (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 9CDED3A6B35; Sat, 3 May 2008 08:14:41 -0700 (PDT)
X-Original-To: yang@core3.amsl.com
Delivered-To: yang@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 80F923A67A7 for <yang@core3.amsl.com>; Sat, 3 May 2008 08:14:40 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.522
X-Spam-Level:
X-Spam-Status: No, score=-0.522 tagged_above=-999 required=5 tests=[AWL=-0.166, BAYES_00=-2.599, J_CHICKENPOX_74=0.6, RCVD_IN_NJABL_PROXY=1.643]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZiHGTIIc6bPy for <yang@core3.amsl.com>; Sat, 3 May 2008 08:14:39 -0700 (PDT)
Received: from smtp101.sbc.mail.mud.yahoo.com (smtp101.sbc.mail.mud.yahoo.com [68.142.198.200]) by core3.amsl.com (Postfix) with SMTP id 9EEDB3A6BB7 for <yang@ietf.org>; Sat, 3 May 2008 08:14:39 -0700 (PDT)
Received: (qmail 83416 invoked from network); 3 May 2008 15:14:40 -0000
Received: from unknown (HELO ?127.0.0.1?) (andybierman@att.net@67.127.166.23 with plain) by smtp101.sbc.mail.mud.yahoo.com with SMTP; 3 May 2008 15:14:39 -0000
X-YMail-OSG: BMJpKH0VM1m6UKBXmi5WsKwP3x.Do789W2lc4WlUjWPeLyAgLEoXBtqhCP5MowZ.IyuRxlSnoJ0SSisbTMHcp_bhV_1p.h4dSTYrLP7HyWzW1LT7RLFi5Z9zc6hwt0u2wm0-
X-Yahoo-Newman-Property: ymail-3
Message-ID: <481C815D.5000903@andybierman.com>
Date: Sat, 03 May 2008 08:14:37 -0700
From: Andy Bierman <ietf@andybierman.com>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
To: Ladislav Lhotka <lhotka@cesnet.cz>, yang@ietf.org
References: <1209812833.14759.12.camel@missotis> <20080503120217.GA24899@elstar.local> <1209823237.14759.24.camel@missotis> <20080503143205.GA24972@elstar.local>
In-Reply-To: <20080503143205.GA24972@elstar.local>
Subject: Re: [YANG] import statement
X-BeenThere: yang@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: YANG modeling Language for NETCONF <yang.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/yang>, <mailto:yang-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/pipermail/yang>
List-Post: <mailto:yang@ietf.org>
List-Help: <mailto:yang-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/yang>, <mailto:yang-request@ietf.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: yang-bounces@ietf.org
Errors-To: yang-bounces@ietf.org

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@ietf.org
https://www.ietf.org/mailman/listinfo/yang