Subject: [netmod] Conditional content [was: refinements and augments]

From: Martin Bjorklund <[email-masked]>
Date: Mon, 12 May 2008 16:37:44 +0200 (CEST)

Hi,

Ladislav Lhotka <[email-masked]> wrote:
> What is IMO more important is that augment is now in fact used for three
> different functions:
> 
> 1. Conditional content:
> 
>    augment . {
>      when condition;
>      ....
>    }
> 
> This could be replaced by a simpler and clearer statement
> 
>     when condition {
>       ....
>     }
> 
> with exactly the same semantics. It could be allowed in the same places
> as augment is now.

So instead of:

  augment /foo/bar {
     when "<condition>";
     ...
  }

I would write:

  when "<condition>" {
    augment /foo/bar {
      ...
    }
  }

I suppose I also can write:

  when "<condition>" {
    leaf foo {
      ...
    }
  }

and also:

  when "<condition>" {
    leaf bar {
      mandatory "true";
      ...
    }
    container baz {
      presence "...";
      ...
    }
  }

Which means that if "<condition>" is true, then "bar" MUST exist in a
valid configuration and "foo" MAY exist.  If "<condition>" is false,
both "foo" and "bar" MUST NOT exist in a valid configuration.

Can I do:

  when "a > b" {
    must "b < 42";
  }

On the plus side it has a similar synatx as the proposed
when-capability:

  when-capability foo {
     leaf bar {
        mandatory true;
        ...
     }
  }

This says that if the capability "foo" is advertised, then the leaf
bar MUST exist in a valid configuration.

I have to think some more about the similarities / differences with
'must'...

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

---

From: Phil Shafer <[email-masked]>
Date: Mon, 12 May 2008 11:11:09 -0400

>     when "<condition>";

Having the "when" inside the node has two advantages.  First we
can define other conditional mechanisms, like "when-capability".
Second, the contents of the "when" statement are fixed, not
dependent on the location of the statement in the module.  If
the when is the parent, the contents may vary.

Thanks,
 Phil

---

From: Martin Bjorklund <[email-masked]>
Date: Mon, 12 May 2008 17:34:51 +0200 (CEST)

Hi,

> On the plus side it has a similar synatx as the proposed

Sorry, my mistake.  The proposed 'when-capability' has the same syntax
as the current 'when'.

/martin