Re: Why NETCONF needs a data modeling language

Martin Bjorklund <mbj@tail-f.com> Fri, 30 November 2007 17:10 UTC

Return-path: <discuss-bounces@apps.ietf.org>
Received: from [127.0.0.1] (helo=stiedprmman1.va.neustar.com) by megatron.ietf.org with esmtp (Exim 4.43) id 1Iy9Ng-0001D2-Cm; Fri, 30 Nov 2007 12:10:24 -0500
Received: from discuss by megatron.ietf.org with local (Exim 4.43) id 1Iy9Nf-0001CT-B5 for discuss-confirm+ok@megatron.ietf.org; Fri, 30 Nov 2007 12:10:23 -0500
Received: from [10.91.34.44] (helo=ietf-mx.ietf.org) by megatron.ietf.org with esmtp (Exim 4.43) id 1Iy9Ne-0001Bn-Uj for discuss@apps.ietf.org; Fri, 30 Nov 2007 12:10:22 -0500
Received: from [213.180.94.162] (helo=mail.tail-f.com) by ietf-mx.ietf.org with esmtp (Exim 4.43) id 1Iy9Nd-00057c-8h for discuss@apps.ietf.org; Fri, 30 Nov 2007 12:10:22 -0500
Received: from localhost (pool-71-120-236-45.spknwa.dsl-w.verizon.net [71.120.236.45]) by mail.tail-f.com (Postfix) with ESMTP id 311F31B80C8; Fri, 30 Nov 2007 18:10:17 +0100 (CET)
Date: Fri, 30 Nov 2007 18:10:15 +0100
Message-Id: <20071130.181015.170292466.mbj@tail-f.com>
To: rohan.mahy@gmail.com
Subject: Re: Why NETCONF needs a data modeling language
From: Martin Bjorklund <mbj@tail-f.com>
In-Reply-To: <953beacc0711282017p3ad865abw19920b4e68e82e80@mail.gmail.com>
References: <474E0F71.2050003@andybierman.com> <953beacc0711282017p3ad865abw19920b4e68e82e80@mail.gmail.com>
X-Mailer: Mew version 5.1.51 on Emacs 22.1 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Scan-Signature: 0770535483960d190d4a0d020e7060bd
Cc: yang@ietf.org, discuss@apps.ietf.org, ngo@ietf.org
X-BeenThere: discuss@apps.ietf.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: general discussion of application-layer protocols <discuss.apps.ietf.org>
List-Unsubscribe: <https://www1.ietf.org/mailman/listinfo/discuss>, <mailto:discuss-request@apps.ietf.org?subject=unsubscribe>
List-Post: <mailto:discuss@apps.ietf.org>
List-Help: <mailto:discuss-request@apps.ietf.org?subject=help>
List-Subscribe: <https://www1.ietf.org/mailman/listinfo/discuss>, <mailto:discuss-request@apps.ietf.org?subject=subscribe>
Errors-To: discuss-bounces@apps.ietf.org

Hi Rohan,

"Rohan Mahy" <rohan.mahy@gmail.com> wrote:
> Look at the following Relax NG in compact form, side-by-side with YANG.
> 
> container aaa {
>    container bbb {
>       leaf foo { type string; }
>       leaf bar { type uint32; }
>    }
> }
> 
> element aaa {
>    element bbb {
>       element foo { xsd:string },
>       element bar { xsd:unsignedInt }
>    }
> }
> 
> This hardly seems like a big difference to me.

I take the liberty to slightly modify this example into:

    container aaa {
      container bbb {
        leaf ifAdminStatus {
          type string;
          description
            "The desired state of the interface.";
          mandatory true;
        }
        leaf ifOperStatus {
          type string;
          description
            "The current operational state of the interface.";
          config false;
        }
      }      
    }
    
It's still a bit simplified, e.g. the type is just a string; it should
really be an enumeration.

The plain RNC is then:

    element aaa {
      element bbb {
        element ifAdminStatus { type xsd:string }?,
        element ifOperStatus  { type xsd:string }?
      }
    }

First of all, these two examples may look similar, but they have
different meaning.  The YANG example defines objects in the
(configuration) data tree.  The RelaxNG example defines a pattern
which is used to validate some XML instance document.

Anyway, if we want to make this RNC as extensible as the corresponding
YANG version, we follow the recommendations in chapter 12 of the book:

    element aaa = aaa-content
    
    aaa-content =
      element bbb {
        bbb-content
      }
    
    bbb-content =
      element ifAdminStatus {
        ifAdminStatus-content
      }?,
      element ifOperStatus {
        ifOperStatus-content
      }?
    
    ifAdminStatus-content =
      type xsd:string
    
    ifOperStatus-content =
      type xsd:string

Next, we add the YANG specific annotations:

    element aaa = aaa-content
    
    aaa-content =
      element bbb {
        bbb-content
      }
    
    bbb-content =
      [
        yang:mandatory [ "true" ]
        yang:description [ "The desired state of the interface." ]
      ]
      element ifAdminStatus {
        ifAdminStatus-content
      }?,
      [
        yang:description [ 
          "The current operational state of the interface."
        ]
      ]
      element ifOperStatus {
        ifOperStatus-content
      }? >> yang:config [ "false" ] # I don't know if initial or
                                    # following annotations are
                                    # better (or even equal). 
    
    ifAdminStatus-content =
      type xsd:string
    
    ifOperStatus-content =
      type xsd:string
    

This is starting to become a bit difficult to grasp at first sight.
Maybe we should follow the recommendation in the book and work with
the XML notation instead.

On a higher level, what exactly is the interpretation of adding
e.g. the yang:mandatory true annotation to ifAdminStatus?  The annotation
is added to the pattern which matches the xml element <ifAdminStatus>.
But that is just the encoding of the underlying object.  What happens
with this annotation if ifAdminStatus is not present in an instance
document?  Should we modify the meaning of the RelaxNG patterns and
say that they also somehow define objects in the configuration data
tree?

This schema will validate <get> replies only, since it contains both
config and non-config data.  According to your email, we'll have to
add these to the definitions of get, get-config, edit-config, and
copy-config:

   get-reply-content &=
     aaa

   get-config-reply-content &=
     # hmm... how do I do this w/o copy&paste?  I just want
     # to add aaa/bbb/ifAdminstatus.

   edit-config-content &=
     # hmm... how do I do this w/o copy&paste?  I just want
     # to add aaa/bbb/ifAdminstatus, but also add some nc:opertaion
     # attributes.


All of this (and the other things we've discussed (and the things we
haven't yet discussed :) ) can probably be solved by writing rules to
restrict the usage of RelaxNG, add the necessary annotations (around
20), and write down extra interpretion of the RelaxNG constructs we're
using, but my conclusion is the same as Juergen's list a-d in his
latest email.  To this list I'd like to add the readibility issue.  


/martin