On 08/23/2016 11:09 AM, Martin Bjorklund wrote:
Vladimir Vassilev <vladi...@transpacket.com> wrote:
On 08/23/2016 10:15 AM, Martin Bjorklund wrote:
They are evaluated. See Section 7.5.3:
When a datastore is validated, all "must" constraints are
conceptually evaluated once for each node in the accessible tree (see
Section 6.4.1).
/martin
Then we have the case I objected to and the example:
YANG 1.0:
augment "/if:interfaces/if:interface" {
container inet {
must "../name = 'me0'" {
This should have been a 'when' expression, not 'must'. Alternatively,
it should have been a P-container, since obviously the container has
some semantics. Or alternatively, the must expression should have
been on the address leaf, since this is what you really checked.
I claim that any example of a must statement in non-presence container
is affected in a similar way (Has anyone example that proves the
contrary?). 'when' statements are alternative when the 'must' statement
depends on data nodes that are not child nodes (which I admit is the
case in this example). The thing with 'must' expressions in non-presence
container is they are used in complicated models where 'mandatory' and
'choice' solutions are not an option and for whatever reason the design
got to that point the fact is that by introducing the auto-evaluation of
non-presence containers it is even more complicated to use them. Here an
example that stops working in YANG 1.1:
augment "/if:interfaces/if:interface" {
container 2-company-3-crowd {
must "(a and b and not(c)) or (not(a) and b and c) or (a and
not(b) and c)" {
}
leaf a {
type string;
}
leaf b {
type string;
}
leaf c {
type string;
}
}
}
... to make it work one has to accept to not deny the creation of
/interfaces/interface/2-company-3-crowd as empty container and modify
the expression adding ...or (not(a) and not(b) and not(c)).
That said I admit it is not often one needs non-presence container must
statements. But in the cases one needs them the YANG 1.1 text is not
helping. It causes all the statements to be processed when no one
attempts to create them or child nodes residing in them. I find no
justification for that.
/martin
description
"The inet container is only valid for the management ('me0')
interface.";
}
leaf address {
type inet:ip-prefix;
}
}
}
YANG 1.1 (replace "../name = 'me0'" with "../name='me0' or not
(./address)" and process 95 unnecessary Xpath evaluations).
I think this proves the argument that there will be more unnecessary
Xpath processing. In addition it illustrates how a simple task
requires ugly patch (the ".. or not (./address)" added to the must
expression) just to ensure the expression does not fail in the default
case where the interface is not named "me0" and the user has not even
attempted to create empty /interfaces/interface/inet container in YANG
1.1.
Vladimir
_______________________________________________
netmod mailing list
netmod@ietf.org
https://www.ietf.org/mailman/listinfo/netmod