Subject: [netmod] "when" statement deviation

From: Alex Campbell <[email-masked]>
Date: Mon, 9 Jan 2017 21:56:24 +0000

Hi,

I have a module that adds some configuration to interfaces (the specific feature being configured isn't important here, so I'll just call it "feature").

I want to implement this module, but the device I'm working on only supports the feature on some kinds of interfaces.

So I want to add a "when" constraint in a deviation module that says the feature configuration is only available for these kinds of interfaces.

However, I found that "when" statements are not allowed to be affected by deviations (according to the RFC and according to confdc).

Is there a reason for this? It seems like an oversight.

Example:

    module feature-module {

        // ... prefix, imports, etc ...

        import ietf-interfaces {prefix if;}

        augment /if:interfaces/if:interface {

            container feature {

                leaf enabled {

                    type boolean;

                    description "Enables the feature";

                }

            }

        }

    }

    module feature-module-deviations {

        // ... prefix, imports, etc ...

        import feature-module {prefix fm;}

        import iana-if-types {prefix ianaift;}

        deviation /if:interfaces/if:interface/fm:feature {

            deviate add {

                // parsing fails here; "when" is not allowed as a child of "deviate"

                when "../if:type = 'ianaift:ethernetCsmacd' or ../if:type = 'ianaift:ieee8023adLag'";

            }

        }

    }

Alex

---

From: Andy Bierman <[email-masked]>
Date: Mon, 9 Jan 2017 14:20:54 -0800

Hi,

This is not allowed because it is too complicated to implement.
Changing the schema tree based on values of instances within the schema tree
is full of complications.

Note that when-stmt used where allowed enables or disables the schema tree
without changing it. This is hard enough to support.

Andy

On Mon, Jan 9, 2017 at 1:56 PM, Alex Campbell <[email-masked]>
wrote:

> Hi,
>
>
> I have a module that adds some configuration to interfaces (the specific
> feature being configured isn't important here, so I'll just call it
> "feature").
>
> I want to implement this module, but the device I'm working on only
> supports the feature on some kinds of interfaces.
>
> So I want to add a "when" constraint in a deviation module that says the
> feature configuration is only available for these kinds of interfaces.
>
>
> However, I found that "when" statements are not allowed to be affected by
> deviations (according to the RFC and according to confdc).
>
> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod
>
>

---

From: Alex Campbell <[email-masked]>
Date: Mon, 9 Jan 2017 22:26:57 +0000

I don't see how a "when" statement modified by a deviation is any more complicated to implement than a "when" statement outside of a deviation - presuming that augments and deviations are processed before "when" statements.

Alex

________________________________
From: Andy Bierman <[email-masked]>
Sent: Tuesday, 10 January 2017 11:20 a.m.
To: Alex Campbell
Cc: [email-masked]
Subject: Re: [netmod] "when" statement deviation

Hi,

Andy

On Mon, Jan 9, 2017 at 1:56 PM, Alex Campbell <[email-masked]<mailto:[email-masked]>> wrote:

Hi,

Example:

    module feature-module {

            container feature {

                leaf enabled {

                    type boolean;

                }

            }

        }

    }

            deviate add {

            }

        }

    }

Alex

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

---

From: Andy Bierman <[email-masked]>
Date: Mon, 9 Jan 2017 14:32:37 -0800

On Mon, Jan 9, 2017 at 2:26 PM, Alex Campbell <[email-masked]>
wrote:

> I don't see how a "when" statement modified by a deviation is any more
> complicated to implement than a "when" statement outside of a deviation -
> presuming that augments and deviations are processed before "when"
> statements.
>
>
>
augments and deviations are processed once when the module is loaded.
A when-stmt is processed anytime the value of the XPath boolean result
changes.

Alex
Andy

> ------------------------------
> *From:* Andy Bierman <[email-masked]>
> *Sent:* Tuesday, 10 January 2017 11:20 a.m.
> *To:* Alex Campbell
> *Cc:* [email-masked]
> *Subject:* Re: [netmod] "when" statement deviation
>
> Hi,
>

---

From: Robert Varga <[email-masked]>
Date: Tue, 10 Jan 2017 02:30:49 +0100

On 01/09/2017 11:32 PM, Andy Bierman wrote:
> 
> 
> On Mon, Jan 9, 2017 at 2:26 PM, Alex Campbell
> <[email-masked] <mailto:[email-masked]>> wrote:
> 
>     I don't see how a "when" statement modified by a deviation is any
>     more complicated to implement than a "when" statement outside of a
>     deviation - presuming that augments and deviations are processed
>     before "when" statements.
> 
> 
> 

Right, but that also means that processing a 'deviate add { when ... }'
would occur only once, after which the cost would be the same as if that
when statement was present in the original definition.

In any case, the same effect can be achieved by deviate-adding an
appropriate must statement -- which seems appropriate, as presumably you
want to restrict the leaf from becoming 'true' rather than enforce it
not being available at all.

Regards,
Robert

---

From: Ladislav Lhotka <[email-masked]>
Date: Tue, 10 Jan 2017 09:28:09 +0100

> On 10 Jan 2017, at 02:30, Robert Varga <[email-masked]> wrote:
> 

I agree.

> not being available at all.

Yes, except that a "when" constraint is stronger - it has to be satisfied in all trees whereas "must" only in a valid tree (sec. 8.1 of RFC 7950).

Lada

--
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67