Re: [netmod] Augmentation with a mandatory leaf in a submodule - Is the following legal?

Robert Wilton <rwilton@cisco.com> Fri, 15 February 2019 10:08 UTC

Return-Path: <rwilton@cisco.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 1EB89130F9F for <netmod@ietfa.amsl.com>; Fri, 15 Feb 2019 02:08:28 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -14.5
X-Spam-Level:
X-Spam-Status: No, score=-14.5 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_DEF_DKIM_WL=-7.5] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cisco.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FEj2EdZyrla3 for <netmod@ietfa.amsl.com>; Fri, 15 Feb 2019 02:08:25 -0800 (PST)
Received: from aer-iport-2.cisco.com (aer-iport-2.cisco.com [173.38.203.52]) (using TLSv1.2 with cipher DHE-RSA-SEED-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 708F2130F8E for <netmod@ietf.org>; Fri, 15 Feb 2019 02:08:24 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=11545; q=dns/txt; s=iport; t=1550225304; x=1551434904; h=subject:to:references:from:message-id:date:mime-version: in-reply-to; bh=U04mDLg9AF1rZQU+BoeoZ+5TiWQLXl8yGlBo5ZjYb0M=; b=FvPEYLX8Tcs/whCYtGZnDHQ0LMsAP9DRkC7A9Msf/V2Er3va4TwNpt/S suPPOUqRQxFpUAikBWQC3MtKlH9/2s/Qb8TuQl+UnFVAygWjqA7o/IjfE QxNQt8BbsOm0ma8hUxUBoMwB/RrKsx9pxyskB+3E2cBjjkYnbEi5F9ize E=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A0AJAAAOj2Zc/xbLJq0ZAUoZAQEBAQEBAQEBAQEBBwEBAQEBAYFTAgEBAQEBCwEBgmhQASASJ4QGiHmMay2SJ4VwgXsNGAEKhANGAoQKNgcNAQMBAQIBAQJtHAyFSwEBAQMBASFIAxsJAhgqAgInMAYBDAYCAQGDHAGBcg+MOYJpm2GBLx+FJYRtjFuBQD+BOII2By6DEwsBAQIBgT4BAQ6DGYJXAol9iCWRFAmHPIsTBhmKXIgdgyeHGYVGgzaBeYcogU0NJIE/DwgzGggbFTuCbAmCSYM4hRSFPz8DMAGNe4I+AQE
X-IronPort-AV: E=Sophos; i="5.58,372,1544486400"; d="scan'208,217"; a="10115716"
Received: from aer-iport-nat.cisco.com (HELO aer-core-3.cisco.com) ([173.38.203.22]) by aer-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Feb 2019 10:08:21 +0000
Received: from [10.63.23.84] (dhcp-ensft1-uk-vla370-10-63-23-84.cisco.com [10.63.23.84]) by aer-core-3.cisco.com (8.15.2/8.15.2) with ESMTP id x1FA8LCI008472; Fri, 15 Feb 2019 10:08:21 GMT
To: "Beauville, Yves (Nokia - BE/Antwerp)" <yves.beauville@nokia.com>, "netmod@ietf.org" <netmod@ietf.org>
References: <6b988ca0-7634-6a57-e984-6553f8f706b7@nokia.com>
From: Robert Wilton <rwilton@cisco.com>
Message-ID: <b97a5f89-b547-203c-d03f-ba68f83708e5@cisco.com>
Date: Fri, 15 Feb 2019 10:08:20 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0
MIME-Version: 1.0
In-Reply-To: <6b988ca0-7634-6a57-e984-6553f8f706b7@nokia.com>
Content-Type: multipart/alternative; boundary="------------31FFA7F6A0273F5D9091A6EA"
Content-Language: en-US
X-Outbound-SMTP-Client: 10.63.23.84, dhcp-ensft1-uk-vla370-10-63-23-84.cisco.com
X-Outbound-Node: aer-core-3.cisco.com
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/ySnqj6Us2cUWZz2Nxqg4PdcydaA>
Subject: Re: [netmod] Augmentation with a mandatory leaf in a submodule - Is the following legal?
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
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: Fri, 15 Feb 2019 10:08:28 -0000

Hi Yves,

My interpretation of the spirit of the RFC is that this should be 
allowed, and I don't think that any text in 7.17 specifically prevents this.

However, this seems like a corner case, and I am also not surprised that 
a YANG compiler would fail on this.  This issue could perhaps be easily 
mitigated by making the second augmentation also conditional on the same 
when statement.

Note that the use of sub-modules doesn't really matter, in that a 
compiler can treat them as one module.  So, I think that the problem is 
equivalent to:

module module-a {
   yang-version 1.1;
   namespace "http://www.example.com/anothermodule";
   prefix am;

   container top {
     leaf type {
       type string;
       mandatory true;
     }
   }
}

module module-b {
   yang-version 1.1;
   namespace "http://www.example.com/module-b";
   prefix mm;

   augment '/am:top' {
     when "am:type = 'test'";
     container first-augment {
     }

   augment '/am:top/mm:first-augment' {
     leaf mandatory-leaf {
       type string;
       mandatory true;
      }
   }
}

Thanks,
Rob


On 15/02/2019 09:12, Beauville, Yves (Nokia - BE/Antwerp) wrote:
> Hi,
>
> We are working with a submodule in which we are augmenting a container 
> of the same module with a mandatory node. There is a small catch though.
>
> Our YANG modules are actually supporting two augmentations - I have 
> copied a trimmed down version of our modules at the end of this mail -:
>
> * From container 'top' in 'module-a' to container 'first-augment' in 
> 'module-b' (sub-module-1) => This augmentation is made conditional 
> with a 'when' statement.
>
> * From container 'first-augment' to leaf 'mandatory-leaf'. This is 
> done within two submodules of the same module 'module-b' => This 
> augmentation is NOT conditional.
>
> The Open Daylight parser rejects our YANG modules with the following 
> error:
>
>    Failed to add augmentation sub-module-1b.yang defined at 
> sub-module-2b.yang 
> org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException: An 
> augment cannot add node 'mandatory-leaf' because it is mandatory and 
> in module different than target [at sub-module-2b.yang]
>
> As per https://tools.ietf.org/html/rfc7950#section-7.17 
> <https://tools.ietf.org/html/rfc7950#section-7.17>, we believe these 
> augmentations are both legal'.
>
> We have raised a ticket YANGTOOLS-956 at Open Daylight but folks at 
> ODL are asking us to check with experts in this mailing list.
>
> Can one assess if these models are making a 'legal' use of 
> augmentations or not?
>
> Yves
>
> ================================
>
> module module-a {
>   yang-version 1.1;
>     namespace "http://www.example.com/anothermodule";
>     prefix am;
>     container top {
>       leaf type {
>         type string;
>         mandatory true;
>       }
>   }
> }
> module module-b {
>   yang-version 1.1;
>     namespace "http://www.example.com/module-b";
>    prefix mm;
>    include sub-module-1;
>    include sub-module-2;
> }
> submodule sub-module-1 {
>    yang-version 1.1;
>    belongs-to module-b {
>     prefix mm;
>   }
>     import module-a {
>     prefix am;
>   }
>   augment '/am:top' {
>     when "am:type = 'test'";
>     container first-augment {
>     }
>   }
> }
> submodule sub-module-2 {
>   yang-version 1.1;
>   belongs-to module-b {
>     prefix mm;
>   }
>     import module-a {
>     prefix am;
>   }
>   include sub-module-1;
>   grouping dummygrouping {
>     leaf mandatory-leaf {
>       type string;
>       mandatory true;
>      }
>   }
>   augment '/am:top/mm:first-augment' {
>     uses dummygrouping;
>   }
> }
>
> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod