[netmod] yanglint and implemented versus imported YANG modules

William Lupton <wlupton@broadband-forum.org> Mon, 06 March 2017 16:44 UTC

Return-Path: <wlupton@broadband-forum.org>
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 D4BD7129464 for <netmod@ietfa.amsl.com>; Mon, 6 Mar 2017 08:44:56 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.2
X-Spam-Level:
X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
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 5aFrlNiTa9BP for <netmod@ietfa.amsl.com>; Mon, 6 Mar 2017 08:44:55 -0800 (PST)
Received: from mail.amsl.com (c8a.amsl.com [4.31.198.40]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 41B2312945A for <netmod@ietf.org>; Mon, 6 Mar 2017 08:44:55 -0800 (PST)
Received: from localhost (localhost [127.0.0.1]) by c8a.amsl.com (Postfix) with ESMTP id 697131E5664; Mon, 6 Mar 2017 08:44:17 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
Received: from mail.amsl.com ([127.0.0.1]) by localhost (c8a.amsl.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 9IsWMenyczV9; Mon, 6 Mar 2017 08:44:17 -0800 (PST)
Received: from [192.168.1.127] (host81-132-49-127.range81-132.btcentralplus.com [81.132.49.127]) by c8a.amsl.com (Postfix) with ESMTPSA id 6B5011E565B; Mon, 6 Mar 2017 08:44:16 -0800 (PST)
From: William Lupton <wlupton@broadband-forum.org>
Content-Type: multipart/alternative; boundary="Apple-Mail=_80CB0879-CF53-43F6-8DAB-1B0E70FE497F"
Message-Id: <1C757F2F-D47A-4688-845D-ACCE04AE56D1@broadband-forum.org>
Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\))
Date: Mon, 6 Mar 2017 16:44:52 +0000
To: netmod@ietf.org
X-Mailer: Apple Mail (2.3124)
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/wPASzAUAyXkbIS4fYPLcfFYQz1s>
Subject: [netmod] yanglint and implemented versus imported YANG modules
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.17
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: Mon, 06 Mar 2017 16:44:57 -0000

All,

This message arose from a yang-multicast@ietf.org <mailto:yang-multicast@ietf.org> “draft-ietf-pim-igmp-mld-yang-02.txt: YANG compilation isuse” (sic) thread <https://www.ietf.org/mail-archive/web/yang-multicast/current/threads.html#00232> initiated by Benoit.

I thought it would be useful for NETMOD to see the part of the discussion that relates to implemented versus imported YANG modules.
Benoit Claise reported this warning:
warn: Schema node "ietf-ip:ipv4" not found (/ietf-interfaces:interfaces/ietf-interfaces:interface[ietf-interfaces:name = current()]/ietf-ip:ipv4)
Radek Krejčí replied:
These warnings are printed because in yanglint, until explicitly stated, the imported modules (such as ietf-interfaces and ietf-ip), are supposed to be only imported, not implemented. The data nodes in imported schemas are not available, which is the reason of these warnings.
William Lupton (that’s me!) asked / commented:
Why are the complaints only about ip:ipv4 (etc) and not about if:interfaces (etc), which are also referenced in the must statements?
This makes it hard for an automated tool (such as Benoit’s) because it needs to know which other YANG files to process in addition to the “file of interest”.
Radek Krejčí replied:
According to RFC 7950, sec 5.6.6 (3rd paragraph) [ED: 5.6.5?], when an implemented module augments another module (ietf-interfaces), the augmented module MUST be also implemented. So libyang automatically changes the augmented module from imported to the implemented. The same rule applies also in case of referring a module in path (leafref) and by deviating a module. But it does not apply when a module data is used in must or when conditions. That's the reason why it complains just about ietf-ip and not about ietf-interfaces.
YANG actually does not provide a way to specify that a particular import is also expected to be implemented. Therefore, libyang needs some help with setting modules implemented - all the explicitly loaded modules are supposed to be implemented, if the module is just implicitly loaded from the search directory and user did not expressed that it is supposed to be implemented, it is kept only imported to provide groupings or type definitions
Benoit Claise asked (referring to my reference to automated tools):
Would it be possible to improve the warning (and the related test, by testing implemented instead of import), basically telling that the module itself is fine?

I’m interested to know that NETMOD thinks about this distinction between implemented versus imported (in the absence of any instance documents). I guess my (maybe naive) view is that if all I’m doing is checking for errors in my YANG model then I don’t care about this. If my YANG is good I want to see no warnings or errors, and if it’s bad then I want to be told this (and why).

Thanks,
William