Hi Kent,
1) Are you assuming a default mode? (RFC 6243)
--No, this is not the default mode as per RFC 6243, it is just a leaf in the
module which has a default value.
2) Does "that has a default” mean in the YANG module or configuration?
--In the yang module
3) What is an “instance”? (I think you mean “configuration”)
--Instance in the presentation means the functional entity to which the defined
template is applied.
A example which could provide more explanation is below
--------Template schema -------------
In this snippet we define the schema of a template for interfaces/interface,
which includes the leaf "enabled" which has a default value as true and a leaf
"type" which has a mandatory value.
container templates{
list templates{
key "template-name";
leaf template-name {
type string;
description "The name of the template.";
}
container interfaces {
list interface {
key "name";
description "List of network interfaces.";
leaf name {
type string;
description "The name of the interface.";
mandatory true;
}
leaf type {
type identityref {
base "interface-type";
}
description "The type of the interface.";
mandatory true; // The interface type is mandatory
}
leaf enabled {
type boolean;
default "true"; // The default state is enabled
description
"The enabled state of the interface. True means the interface
is enabled, false means it is disabled.";
}
--------Template configuration -------------
<rpc message-id="102" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<edit-config>
<target>
<running/>
</target>
<config>
<templates>
<template>
<template-name>sample-template</template-name>
<interfaces
xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
<interface>
<name>GigabitEthernet0/0/0</name>
<type
xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type>
<!-- Mandatory leaf -->
<enabled>false</enabled><!—default leaf, but assuming this value is set to the
non-default value(false).-->
</interface>
</interfaces>
</template>
</templates>
</config>
</edit-config>
</rpc>
When this template is applied to the interface model, will the leaf "enabled"
not conflict with what is defined in the template, because the leaf "enabled"
has a default value as "true" as compared to what has been configured in the
template(false).
From: Kent Watsen <[email protected]>
Sent: Thursday, November 14, 2024 3:14 AM
To: Robert Peschi (Nokia) <[email protected]>
Cc: [email protected]
Subject: [netmod] Re: Mandatory/default statements and templates (was: Yang
Template Proposals)
CAUTION: This is an external email. Please be very careful when clicking links
or opening attachments. See the URL nok.it/ext for additional information.
Hi Robert,
The issue that I raise in slide 8 of proposal #1 is the following.
A data node “foo” that has a default can be used in a template configuration
without problem (while configuring the template, the default can be used or
another value can be explicitly configured instead). However, this same data
node “foo” must not keep this default value when used in the YANG schema of the
instance.
I’m having a hard time parsing this paragraph:
1) Are you assuming a default mode? (RFC 6243)
2) Does "that has a default” mean in the YANG module or configuration?
3) What is an “instance”? (I think you mean “configuration”)
It might help to use terms defined in various RFCs.
Why so ?
Well, imagine that the template is explicitly configured with “foo” having
value 200, so, different from the default.
In the general case, the vast majority of the data nodes of an instance are not
explicitly configured because the expectation is that their value comes from
the template. If the instance data node “foo” is left unconfigured (naively
hoping to inherit 200 from the template) but still has its default 100, the
default value 100 will take effect as-if it had been explicitly configured and
hence 100 will overrule the value 200 coming from the template. The problem is
that this default value overruling the template will happen silently, so this
is very prone to unintended behaviour !
So this is why default values in instances should not be present.
I love that you provided an example, but I again am having trouble parsing what
is written. It would be clearer if the example contained snippets of YANG and
JSON/XML.
That said, my understanding of how templates are processed is so
straightforward, that no special consideration for how leafs with ‘default’
statements are processed is needed. In my worldview, the templates are fully
expanded/flattened and, if an unconfigured leaf has a ‘default’ statement, then
it is understood that the ‘default’ value is used when the config is *applied*
(standard RFC 7950 behavior).
The issue with mandatory is that data nodes that are mandatory in templates and
instances must be configured twice: once in the template (this one is OK) but
also in the instance (this one is useless, value would have come from the
template anyway). This causes inefficiency to the template mechanism, albeit it
is less problematic than the “default” issue because it is not a silent side
effect.
I disagree that ‘mandatory’ leafs must be configured in templates. I think
that mandatory nodes only must be configured after all templates have been
fully expanded/flattened.
That said, please add a requirement for "‘mandatory’ leafs must be configured
in templates” to the issue tracker so the idea can be scored later.
Kent // contributor
_______________________________________________
netmod mailing list -- [email protected]
To unsubscribe send an email to [email protected]