Subject: [netmod] defaults and XPath

From: Andy Bierman <[email-masked]>
Date: Sat, 23 Aug 2008 07:02:03 -0700

Hi,

Here is Martin's recent example:

   module a {
      prefix foo;

      leaf y { type int32; }
      must "/foo:x == 42";
   }

   module b {
      prefix foo;

      leaf y { type int32; }
      must "/foo:y == 4668";
   }

This is not valid YANG, so I will change it a bit to make my point;

   module a {
      namespace a;
      prefix foo;

      leaf x {
         type int32;
         must "/foo:x = 42 and /foo:z = 17";
       }
       leaf z {
         type int32 {
            default  17;
         }
       }
   }

   module b {
      namespace b;
      prefix foo;
      import a { prefix a; }

      leaf y {
         type int32;
         must "/foo:y = 4668 and /a:x >= 17";
      }
   }

The manager gets back a <get-config> without any
agent-supplied defaults and it is useless for offline
must-stmt evaluation:

   <rpc-reply ...>
     <data xmlns:a="a" xmlns:b="b">
        <b:y>4668</b:y>
     </data>
   </rpc-reply>

The manager needs to use the TBD 'with-defaults' in
order to receive the same XML that passed the validation
test on the agent:

   <rpc ... with-defaults=true>
     <get-config>
        <source><running/></source>
     </get-config>
   </rpc>

   <rpc-reply ...>
     <data xmlns:a="a" xmlns:b="b">
        <a:x>42</a:x>
        <a:z>17</a:z>
        <b:y>4668</b:y>
     </data>
   </rpc-reply>

IMO, it is OK for YANG to leave defaults out only if
the NETCONF protocol is extended (e.g., with-defaults) to compensate.
If not, then YANG must not hide the agent-supplied nodes.

Andy

_______________________________________________
netmod mailing list
[email-masked]
https://www.ietf.org/mailman/listinfo/netmod

---

From: Martin Bjorklund <[email-masked]>
Date: Sun, 24 Aug 2008 11:02:41 +0200 (CEST)

> order to receive the same XML that passed the validation

Or the client can add the missing defaults itself, before doing
off-line must validation.  I'm not an XSLT expert, but I'm sure it's
fairly straightforward to let a tool like pyang generate an XSLT
script which adds defaults for a given YANG module.

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 25 Aug 2008 10:21:08 +0200

>      <data xmlns:a="a" xmlns:b="b">
The default for 'x' is not defined in the DM, so I guess <a:x>17</a:x>
must be included here?

> order to receive the same XML that passed the validation

Not necessarily. DSDL is designed to handle such cases: default values
defined in a DSRL schema are used for validation if the corresponding
elements are empty or not present in the instance document. So the
manager could do the same and first assume defaults where the
corresponding leaf is missing.

Lada

-- 
Ladislav Lhotka, CESNET
PGP Key ID: E74E8C0C

---

From: Phil Shafer <[email-masked]>
Date: Mon, 25 Aug 2008 10:14:52 -0400

>corresponding leaf is missing.

Cool.  This is exactly the behavior we are aiming for in YANG.

Thanks,
 Phil