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:
Olof hagsand 2021-11-14 17:54:58 +01:00
parent 2bb5c23856
commit 7d9d0017a9
3 changed files with 34 additions and 31 deletions

View file

@ -94,7 +94,8 @@ Developers may need to change their code
* Check blocked signals and signal handlers * Check blocked signals and signal handlers
* Check termios settings * Check termios settings
* Any changes to context are logged at loglevel WARNING * 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(), * clicon_ptr_get(), clicon_ptr_set(),
* Restconf YANG PATCH according to RFC 8072 * Restconf YANG PATCH according to RFC 8072
* Changed YANG PATCH enabling: * Changed YANG PATCH enabling:

View file

@ -834,20 +834,21 @@ yang2cli_container(clicon_handle h,
char *s; char *s;
int hide = 0; int hide = 0;
int hide_oc = 0; int hide_oc = 0;
int exist = 0; int isoc = 0;
char *opext = NULL; char *opext = NULL;
yang_stmt *ymod = NULL; yang_stmt *ymod = NULL;
if (ys_real_module(ys, &ymod) < 0) if (ys_real_module(ys, &ymod) < 0)
goto done; goto done;
if (yang_extension_value(ymod, "openconfig-version", "http://openconfig.net/yang/openconfig-ext", &exist, NULL) < 0) /* Hide container "config" if openconfig and OC_COMPRESS */
goto done;
if (exist) {
if (strcmp(yang_argument_get(ys), "config") == 0){ 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; hide_oc = 1;
} }
}
/* If non-presence container && HIDE mode && only child is /* If non-presence container && HIDE mode && only child is
* a list, then skip container keyword * a list, then skip container keyword

View file

@ -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; prefix ex2;
import openconfig-extensions { prefix oc-ext; } import openconfig-extensions { prefix oc-ext; }
container interfaces2 { container interfaces2 {
list interface { list interface2 {
key name; key name;
leaf name { leaf name {
type string; 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 #---- openconfig path compression
new "Openconfig: check no config path" new "Openconfig: OC_COMPRESS+extension: compressed)"
expectpart "$($clixon_cli -1 -f $cfg set interfaces interface e config enabled true 2>&1)" 255 "Unknown command" 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: OC_COMPRESS+extension: no config (negative)"
new "Openconfig: check exist config path" expectpart "$($clixon_cli -1 -f $cfg -o CLICON_CLI_GENMODEL_TYPE=OC_COMPRESS set interface e config enabled true 2>&1)" 255 "Unknown command"
expectpart "$($clixon_cli -1 -f $cfg set interfaces2 interface e config enabled true 2>&1)" 0 "^$"
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" new "Kill backend"
# Check if premature kill # Check if premature kill