Fixed an issue with openconfig path compression: the compression was always done, not exclusively
for openconfig. See [OpenConfig path compression](https://github.com/clicon/clixon/pull/276)
This commit is contained in:
parent
2bb5c23856
commit
7d9d0017a9
3 changed files with 34 additions and 31 deletions
|
|
@ -94,7 +94,8 @@ Developers may need to change their code
|
|||
* Check blocked signals and signal handlers
|
||||
* Check termios settings
|
||||
* Any changes to context are logged at loglevel WARNING
|
||||
* Added set/get pointer API to clixon_data:
|
||||
* [OpenConfig path compression](https://github.com/clicon/clixon/pull/276)
|
||||
* C API: Added set/get pointer API to clixon_data:
|
||||
* clicon_ptr_get(), clicon_ptr_set(),
|
||||
* Restconf YANG PATCH according to RFC 8072
|
||||
* Changed YANG PATCH enabling:
|
||||
|
|
|
|||
|
|
@ -834,26 +834,27 @@ yang2cli_container(clicon_handle h,
|
|||
char *s;
|
||||
int hide = 0;
|
||||
int hide_oc = 0;
|
||||
int exist = 0;
|
||||
int isoc = 0;
|
||||
char *opext = NULL;
|
||||
yang_stmt *ymod = NULL;
|
||||
|
||||
|
||||
if (ys_real_module(ys, &ymod) < 0)
|
||||
goto done;
|
||||
if (yang_extension_value(ymod, "openconfig-version", "http://openconfig.net/yang/openconfig-ext", &exist, NULL) < 0)
|
||||
goto done;
|
||||
if (exist) {
|
||||
if (strcmp(yang_argument_get(ys), "config") == 0){
|
||||
hide_oc = 1;
|
||||
}
|
||||
goto done;
|
||||
/* Hide container "config" if openconfig and OC_COMPRESS */
|
||||
if (strcmp(yang_argument_get(ys), "config") == 0){
|
||||
if (0) fprintf(stderr, "%s config\n", __FUNCTION__);
|
||||
if (yang_extension_value(ymod, "openconfig-version", "http://openconfig.net/yang/openconfig-ext", &isoc, NULL) < 0)
|
||||
goto done;
|
||||
if (isoc &&
|
||||
gt == GT_OC_COMPRESS)
|
||||
hide_oc = 1;
|
||||
}
|
||||
|
||||
/* If non-presence container && HIDE mode && only child is
|
||||
* a list, then skip container keyword
|
||||
* See also xml2cli
|
||||
*/
|
||||
if ((hide = yang_container_cli_hide(ys, gt)) == 0 && hide_oc == 0){
|
||||
if ((hide = yang_container_cli_hide(ys, gt)) == 0 && hide_oc == 0){
|
||||
cprintf(cb, "%*s%s", level*3, "", yang_argument_get(ys));
|
||||
if ((yd = yang_find(ys, Y_DESCRIPTION, NULL)) != NULL){
|
||||
if ((helptext = strdup(yang_argument_get(yd))) == NULL){
|
||||
|
|
@ -882,10 +883,10 @@ yang2cli_container(clicon_handle h,
|
|||
yc = NULL;
|
||||
while ((yc = yn_each(ys, yc)) != NULL)
|
||||
if (yang2cli_stmt(h, yc, gt, level+1, state, show_tree, cb) < 0)
|
||||
goto done;
|
||||
if (hide == 0 && hide_oc == 0)
|
||||
cprintf(cb, "%*s}\n", level*3, "");
|
||||
retval = 0;
|
||||
goto done;
|
||||
if (hide == 0 && hide_oc == 0)
|
||||
cprintf(cb, "%*s}\n", level*3, "");
|
||||
retval = 0;
|
||||
done:
|
||||
if (helptext)
|
||||
free(helptext);
|
||||
|
|
|
|||
|
|
@ -109,11 +109,6 @@ module $APPNAME {
|
|||
}
|
||||
}
|
||||
}
|
||||
leaf enabled {
|
||||
type boolean;
|
||||
default false;
|
||||
description "Whether the interface is enabled or not.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -126,7 +121,7 @@ module ${APPNAME}2 {
|
|||
prefix ex2;
|
||||
import openconfig-extensions { prefix oc-ext; }
|
||||
container interfaces2 {
|
||||
list interface {
|
||||
list interface2 {
|
||||
key name;
|
||||
leaf name {
|
||||
type string;
|
||||
|
|
@ -153,11 +148,6 @@ module ${APPNAME}2 {
|
|||
}
|
||||
}
|
||||
}
|
||||
leaf enabled {
|
||||
type boolean;
|
||||
default false;
|
||||
description "Whether the interface is enabled or not.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -305,12 +295,23 @@ expectpart "$($clixon_cli -1 -f $cfg show state exstate)" 0 "state sender x" --n
|
|||
|
||||
#---- openconfig path compression
|
||||
|
||||
new "Openconfig: check no config path"
|
||||
expectpart "$($clixon_cli -1 -f $cfg set interfaces interface e config enabled true 2>&1)" 255 "Unknown command"
|
||||
new "Openconfig: OC_COMPRESS+extension: compressed)"
|
||||
expectpart "$($clixon_cli -1 -f $cfg -o CLICON_CLI_GENMODEL_TYPE=OC_COMPRESS set interface e enabled true 2>&1)" 0 "^$"
|
||||
|
||||
# negative test
|
||||
new "Openconfig: check exist config path"
|
||||
expectpart "$($clixon_cli -1 -f $cfg set interfaces2 interface e config enabled true 2>&1)" 0 "^$"
|
||||
new "Openconfig: OC_COMPRESS+extension: no config (negative)"
|
||||
expectpart "$($clixon_cli -1 -f $cfg -o CLICON_CLI_GENMODEL_TYPE=OC_COMPRESS set interface e config enabled true 2>&1)" 255 "Unknown command"
|
||||
|
||||
new "Openconfig: OC_COMPRESS+no-extension: no config"
|
||||
expectpart "$($clixon_cli -1 -f $cfg -o CLICON_CLI_GENMODEL_TYPE=OC_COMPRESS set interface2 e config enabled true 2>&1)" 0 "^$"
|
||||
|
||||
new "Openconfig: OC_COMPRESS+no-extension: no config (negative)"
|
||||
expectpart "$($clixon_cli -1 -f $cfg -o CLICON_CLI_GENMODEL_TYPE=OC_COMPRESS set interface2 e enabled true 2>&1)" 255 "Unknown command"
|
||||
|
||||
new "Openconfig: OC_VARS+extension: no compresssion"
|
||||
expectpart "$($clixon_cli -1 -f $cfg -o CLICON_CLI_GENMODEL_TYPE=VARS set interfaces interface e config enabled true 2>&1)" 0 "^$"
|
||||
|
||||
new "Openconfig: OC_VARS+extension: no compresssion (negative)"
|
||||
expectpart "$($clixon_cli -1 -f $cfg -o CLICON_CLI_GENMODEL_TYPE=VARS set interfaces interface e enabled true 2>&1)" 255 "Unknown command"
|
||||
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue