Subject: [Netconf] about subtree filtering

From: WashamFan <[email-masked]>
Date: Fri, 26 Jun 2009 11:44:15 +0800

Hi,

>From sec6.4.6, rfc4741, there is a request using subtree:

   <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <get-config>
         <source>
           <running/>
         </source>
         <filter type="subtree">
           <top xmlns="http://example.com/schema/1.2/config">
             <users>
               <user>
                 <name>fred</name>
                 <type/>
                 <full-name/>
               </user>
             </users>
           </top>
         </filter>
       </get-config>
     </rpc>

But what if users contains another element, let's say <role>
and I also want it returned, so is it legal, and is it returned as
the intent?

   <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <get-config>
         <source>
           <running/>
         </source>
         <filter type="subtree">
           <top xmlns="http://example.com/schema/1.2/config">
             <users>
               <user>
                 <name>fred</name>
                 <type/>
                 <full-name/>
               </user>
               <role/>                            <!-- user's sibling-->
             </users>
           </top>
         </filter>
       </get-config>
     </rpc>

Thanks,
washam

---

From: Andy Bierman <[email-masked]>
Date: Thu, 25 Jun 2009 21:43:17 -0700

>                <role/>                            <!-- user's sibling-->

This is fine.
This is just another selection node, like if <user/> was empty.
If there is no <role> in the entry, the whole thing will be
left out, because the select nodes form an AND expression.

> washam

Andy

---

From: Martin Bjorklund <[email-masked]>
Date: Fri, 26 Jun 2009 08:53:16 +0200 (CEST)

> This is fine.

Yes.

> left out, because the select nodes form an AND expression.

No, selection nodes do not form AND expressions - content match nodes
do.  So even if no users/role exists, the fred user will be returned
(if it exists).

/martin

---

From: WashamFan <[email-masked]>
Date: Fri, 26 Jun 2009 15:59:03 +0800

>  do.  So even if no users/role exists, the fred user will be returned

Actually, that is what I want. I want all possible info about fred.
If fred has the role, please return the role info, elsewise, just return me
the basic info.

Thanks,
washam

---

From: Martin Bjorklund <[email-masked]>
Date: Fri, 26 Jun 2009 10:34:26 +0200 (CEST)

> Actually, that is what I want. I want all possible info about fred.

Ok.

> If fred has the role, please return the role info, elsewise, just return me

This is probably just fine, but note that in your example you did:

             <users>
               <user>
                 <name>fred</name>
                 <type/>
                 <full-name/>
               </user>

Which would correspond to this:

  container users {
      list user { ... }
      leaf role { ... }
  }

so the role - in your example - isn't a property of the user, but a
global property for all users.

The reasoning applies even if we do:

  container users {
      list user {
          ...
          leaf role { ... }
      }
  }

/martin

---

From: WashamFan <[email-masked]>
Date: Fri, 26 Jun 2009 17:25:43 +0800

Hi,

----- Original Message -----
From: Martin Bjorklund <[email-masked]>
Date: Friday, June 26, 2009 4:35 pm
Subject: Re: [Netconf] about subtree filtering
To: [email-masked]
Cc: [email-masked], [email-masked]

>  The reasoning applies even if we do:
Well, the data model might like this:

   container users {
     list user {
       container basic {
          leaf name { ...}
          leaf type {...}
          leaf full-name { ... }
       }
       leaf role { ... }
     }
   }

So, the filter

   <users>
      <user>
        <basic>
           <name>fred</name>
           <type/>
           <full-name/>
        </basic>
        <role/>
      </user>
    </users>

will help return what I want?

Thanks,
washam

---

From: Martin Bjorklund <[email-masked]>
Date: Fri, 26 Jun 2009 13:18:58 +0200 (CEST)

> will help return what I want?

Assuming this is config, the data model is not quite correct - the
list lacks a key.  So if we do:

    container users {
      list user {
        key name;
        leaf name { ...}
        container basic {
           leaf type {...}
           leaf full-name { ... }
        }
        leaf role { ... }
      }
    }

Then the filter:

    <users>
       <user>
         <name>fred</name>
         <basic>
            <type/>
            <full-name/>
         </basic>
         <role/>
       </user>
     </users>

will return the type, full-name, and role of "fred", if they exist,
which is what you want.

However, the filter:

    <users>
       <user>
         <basic>
            <type/>
            <full-name>Fred Flintstone</full-name>
         </basic>
         <role/>
       </user>
     </users>

will return the role of *all* users, and the type of Fred.

/martin

---

From: WashamFan <[email-masked]>
Date: Fri, 26 Jun 2009 21:46:05 +0800

Hi,

----- Original Message -----
From: Martin Bjorklund <[email-masked]>
Date: Friday, June 26, 2009 7:19 pm
Subject: Re: [Netconf] about subtree filtering
To: [email-masked]
Cc: [email-masked], [email-masked]

> will return the role of *all* users, and the type of Fred.

So, <role> is only constrained by the key, but not the 
siblings. What if <role> is under a container:

   container owner {
     container basic {
       leaf name { ... }
       leaf type { ... }
       leaf full-name { ... }
     }
     leaf role { ... }
   }

When the belowing filter is applied:

   <owner>
     <basic>
       <name>fred</name>
       <type/>
       <full-name/>
     </basic>
     <role/>
   </owner>

If the current owner is fred, the name, type, full-name as well as
role (if exists) of fred would be returned, right?
If the current owner is fan, the name, type, full-name of
fan would not be returned, but would the role of fan be returned?

washam