Re: [netmod] Questions about namings and prefixes in leafrefs
Paul Borman <borman@google.com> Thu, 22 January 2015 19:32 UTC
Return-Path: <borman@google.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 890581A6F3B for <netmod@ietfa.amsl.com>; Thu, 22 Jan 2015 11:32:15 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.188
X-Spam-Level:
X-Spam-Status: No, score=-0.188 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, J_CHICKENPOX_44=0.6, J_CHICKENPOX_54=0.6, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=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 lvW1QShUvdCZ for <netmod@ietfa.amsl.com>; Thu, 22 Jan 2015 11:32:11 -0800 (PST)
Received: from mail-vc0-x22d.google.com (mail-vc0-x22d.google.com [IPv6:2607:f8b0:400c:c03::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 589371B29D9 for <netmod@ietf.org>; Thu, 22 Jan 2015 11:32:11 -0800 (PST)
Received: by mail-vc0-f173.google.com with SMTP id id10so1180251vcb.4 for <netmod@ietf.org>; Thu, 22 Jan 2015 11:32:10 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=m0ngo/hBid8aq6FfPlJ02pR9iaJUf57NpD/Zm2iRNW8=; b=L4wogGpih+691Zmy82RBN4zjX/nnqIB/VXx71neWq8Ik9y2cvZm2553XasJg2I5xE9 0TUlcjYdeJbj+OTT3+KvGWjY72fm9pJxrai3npEI5DD0cR3zpkGa8ieD5eiRq9Vk7w6C NaEQibgDHCxGF+UGW8tKP+NRPIzYOKXnukFpsRqsK89Fvohbio44x5UVl4t20SAw+NAN ZXlu7SCeJswJi0X246vuNpOCyxt/ic3+U7/jeIKkTcm+AhFVEVf6Hwu7DvR3rRXxB0XZ VWUk6QyF8IIJMU869VSqxi/ixy0OzS0uQg5cp87ed36sNYGuo+ugQxC1d4gSVZqyBpNs AP8g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=m0ngo/hBid8aq6FfPlJ02pR9iaJUf57NpD/Zm2iRNW8=; b=VVLfQKEXHoZ7OgAh823J+JeXtK+n1MOn/CbFO65wIQdlKOufm77/hV29ai/sMTBNal zR6+Jsl75LOm7VVFkPBQsYseyIJvo3tEwg3S0EjnVoNjOgiJBTEBbd5L7VVPbIkJKyeo VjzcZneIW21j8wRu/Bg9l3tfmFRCV3nX4vNYN95rYcWBQ68sdl8QRN/shYMx/M5a6kPk 2OnL8QfNWszbQS8YJ/99+ioeaDmYeS+k5CnCaF6bcZJZekQtkXPqsNEZR5DfOSwfDRyq rPFpDyUaOw6UlTbUKHmbREAPk+xvpWH8h5ZA2DEVIDTIJ64QgBAYcEd4sdPEvnGSlqvf G+Ag==
X-Gm-Message-State: ALoCoQnT2Kr/WbU9kP8UUaxsBe9pCfPfnpZd9qMF/wZ0N1P8Xz+AZcStCHJE4QLvaeUDjllD2rfh
MIME-Version: 1.0
X-Received: by 10.52.87.209 with SMTP id ba17mr1413626vdb.28.1421955130021; Thu, 22 Jan 2015 11:32:10 -0800 (PST)
Received: by 10.52.246.194 with HTTP; Thu, 22 Jan 2015 11:32:09 -0800 (PST)
In-Reply-To: <B857976C-B080-4D35-9791-14350C21E2E3@nic.cz>
References: <CAHsVM3=n5fRUmN4MBs01b3kvNXD2WMt4E6FbcpowRYsHM8pE_w@mail.gmail.com> <m2ppa7m0au.fsf@nic.cz> <CAHsVM3momUxi_iqh5hEk931vFcLKd9S3=p=-+LtHRGJJwmAe7Q@mail.gmail.com> <B857976C-B080-4D35-9791-14350C21E2E3@nic.cz>
Date: Thu, 22 Jan 2015 11:32:09 -0800
Message-ID: <CAHsVM3=zFESWeMOZ+X2TwZ9PW+ysybUY0v_ThmUaaHQ9f_NnTQ@mail.gmail.com>
From: Paul Borman <borman@google.com>
To: Ladislav Lhotka <lhotka@nic.cz>
Content-Type: multipart/alternative; boundary="bcaec50407fe697821050d42ba75"
Archived-At: <http://mailarchive.ietf.org/arch/msg/netmod/rcjzptdvkMbQxNiYS2ktLTy329s>
Cc: netmod@ietf.org
Subject: Re: [netmod] Questions about namings and prefixes in leafrefs
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.15
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: <http://www.ietf.org/mail-archive/web/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: Thu, 22 Jan 2015 19:32:15 -0000
> > $ pyang base.yang other.yang > other.yang:15: error: type "base-type" not found in module other > other.yang:16: error: type "bad-type" not found in module other Okay, this appears to be a bug in the tree format: $ *pyang base.yang 2>&1 | grep -- -type* other.yang:15: error: type "base-type" not found in module other other.yang:16: error: type "bad-type" not found in module other $ *pyang -f tree base.yang 2>&1 | grep -- -type* +--rw other-group-leaf? other-type +--rw other-base-leaf? base-type +--rw other-bad-leaf? bad-type $ *pyang -f tree base.yang other.yang 2>&1 | grep -- -type* other.yang:15: error: type "base-type" not found in module other other.yang:16: error: type "bad-type" not found in module other +--rw other-group-leaf? other-type +--rw other-base-leaf? base-type +--rw other-bad-leaf? bad-type +--rw other-group-leaf? other-type +--rw other-base-leaf? base-type +--rw other-bad-leaf? bad-type I only specified base.yang as that was the only tree I was interested in. This research is part of a larger issue of how we are going to be able to combine various disparate modules defined in YANG into a single tree. Thus far it appears that module writers decide where the root of their tree is and the data tree of one module cannot become part of a tree for another module. That is, we cannot write, in pure YANG, a super module that includes several other modules where those module writers were unaware of the super module. It is recursive because we probably will later need a super super module that is a collection of super modules (and regular modules). Currently it appears that modules always know the root of the tree (either their own or one they augment). I don't yet see a combination of include, import, grouping, augment and/or uses that would enable this ability, but perhaps I am missing something. Thanks, -Paul On Thu, Jan 22, 2015 at 10:18 AM, Ladislav Lhotka <lhotka@nic.cz> wrote: > > > On 22 Jan 2015, at 18:43, Paul Borman <borman@google.com> wrote: > > > > Thanks for the response and clarification, Lada. > > > > > I am also trying to understand the prefixes used in XPath > representations. > > > I have tried using --tree-prefix but that does not appear to accept any > > > prefixes. > > > > The "tree" plugin has no such option, RTFM. > > > > Yes, clearly I meant --tree-path. Sorry to have confused you. Given > the chameleon aspect of groups, I take it that paths to a node in a data > tree (not the schema tree) do not have prefixes, and --tree-path takes a > path in the data tree (the documentation I read just says "Subtree to > print"). I am actually very happy to not have prefixes in the resulting > data tree at all. > > Sometimes they are needed, even in JSON encoding that tries to suppress > them as much as possible. > > > > > > - may optionally use the module's prefix for any element in a > leafref > > > path, no matter where the element is defined > > > > The prefix has to be present if the node is defined in another > > module. For example, a leafref in "base" pointing to > > "other-container-leaf1" would have > > > > path "/bother:other-container/bother:other-container-leaf1"; > > > > Interesting. So a path in a leafref references the resulting data tree, > while the path provided to augment references the schema tree. Re-reading > the "uses" description I see where it switches > > That’s right, augments modify the schema tree. > > > namespaces. > > > > Since it appears, via empirical evidence with pyang, that the nodes of > an imported tree do not become part of the tree of the importing module. > What does it mean to have a leafref reference a node in a > > That’s correct, the importing module only gets access to top-level > groupings, typedefs, identities and features. > > > tree other than its own? I will note that my example referred to a > node within a grouping defined in > > The information about the set of modules that comprise the data model has > to be supplied by other means. In NETCONF it is the hello message, and in > pyang you can either provide a hello message as an XML document (with the > --hello option), or simply put all modules on the command line. In your > case it could be > > $ pyang -f tree base.yang other.yang > > > other but used in base, while your example refers to a node that only > exists in other. So, my assertion about paths (they were all relative) and > prefix names was actually correct, but does not apply when referencing a > node in a different data tree (i.e., not part of the data tree of the base > module), which is what you gave an example of. > > > > The "switching names spaces" aspect of uses explains why I cannot use > the bother prefix in relative paths, or even in paths rooted in base, that > include nodes from a grouping in other. The satisfaction of types does > seem inconsistent with this, however. I added some typedefs to base.yang > and other.yang (base-type and other-type, respectively), and then modified > the grouping in other.yang to have: > > > > grouping other-group { > > leaf other-group-leaf { type other-type; } > > leaf other-base-leaf { type base-type; } > > leaf other-bad-leaf { type bad-type; } > > } > > > > When the other-group is used in base.yang, only bad-type is flagged as > not found (shouldn't other-type also be flagged as not found?), while when > other-group is used in other.yang, both base-type and bad-type are flagged > as not found (as I would expect). > > This is not what I get: > > $ pyang base.yang other.yang > other.yang:15: error: type "base-type" not found in module other > other.yang:16: error: type "bad-type" not found in module other > > This is correct because types and everything else in a grouping are > resolved in the context of the module where the grouping is defined, only > reusable data nodes defined by the grouping receive the namespace of the > module where the grouping is used. In your case, “base-type” is not known > in “other”. > > In the “base” module you could refer to “other-type” but only with the > prefix: > > type bother:other-type > > This is because “base” imports “other”. > > Lada > > > > > Thanks, > > > > -Paul > > > > On Thu, Jan 22, 2015 at 5:07 AM, Ladislav Lhotka <lhotka@nic.cz> wrote: > > Hi Paul, > > > > Paul Borman <borman@google.com> writes: > > > > > Hi, I am trying to understand RFC6020 without having had the benefit of > > > being in any of the discussions of the working group. I have found the > > > discussion of path names unclear so I have used pyang to try and > understand > > > what is expected. It seems to me that a path in a leafref: > > > > > > - may descend into submodule's containers > > > > yes > > > > > - may descend into used groupings, no matter where the grouping is > > > defined > > > > yes > > > > > - may *not* ascend into the parent module > > > > Actually, I am not sure about this one. > > > > > - may optionally use the module's prefix for any element in a > leafref > > > path, no matter where the element is defined > > > > The prefix has to be present if the node is defined in another > > module. For example, a leafref in "base" pointing to > > "other-container-leaf1" would have > > > > path "/bother:other-container/bother:other-container-leaf1"; > > > > > - may optionally use the belongs-to-prefix in elements in paths > inside a > > > submodule > > > > yes > > > > > - may *never* use the prefix for/from an imported module > > > > It must *always* use it. > > > > > > > > Some questions this raise are: > > > > > > - are these observations correct (and intended)? > > > - is there ever a time where a prefix is required in a leafref > > > path? > > > > Yes, see above. > > > > I hope submodule rules will be significantly simplified in YANG 1.1, see > > issue Y49: > > > > https://svn.tools.ietf.org/svn/wg/netmod/yang-1.1/issues.html#sec-50 > > > > ... > > > > > > > > I am also trying to understand the prefixes used in XPath > representations. > > > I have tried using --tree-prefix but that does not appear to accept any > > > prefixes. > > > > The "tree" plugin has no such option, RTFM. > > > > > // These next two ar invalid > > > leaf base-container-badref1 { > > > type leafref { path > > > ../other-group-container/bother:other-group-container-leaf1; } > > > > The prefix "bother" is wrong. It is because YANG groupings are > > "chameleons": nodes defined in a grouping receive the namespace of the > > module where the grouping is used, not the one in which it is > > defined. Sec sec. 7.12 in RFC 6020. > > > > Lada > > > > > } > > > leaf base-container-badref2 { > > > type leafref { path > > > ../other-group-container/pother:other-group-container-leaf1; } > > > } > > > } > > > } > > > > > > // included by base.yang. > > > submodule sub { > > > belongs-to base { prefix "sbase"; } > > > container sub-container { > > > leaf sub-container-leaf { type string; } > > > container subsub { > > > leaf sub-leafref { > > > type leafref { path ../../sub-container-leaf; } > > > } > > > leaf sub-leafref1 { > > > type leafref { path ../../sbase:sub-container-leaf; } > > > } > > > // the next two both fail trying to ascend into the parent > > > leaf sub-badref2 { > > > type leafref { path > ../../../base-container/base-container-leaf; } > > > } > > > leaf sub-badref3 { > > > type leafref { path > > > ../../../sbase:base-container/base-container-leaf; } > > > } > > > } > > > } > > > grouping sub-group { > > > container sub-group-container { > > > leaf sub-group-leaf { type string; } > > > } > > > } > > > } > > > > > > // imported by base.yang. > > > module other { > > > namespace "uri:empty"; > > > prefix "otherp"; > > > container other-container { > > > leaf other-container-leaf1 { type string; } > > > leaf other-container-leaf2 { type string; } > > > } > > > grouping other-group { > > > leaf other-group-leaf { type string; } > > > container other-group-container { > > > leaf other-group-container-leaf1 { type string; } > > > leaf other-group-container-leaf2 { type string; } > > > } > > > } > > > } > > > _______________________________________________ > > > netmod mailing list > > > netmod@ietf.org > > > https://www.ietf.org/mailman/listinfo/netmod > > > > -- > > Ladislav Lhotka, CZ.NIC Labs > > PGP Key ID: E74E8C0C > > > > -- > Ladislav Lhotka, CZ.NIC Labs > PGP Key ID: E74E8C0C > > > > >
- [netmod] Questions about namings and prefixes in … Paul Borman
- Re: [netmod] Questions about namings and prefixes… Ladislav Lhotka
- Re: [netmod] Questions about namings and prefixes… Paul Borman
- Re: [netmod] Questions about namings and prefixes… Ladislav Lhotka
- Re: [netmod] Questions about namings and prefixes… Paul Borman