Re: [netmod] Questions about namings and prefixes in leafrefs

Paul Borman <borman@google.com> Thu, 22 January 2015 17:43 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 D319C1ACE17 for <netmod@ietfa.amsl.com>; Thu, 22 Jan 2015 09:43:57 -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 j59QRGVEl8sH for <netmod@ietfa.amsl.com>; Thu, 22 Jan 2015 09:43:55 -0800 (PST)
Received: from mail-vc0-x234.google.com (mail-vc0-x234.google.com [IPv6:2607:f8b0:400c:c03::234]) (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 013441ACE13 for <netmod@ietf.org>; Thu, 22 Jan 2015 09:43:54 -0800 (PST)
Received: by mail-vc0-f180.google.com with SMTP id hy10so759937vcb.11 for <netmod@ietf.org>; Thu, 22 Jan 2015 09:43:54 -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=WP2Ij16+9ScEGAlfCnKFhRRyi06YIEe7AizMmWibzls=; b=lYJqZn1CrfBvQXJviGudv1yqsjJaw3Izm7RrTnFI86KJK9BmOsv2DoR3rpjnMbA9yx dJGx2YzFwG1+3sMC2PCFF3MYXhGnkgJK8ggpJ78cPXapIFOM0Yx+j6t85fx9gd4OaLQU pfjfTVi6ALpnhiQDL9cD2WKQvfbKpyb/R1c40HD87yX8tF2+uBi/qv5+WyKXhRCC05Xz d+uJVVKoK7q7/J24QYemq+l1+4SRfJhQMalTHdOjIKX7fz62nQ+caLalAU1bpnhNIgfY bXiuoJwLzKC3agNHqTII4YgRHS+FvL96kzZ8JwwzOdPxm9y7dEKs8pWKYVBF1iNXhRwW ovLQ==
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=WP2Ij16+9ScEGAlfCnKFhRRyi06YIEe7AizMmWibzls=; b=aTfpR7llVhKCu/x19jB3X1GU/ZC0jf0IwVy5j7ASWcCCvJSxVtpP+y1/K0HaBL78tb td7GF/O1lYeu/Gk7Ntz1/MlFCcpLTYouRew61VjhsFPllQ60c6IkbIjcfxK1xHncSN03 o+YlkorE9KdKPJArT5HChELADsSt6Jn6HIZvzyXJA90exFjxu89mNYJgjcABFUyNIDtR 6LWHWrOOH2mqq2aEaDunY290aiRadaucVXTe0Dse7Gg1Fflp2f5uPUpLN+jCVCBIaMUx /MC3H5OeVa6Tp/lYAC2pSYwSRSBzw4RGqWBUQf0lfPUx8icOCstNaK8SLpl9QQ6h1q6V xyvg==
X-Gm-Message-State: ALoCoQkuERvqeznc0mtJrjTQTAZR5pGyNHlqSb3XRwJgGSkQ2+OL2BmhxssIW3TTwOtapF+nPp62
MIME-Version: 1.0
X-Received: by 10.52.29.172 with SMTP id l12mr1053948vdh.33.1421948633978; Thu, 22 Jan 2015 09:43:53 -0800 (PST)
Received: by 10.52.246.194 with HTTP; Thu, 22 Jan 2015 09:43:53 -0800 (PST)
In-Reply-To: <m2ppa7m0au.fsf@nic.cz>
References: <CAHsVM3=n5fRUmN4MBs01b3kvNXD2WMt4E6FbcpowRYsHM8pE_w@mail.gmail.com> <m2ppa7m0au.fsf@nic.cz>
Date: Thu, 22 Jan 2015 09:43:53 -0800
Message-ID: <CAHsVM3momUxi_iqh5hEk931vFcLKd9S3=p=-+LtHRGJJwmAe7Q@mail.gmail.com>
From: Paul Borman <borman@google.com>
To: Ladislav Lhotka <lhotka@nic.cz>
Content-Type: multipart/alternative; boundary="20cf30780cb237b851050d413773"
Archived-At: <http://mailarchive.ietf.org/arch/msg/netmod/eBnyCR8shPfM3w0CXTyZnRNkBuI>
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 17:43:58 -0000

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.

>    - 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 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 tree other than its
own?  I will note that my example referred to a node within a grouping
defined in 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).

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
>