how is the yang default statement used.

1,060 views
Skip to first unread message

salma...@gmail.com

unread,
Dec 16, 2014, 6:12:50 PM12/16/14
to libne...@googlegroups.com
Hi,

I have the following yang model:

module interface-example {

namespace "http://example.net/interface-example";

prefix "ifeg";

description
"Data model for the interface example.";

revision 2014-12-09 {
description
"Initial revision.";
}

/* Typedefs */
typedef state {
type enumeration {
enum locked;
enum unlocked;
}
default "unlocked";
}

/* State data and Configuration */
container ne {
description
"State data and configuration of a CYAN nseries.";

list equip {
key "slot";

leaf slot {
type uint16 {
range "1..4";
}
}

leaf adminState {
type state;
}
}
}
}

When I issue the following edit-config request from the netconf-cli everything seems OK. I printed out the updates in the transAPI callback and I got the request.

<ne xmlns="http://example.net/interface-example">
<equip>
<slot>1</slot>
</equip>
</ne>

The question I have is, because adminState was not specified in the netconf request and as the YANG model specifies a default, should we not get that update as well internally from the netopeer server.

If we don't get that request then what is the point of having the default statement in the model ?

Thanks,
Salman

Radek Krejčí

unread,
Dec 18, 2014, 3:49:19 AM12/18/14
to salma...@gmail.com, libne...@googlegroups.com
Hi Salman,

Dne 17.12.2014 v 00:12 salma...@gmail.com napsal(a):
yes, you should. But libnetconf currently does not support the default values defined as part of the type (libnetconf in general currently do nothing with typedefs). Try to move the default statement into the adminState and it should work as you expect.

I've added the issue to support this, however I don't think it will be implemented soon. We plan a huge internal change in the libnetconf for the next year and after implementing this change, support for all YANG features will be much more simpler.

But maybe some volunteer will provide a patch :)

Regards,
Radek

salma...@gmail.com

unread,
Dec 18, 2014, 12:51:20 PM12/18/14
to libne...@googlegroups.com, salma...@gmail.com
Thank you for your answer. Just tested the work around you mentioned and it works fine.

I wanted to know if there are some other YANG features that might not be supported that we need to be aware about when writing YANG models.

I'm mostly interested in groupings, must and when statements, XPath expressions within the YANG models.

Thanks,
Salman

salma...@gmail.com

unread,
Dec 18, 2014, 1:09:31 PM12/18/14
to libne...@googlegroups.com, salma...@gmail.com
Also wanted to know if there are any peculiar things on refine and augment statements. Refines also can use a default.

Thanks,
Salman

Radek Krejčí

unread,
Dec 19, 2014, 3:47:11 AM12/19/14
to salma...@gmail.com, libne...@googlegroups.com
Hi Salman,
good question :)

- groupings should be supported completely
- must/when statements - should be covered by validation processwhen you generate schematron file for your model (lnctool can do it for you)
- XPath expressions - in must/when statements it should be supported by schematron, libnetconf does not implement NETCONF's xpath: capability so it cannot be used for example for filtering
- import - supported
- submodule/belongs-to - not supported
- refine - not supported
- augment - supported
- extension - not supported
- deviation - not supported

Other statements (ordering in lists, choices,...) should be supported.

Best regards,
Radek

Dne 18.12.2014 v 19:09 salma...@gmail.com napsal(a):
Reply all
Reply to author
Forward
0 new messages