Fixed show mem yspec vs ydomain issue

This commit is contained in:
Olof hagsand 2024-10-28 10:39:04 +01:00
parent 947128339c
commit 54a8f51bfd
3 changed files with 126 additions and 5 deletions

View file

@ -425,7 +425,7 @@ clixon_stats_datastore_get(clixon_handle h,
* @retval -1 Error
*/
static int
clixon_stats_module_get(clixon_handle h,
clixon_stats_yang_get(clixon_handle h,
yang_stmt *ys,
cbuf *cb)
{
@ -1466,13 +1466,13 @@ from_client_stats(clixon_handle h,
while ((yspec = yn_iter(ydomain, &inext2)) != NULL) {
cprintf(cbret, "<module-set>");
cprintf(cbret, "<name>%s/%s</name>", domain, yang_argument_get(yspec));
if (clixon_stats_module_get(h, ydomain, cbret) < 0)
if (clixon_stats_yang_get(h, yspec, cbret) < 0)
goto done;
if (modules){
inext3 = 0;
while ((ymodule = yn_iter(yspec, &inext3)) != NULL) {
cprintf(cbret, "<module><name>%s</name>", yang_argument_get(ymodule));
if (clixon_stats_module_get(h, ymodule, cbret) < 0)
if (clixon_stats_yang_get(h, ymodule, cbret) < 0)
goto done;
cprintf(cbret, "</module>");
}

View file

@ -1936,6 +1936,8 @@ cli_show_statistics(clixon_handle h,
goto done;
}
if (cli) {
if (backend)
cligen_output(stdout, "CLI:\n====\n");
if (!detail) {
cligen_output(stdout, "%-25s %-10s\n", "YANG", "Mem");
}
@ -2004,6 +2006,8 @@ cli_show_statistics(clixon_handle h,
}
}
if (backend) {
if (cli)
cligen_output(stdout, "\nBackend:\n========\n");
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
cprintf(cb, " %s", NETCONF_MESSAGE_ID_ATTR); /* XXX: use incrementing sequence */
cprintf(cb, ">");

117
test/test_grouping_multi.sh Executable file
View file

@ -0,0 +1,117 @@
#!/usr/bin/env bash
# Tests multiple level groupings
# See https://github.com/clicon/clixon/issues/572
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
APPNAME=example
cfg=$dir/conf_yang.xml
fyang=$dir/example.yang
# XXX try -E?
cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_DIR>$dir</CLICON_YANG_MAIN_DIR>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_CLISPEC_DIR>$dir</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/run/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/run/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
<CLICON_YANG_LIBRARY>false</CLICON_YANG_LIBRARY>
</clixon-config>
EOF
cat <<EOF > $dir/example.cli
CLICON_MODE="example";
CLICON_PROMPT="%U@%H %W> ";
# Autocli syntax tree operations
edit @datamodel, cli_auto_edit("datamodel");
up, cli_auto_up("datamodel");
top, cli_auto_top("datamodel");
set @datamodel, cli_auto_set();
merge @datamodel, cli_auto_merge();
create @datamodel, cli_auto_create();
commit("Commit the changes"), cli_commit();
validate("Validate changes"), cli_validate();
delete("Delete a configuration item") {
@datamodel, cli_auto_del();
all("Delete whole candidate configuration"), delete_all("candidate");
}
show("Show a particular state of the system"){
configuration("Show configuration"), cli_show_auto_mode("candidate", "xml", false, false);
}
EOF
# Yang specs must be here first for backend. But then the specs are changed but just for CLI
# Annotate original Yang spec example directly
# First annotate /table/parameter
# Had a problem with unknown in grouping -> test uses uses/grouping
cat <<EOF > $fyang
module example {
namespace "urn:example:clixon";
prefix ex;
grouping L3-top {
leaf L3{
type string;
}
}
grouping L2-top {
container L2 {
uses L3-top {
when 'false';
}
}
}
container L1x {
/* Does not work */
uses L2-top;
}
container L1y {
/* Works */
container L2 {
uses L3-top {
when 'false';
}
}
}
}
EOF
new "test params: -f $cfg"
if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -z -f $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
fi
new "wait backend"
wait_backend
if [ $BE -ne 0 ]; then
new "Kill backend"
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
if [ -z "$pid" ]; then
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg
fi
rm -rf $dir
new "endtest"
endtest