[netmod] Questions about namings and prefixes in leafrefs

Paul Borman <borman@google.com> Wed, 21 January 2015 18:07 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 595AC1A1B4E for <netmod@ietfa.amsl.com>; Wed, 21 Jan 2015 10:07:40 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.788
X-Spam-Level:
X-Spam-Status: No, score=-0.788 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, 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 IO4u9g0Bc7Ek for <netmod@ietfa.amsl.com>; Wed, 21 Jan 2015 10:07:38 -0800 (PST)
Received: from mail-vc0-x235.google.com (mail-vc0-x235.google.com [IPv6:2607:f8b0:400c:c03::235]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 3DA711A1B49 for <netmod@ietf.org>; Wed, 21 Jan 2015 10:07:38 -0800 (PST)
Received: by mail-vc0-f181.google.com with SMTP id id10so2991245vcb.12 for <netmod@ietf.org>; Wed, 21 Jan 2015 10:07:37 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=uwl7yuTKLqe7PtnW8rPoVSpO7COZuyM9Mdt824DARZ8=; b=Vq29kCnuvj/69Ulv4IYZzinjev2iDDVFw7yvrP8nYZEWtAqEH3PPaTniZQKlOJ40Sk 1uRhes0swpv/fFxCRYR0t2fvyU0bDTnX+2bLz+lyidJaQdyc96MLKmx3Fq4Lfza9jnhy oylbzZFPFgb3wmplIR2aUQ/sYkQaNeKx4PtBiJX7s2J4dKOHpYw5FWbNz29AR1oykdti KoFYoWyFbS3KB1ESjOYW/tkIXUwgos3nfBVd6YeWOqSmG11JZv9tM40KD7oNROgJgPFD hihjkQ5cCM3K98e9v46yU+1X00gj6lLqfXAjUUn2/LcpNUHdesh/n0fmXCawO7IzJHLa vNOw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=uwl7yuTKLqe7PtnW8rPoVSpO7COZuyM9Mdt824DARZ8=; b=MmDa7TNB76Iwb/6TuKNUSgP5OOOPA/aMdbEMpOlDmWwCAADe+Oh6HMoYCJqJnix9/5 2o4wm/JxSeLlQS3z2HQQr/FcJSwtUFAcCXMw7URU2rvsOgYjPhGvEQfG9VG2/HQj5om9 DJECUvmjWtxv+QebBN92gKyNUyoxXi4HX87gP4teMTg8efqdlhWQfw9Pm57oHh6Q5Tot BiCV/rR82cE3ee7n6fhjjYe6YHDtIV06n73rMKh3gZE35zg7xuD3kZF+DBEoHAv0BgZX uYUsGYSFlq/B4gpS57q7FHVHP5DtKNPxycpMRmjRiqpozwYRgUZpc7RiXEvYqPrX7Qbz W/mA==
X-Gm-Message-State: ALoCoQlfRJmO1siL/MhhWTi11JWHRpRj3tKZzJOnau396PW3/aoWZDicujzDyc9tJBXnHbM42CYC
MIME-Version: 1.0
X-Received: by 10.52.242.75 with SMTP id wo11mr10137012vdc.82.1421863657050; Wed, 21 Jan 2015 10:07:37 -0800 (PST)
Received: by 10.52.166.99 with HTTP; Wed, 21 Jan 2015 10:07:36 -0800 (PST)
Date: Thu, 22 Jan 2015 05:07:36 +1100
Message-ID: <CAHsVM3=n5fRUmN4MBs01b3kvNXD2WMt4E6FbcpowRYsHM8pE_w@mail.gmail.com>
From: Paul Borman <borman@google.com>
To: netmod@ietf.org
Content-Type: multipart/mixed; boundary="001a1134d7ba349ab5050d2d6e06"
Archived-At: <http://mailarchive.ietf.org/arch/msg/netmod/K62oDIZZNlsW19DfpZprULQYkOw>
Subject: [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: Wed, 21 Jan 2015 18:07:40 -0000

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
   - may descend into used groupings, no matter where the grouping is
   defined
   - may *not* ascend into the parent module
   - may optionally use the module's prefix for any element in a leafref
   path, no matter where the element is defined
   - may optionally use the belongs-to-prefix in elements in paths inside a
   submodule
   - may *never* use the prefix for/from an imported module

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?

Attached are the modules and submodules I used that lead to these
assumptions and questions.  pyang -f tree produces the following errors:

base.yang:50: error: other:other-group-container-leaf1 in the path for
base-container-badref1 at base.yang:49 is not found
base.yang:53: error: prefix "pother" is not defined (reported only once)
sub.yang:15: error: base:base-container in the path for sub-badref2 at
sub.yang:14 is not found
sub.yang:18: error: base:base-container in the path for sub-badref3 at
sub.yang:17 is not found

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.

Thanks for any guidance,

    -Paul

// Base test yang module.
module base {
  namespace "urn:mod";
  prefix "base";

  include sub;
  import other {
    prefix bother;
  }

  grouping base-group {
    leaf base-group-leaf { type string; }
  }

  // test uses and leaf ref
  container base-container {
    uses base-group;
    uses bother:other-group;
    uses base:sub-group;
    leaf base-container-leaf { type string; }
    leaf base-container-ref1 {
      type leafref { path ../base-container-leaf; }
    }
    leaf base-container-ref2 {
      type leafref { path ../base-group-leaf; }
    }
    leaf base-container-ref3 {
      type leafref { path ../other-group-leaf; }
    }
    leaf base-container-ref4 {
      type leafref { path ../sub-group-container/sub-group-leaf; }
    }
    leaf base-container-ref5 {
      type leafref { path ../../base:sub-container/sub-container-leaf; }
    }
    leaf base-container-ref6 {
      type leafref { path ../../base:sub-container/base:sub-container-leaf;
}
    }
    leaf base-container-ref7 {
      type leafref { path ../../sub-container/base:sub-container-leaf; }
    }
    leaf base-container-ref8 {
      type leafref { path
../other-group-container/other-group-container-leaf1; }
    }
    leaf base-container-ref9 {
      type leafref { path
../other-group-container/base:other-group-container-leaf1; }
    }
    // These next two ar invalid
    leaf base-container-badref1 {
      type leafref { path
../other-group-container/bother:other-group-container-leaf1; }
    }
    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; }
    }
  }
}