Fixed: [yang submodule show error in modules-state #190](yang submodule show error in modules-state #190)
This commit is contained in:
parent
fb9917e81e
commit
f8830dc27e
3 changed files with 31 additions and 14 deletions
|
|
@ -69,6 +69,7 @@ Developers may need to change their code
|
|||
|
||||
### Corrected Bugs
|
||||
|
||||
* Fixed: [yang submodule show error in modules-state #190](yang submodule show error in modules-state #190)
|
||||
* Fixed: [Backend can not read datastore with container named "config" #147](https://github.com/clicon/clixon/issues/147)
|
||||
* Fixed: [The config false leaf shouldn't be configed in startup stage #189](https://github.com/clicon/clixon/issues/189)
|
||||
* Fixed: [CLIXON is not waiting for the hello message #184](https://github.com/clicon/clixon/issues/184)
|
||||
|
|
|
|||
|
|
@ -180,6 +180,9 @@ yms_build(clicon_handle h,
|
|||
yang_stmt *yc;
|
||||
yang_stmt *ymod; /* generic module */
|
||||
yang_stmt *yns = NULL; /* namespace */
|
||||
yang_stmt *yinc;
|
||||
yang_stmt *ysub;
|
||||
char *name;
|
||||
|
||||
if ((ylib = yang_find(yspec, Y_MODULE, module)) == NULL &&
|
||||
(ylib = yang_find(yspec, Y_SUBMODULE, module)) == NULL){
|
||||
|
|
@ -196,8 +199,7 @@ yms_build(clicon_handle h,
|
|||
|
||||
ymod = NULL;
|
||||
while ((ymod = yn_each(yspec, ymod)) != NULL) {
|
||||
if (yang_keyword_get(ymod) != Y_MODULE &&
|
||||
yang_keyword_get(ymod) != Y_SUBMODULE)
|
||||
if (yang_keyword_get(ymod) != Y_MODULE)
|
||||
continue;
|
||||
cprintf(cb,"<module>");
|
||||
cprintf(cb,"<name>%s</name>", yang_argument_get(ymod));
|
||||
|
|
@ -228,21 +230,20 @@ yms_build(clicon_handle h,
|
|||
}
|
||||
cprintf(cb, "<conformance-type>implement</conformance-type>");
|
||||
}
|
||||
yc = NULL;
|
||||
while ((yc = yn_each(ymod, yc)) != NULL) {
|
||||
switch(yang_keyword_get(yc)){
|
||||
case Y_SUBMODULE:
|
||||
cprintf(cb,"<submodule>");
|
||||
cprintf(cb,"<name>%s</name>", yang_argument_get(yc));
|
||||
if ((ys = yang_find(yc, Y_REVISION, NULL)) != NULL)
|
||||
yinc = NULL;
|
||||
while ((yinc = yn_each(ymod, yinc)) != NULL) {
|
||||
if (yang_keyword_get(yinc) != Y_INCLUDE)
|
||||
continue;
|
||||
cprintf(cb,"<submodule>");
|
||||
name = yang_argument_get(yinc);
|
||||
cprintf(cb,"<name>%s</name>", name);
|
||||
if ((ysub = yang_find(yspec, Y_SUBMODULE, name)) != NULL){
|
||||
if ((ys = yang_find(ysub, Y_REVISION, NULL)) != NULL)
|
||||
cprintf(cb,"<revision>%s</revision>", yang_argument_get(ys));
|
||||
else
|
||||
cprintf(cb,"<revision></revision>");
|
||||
cprintf(cb,"</submodule>");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
cprintf(cb,"</submodule>");
|
||||
}
|
||||
cprintf(cb,"</module>");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ restconf_config none false
|
|||
|
||||
cat <<EOF > $cfg
|
||||
<clixon-config xmlns="http://clicon.org/config">
|
||||
<CLICON_FEATURE>main:A</CLICON_FEATURE>
|
||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
|
||||
|
|
@ -44,7 +45,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_BACKEND_REGEXP>example_backend.so$</CLICON_BACKEND_REGEXP>
|
||||
<CLICON_RESTCONF_DIR>/usr/local/lib/$APPNAME/restconf</CLICON_RESTCONF_DIR>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
<CLICON_MODULE_LIBRARY_RFC7895>false</CLICON_MODULE_LIBRARY_RFC7895>
|
||||
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
|
@ -55,11 +56,19 @@ module main{
|
|||
yang-version 1.1;
|
||||
prefix ex;
|
||||
namespace "urn:example:clixon";
|
||||
|
||||
include sub1;
|
||||
import extra{
|
||||
description "Uses the same prefix as submodule but for another module";
|
||||
prefix xtra;
|
||||
}
|
||||
revision 2021-03-08;
|
||||
feature A{
|
||||
description "This test feature is enabled";
|
||||
}
|
||||
feature B{
|
||||
description "This test feature is not enabled";
|
||||
}
|
||||
container main{
|
||||
uses xtra:mygroup;
|
||||
leaf x{
|
||||
|
|
@ -248,6 +257,12 @@ expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+jso
|
|||
new "restconf edit augment 2"
|
||||
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/main:sub2 -d '{"main:aug2":"foo"}')" 0 'HTTP/1.1 201 Created'
|
||||
|
||||
new "NETCONF get module state"
|
||||
expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get><filter type=\"xpath\" select=\"/yl:modules-state/yl:module[yl:name='main']\" xmlns:yl=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\"/></get></rpc>]]>]]>" "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\"><module><name>main</name><revision>2021-03-08</revision><namespace>urn:example:clixon</namespace><feature>A</feature><conformance-type>implement</conformance-type><submodule><name>sub1</name><revision/></submodule></module>"
|
||||
|
||||
new "RESTCONF get module state"
|
||||
expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml" $RCPROTO://localhost/restconf/data/ietf-yang-library:modules-state/module=main,2021-03-08?config=nonconfig)" 0 'HTTP/1.1 200 OK' "<module xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\"><name>main</name><revision>2021-03-08</revision><namespace>urn:example:clixon</namespace><feature>A</feature><conformance-type>implement</conformance-type><submodule><name>sub1</name><revision/></submodule></module>"
|
||||
|
||||
if [ $RC -ne 0 ]; then
|
||||
new "Kill restconf daemon"
|
||||
stop_restconf
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue