Subject: Re: [netmod] deviation-stmt (7.20.3)

From: Andy Bierman <[email-masked]>
Date: Tue, 4 Oct 2016 09:55:37 -0700

On Fri, Sep 30, 2016 at 9:01 AM, Balazs Lengyel <[email-masked]
> wrote:

> My biggest problem with deviations is that a number of things can not be
> deviated:
>
>    - description
>    - reference
>
>

This does seem quite useful.
I wonder why it got left out.

The way deviations work is rather counter-intuitive to those of us who think
of deviations as source code patches.  Almost all deviations are source
code patches,
except type-stmt, and some default-stmt replacements.

It would be nice if a YANG tool could process all the deviations advertised
by the server
and produce a set of valid "deviated modules" which could then be fed to a
YANG compiler
that did not support deviations.  This is non-trivial and not always
possible, because of the type-stmt
and possible import loops.

> Regards Balazs
Andy

> On 2016-09-30 00:22, Andy Bierman wrote:
>
> Hi,
>
> The deviation section has a lot of fluff text about how bad deviations are,
> but very little text on how to process the "deviate" statement correctly.
>
> The text is not clear if the statements altered in the target module
> are semantic patches or syntactic patches.  Are the sub-statements
> of the deviate-stmt fully processed in the scope of the deviation module
> or in the scope of the target module? In this example, is the type-stmt
> resolved in A or dev-A?
>
> Similar issues for deviating a default for an identityref.
>
>
>   module A {
>     namespace "...";
>     prefix a;
>     // no imports!
>
>     leaf foo {
>        type string;
>      }
>
>     leaf bar {
>        type string;
>      }
>
>     leaf baz {
>        type string;
>      }
>   }
>
>   module A-dev {
>     ...
>     import A { prefix a; }
>     import C { prefix c; }
>     import ietf-interfaces { prefix if; }
>
>     // variant 1: inline leafref but module A does not import path module
>     deviation /a:foo {
>        deviate replace {
>           type leafref {
>                base /c:modules/c:module/c:name;
>            }
>         }
>      }
>
>
>    // variant 2: imported typedef but module A does not import it
>     deviation /a:bar {
>        deviate replace {
>           type if:interface-ref;
>         }
>      }
>
>
>     // variant 3: local typedef but module A cannot import it (circular
> imports)
>     typedef mystring {
>         type string { length "1..10"; }
>     }
>
>     deviation /a:baz {
>        deviate replace {
>           type mystring;
>         }
>      }
>   }
>
>
> Andy
>
>
>
> _______________________________________________
> netmod mailing [email-masked]://www.ietf.org/mailman/listinfo/netmod
>
>
> --
> Balazs Lengyel                       Ericsson Hungary Ltd.
> Senior Specialist
> Mobile: +36-70-330-7909              email: [email-masked]
>
>

---

From: Balázs Lengyel <[email-masked]>
Date: Wed, 5 Oct 2016 10:54:30 +0000

PYANG does much of what you request if you ask for a tree, jstree output. It probably could create a yang output with some work.
Balazs

From: Andy Bierman [mailto:[email-masked]]
Sent: Tuesday, 04 October, 2016 18:56
To: Balázs Lengyel <[email-masked]>
Cc: [email-masked]
Subject: Re: [netmod] deviation-stmt (7.20.3)

On Fri, Sep 30, 2016 at 9:01 AM, Balazs Lengyel <[email-masked]<mailto:[email-masked]>> wrote:

My biggest problem with deviations is that a number of things can not be deviated:

  *   description
  *   reference

The way deviations work is rather counter-intuitive to those of us who think
of deviations as source code patches.  Almost all deviations are source code patches,
except type-stmt, and some default-stmt replacements.

It would be nice if a YANG tool could process all the deviations advertised by the server
and produce a set of valid "deviated modules" which could then be fed to a YANG compiler
that did not support deviations.  This is non-trivial and not always possible, because of the type-stmt
and possible import loops.

Regards Balazs

Andy

  module A {
    namespace "...";
    prefix a;
    // no imports!

    leaf foo {
       type string;
     }

    leaf bar {
       type string;
     }

    leaf baz {
       type string;
     }
  }

  module A-dev {
    ...
    import A { prefix a; }
    import C { prefix c; }

    // variant 3: local typedef but module A cannot import it (circular imports)
    typedef mystring {
        type string { length "1..10"; }
    }

    deviation /a:baz {
       deviate replace {
          type mystring;
        }
     }
  }

Andy

netmod mailing list

[email-masked]<mailto:[email-masked]>

https://www.ietf.org/mailman/listinfo/netmod

--

Senior Specialist

Mobile: +36-70-330-7909              email: [email-masked]<mailto:[email-masked]>

---

From: Andy Bierman <[email-masked]>
Date: Wed, 5 Oct 2016 07:23:14 -0700

On Wed, Oct 5, 2016 at 3:54 AM, Balázs Lengyel <[email-masked]>
wrote:

> PYANG does much of what you request if you ask for a tree, jstree output.
> It probably could create a yang output with some work.
>
> Balazs
>
>

You misunderstood my comment.
We have tools that can regenerate the YANG as well. That is not that hard.
But the type-stmt MUST be evaluated in the original document.
The patched module has a different set of prefix-to-import bindings,
so compiling the patched module may not work.

Andy

> *From:* Andy Bierman [mailto:[email-masked]]
> *Sent:* Tuesday, 04 October, 2016 18:56
> *To:* Balázs Lengyel <[email-masked]>
> *Cc:* [email-masked]
> *Subject:* Re: [netmod] deviation-stmt (7.20.3)
>
>
>
>
>
>
>
> On Fri, Sep 30, 2016 at 9:01 AM, Balazs Lengyel <
> [email-masked]> wrote:
>
> [email-masked]