New clixon-lib@2024-01-01.yang revision
* Replaced container creators to grouping/uses
This commit is contained in:
parent
74ed09b36e
commit
ea645d1334
9 changed files with 136 additions and 56 deletions
|
|
@ -28,6 +28,8 @@ Expected: February 2024
|
||||||
### C/CLI-API changes on existing features
|
### C/CLI-API changes on existing features
|
||||||
Developers may need to change their code
|
Developers may need to change their code
|
||||||
|
|
||||||
|
* New `clixon-lib@2024-01-01.yang` revision
|
||||||
|
* Replaced container creators to grouping/uses
|
||||||
* Changed ca_errmsg callback to a more generic variant
|
* Changed ca_errmsg callback to a more generic variant
|
||||||
* Includes all error, log and debug messages
|
* Includes all error, log and debug messages
|
||||||
* See [Customized NETCONF error message](https://github.com/clicon/clixon/issues/454)
|
* See [Customized NETCONF error message](https://github.com/clicon/clixon/issues/454)
|
||||||
|
|
|
||||||
|
|
@ -170,10 +170,10 @@ typedef struct xml cxobj; /* struct defined in clicon_xml.c */
|
||||||
*
|
*
|
||||||
* @param[in] x XML node
|
* @param[in] x XML node
|
||||||
* @param[in] arg General-purpose argument
|
* @param[in] arg General-purpose argument
|
||||||
* @retval -1 Error, aborted at first error encounter, return -1 to end user
|
|
||||||
* @retval 0 OK, continue
|
|
||||||
* @retval 1 Abort, dont continue with others, return 1 to end user
|
|
||||||
* @retval 2 Locally abort this subtree, continue with others
|
* @retval 2 Locally abort this subtree, continue with others
|
||||||
|
* @retval 1 Abort, dont continue with others, return 1 to end user
|
||||||
|
* @retval 0 OK, continue
|
||||||
|
* @retval -1 Error, aborted at first error encounter, return -1 to end user
|
||||||
*/
|
*/
|
||||||
typedef int (xml_applyfn_t)(cxobj *x, void *arg);
|
typedef int (xml_applyfn_t)(cxobj *x, void *arg);
|
||||||
|
|
||||||
|
|
@ -239,7 +239,6 @@ size_t xml_creator_len(cxobj *xn);
|
||||||
cvec *xml_creator_get(cxobj *xn);
|
cvec *xml_creator_get(cxobj *xn);
|
||||||
int xml_creator_copy_one(cxobj *x0, cxobj *x1);
|
int xml_creator_copy_one(cxobj *x0, cxobj *x1);
|
||||||
int xml_creator_copy_all(cxobj *x0, cxobj *x1);
|
int xml_creator_copy_all(cxobj *x0, cxobj *x1);
|
||||||
int xml_creator_print(FILE *f, cxobj *xn);
|
|
||||||
|
|
||||||
char *xml_value(cxobj *xn);
|
char *xml_value(cxobj *xn);
|
||||||
int xml_value_set(cxobj *xn, char *val);
|
int xml_value_set(cxobj *xn, char *val);
|
||||||
|
|
|
||||||
|
|
@ -77,5 +77,6 @@ int xml_rpc_isaction(cxobj *xn);
|
||||||
int xml_find_action(cxobj *xn, int top, cxobj **xap);
|
int xml_find_action(cxobj *xn, int top, cxobj **xap);
|
||||||
int purge_tagged_nodes(cxobj *xn, char *ns, char *name, char *value, int keepnode);
|
int purge_tagged_nodes(cxobj *xn, char *ns, char *name, char *value, int keepnode);
|
||||||
int clixon_compare_xmls(cxobj *xc1, cxobj *xc2, enum format_enum format);
|
int clixon_compare_xmls(cxobj *xc1, cxobj *xc2, enum format_enum format);
|
||||||
|
int xml_creator_tree(cxobj *xt, cxobj **xcreator);
|
||||||
|
|
||||||
#endif /* _CLIXON_XML_MAP_H_ */
|
#endif /* _CLIXON_XML_MAP_H_ */
|
||||||
|
|
|
||||||
|
|
@ -819,41 +819,6 @@ xml_creator_copy_all(cxobj *x0,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Print XML and creator tags where they exists, apply help function
|
|
||||||
*
|
|
||||||
* @param[in] x XML tree
|
|
||||||
* @param[in] arg FIle
|
|
||||||
* @retval see xml_apply
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
creator_print_fn(cxobj *x,
|
|
||||||
void *arg)
|
|
||||||
{
|
|
||||||
FILE *f = (FILE *)arg;
|
|
||||||
cg_var *cv;
|
|
||||||
|
|
||||||
if (x->x_creators == NULL)
|
|
||||||
return 0;
|
|
||||||
cv = NULL;
|
|
||||||
while ((cv = cvec_each(x->x_creators, cv)) != NULL){
|
|
||||||
fprintf(f, "%s ", cv_name_get(cv));
|
|
||||||
}
|
|
||||||
fprintf(f, ":\n");
|
|
||||||
clixon_xml2file(f, x, 3, 1, NULL, cligen_output, 0, 0);
|
|
||||||
return 2; /* Locally abort this subtree, continue with others */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Print XML and creator tags where they exists recursively, for debugging
|
|
||||||
*
|
|
||||||
* @param[in] xn XML tree
|
|
||||||
* @retval see xml_apply
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xml_creator_print(FILE *f,
|
|
||||||
cxobj *xn)
|
|
||||||
{
|
|
||||||
return xml_apply0(xn, CX_ELMNT, creator_print_fn, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Get value of xnode
|
/*! Get value of xnode
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,9 @@
|
||||||
/* Size of xml read buffer */
|
/* Size of xml read buffer */
|
||||||
#define BUFLEN 1024
|
#define BUFLEN 1024
|
||||||
|
|
||||||
|
/* Forward */
|
||||||
|
static int xml_diff2cbuf(cbuf *cb, cxobj *x0, cxobj *x1, int level, int skiptop);
|
||||||
|
|
||||||
/*------------------------------------------------------------------------
|
/*------------------------------------------------------------------------
|
||||||
* XML printing functions. Output a parse tree to file, string cligen buf
|
* XML printing functions. Output a parse tree to file, string cligen buf
|
||||||
*------------------------------------------------------------------------*/
|
*------------------------------------------------------------------------*/
|
||||||
|
|
@ -1037,7 +1040,7 @@ xml_diff2cbuf_ordered_by_user(cbuf *cb,
|
||||||
* @see clixon_compare_xmls which uses files and is independent of YANG
|
* @see clixon_compare_xmls which uses files and is independent of YANG
|
||||||
* @see text_diff2cbuf
|
* @see text_diff2cbuf
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
xml_diff2cbuf(cbuf *cb,
|
xml_diff2cbuf(cbuf *cb,
|
||||||
cxobj *x0,
|
cxobj *x0,
|
||||||
cxobj *x1,
|
cxobj *x1,
|
||||||
|
|
|
||||||
|
|
@ -2034,3 +2034,90 @@ clixon_compare_xmls(cxobj *xc1,
|
||||||
unlink(filename2);
|
unlink(filename2);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Add creator data to metadata xml object on the form name:xpath*
|
||||||
|
*
|
||||||
|
* Callback function type for xml_apply
|
||||||
|
* @param[in] x XML node
|
||||||
|
* @param[in] arg General-purpose argument
|
||||||
|
* @retval 2 Locally abort this subtree, continue with others
|
||||||
|
* @retval 1 Abort, dont continue with others, return 1 to end user
|
||||||
|
* @retval 0 OK, continue
|
||||||
|
* @retval -1 Error, aborted at first error encounter, return -1 to end user
|
||||||
|
* On the form:
|
||||||
|
* <creator>
|
||||||
|
* <name>testA[name='foo']</name>
|
||||||
|
* <xpath>...</xpath>
|
||||||
|
* ...
|
||||||
|
* </creator>
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xml_creator_one(cxobj *x,
|
||||||
|
void *arg)
|
||||||
|
{
|
||||||
|
int retval = -1;
|
||||||
|
cxobj *xmeta = (cxobj*)arg;
|
||||||
|
cxobj *xmc;
|
||||||
|
cvec *cvv;
|
||||||
|
cg_var *cv;
|
||||||
|
char *val;
|
||||||
|
cvec *nsc = NULL;
|
||||||
|
char *xpath = NULL;
|
||||||
|
|
||||||
|
if ((cvv = xml_creator_get(x)) == NULL){
|
||||||
|
retval = 0;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
/* Note this requires x to have YANG spec */
|
||||||
|
if (xml2xpath(x, nsc, 0, 0, &xpath) < 0)
|
||||||
|
goto done;
|
||||||
|
cv = NULL;
|
||||||
|
while ((cv = cvec_each(cvv, cv)) != NULL){
|
||||||
|
val = cv_name_get(cv);
|
||||||
|
/* Find existing entry where name is val */
|
||||||
|
xmc = NULL;
|
||||||
|
while ((xmc = xml_child_each(xmeta, xmc, CX_ELMNT)) != NULL){
|
||||||
|
if (strcmp(xml_find_body(xmc, "name"), val) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (xmc != NULL){
|
||||||
|
if (clixon_xml_parse_va(YB_NONE, NULL, &xmc, NULL, "<path>%s</path>", xpath) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (clixon_xml_parse_va(YB_NONE, NULL, &xmeta, NULL,
|
||||||
|
"<creator><name>%s</name><path>%s</path></creator>",
|
||||||
|
val, xpath) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
retval = 2;
|
||||||
|
done:
|
||||||
|
if (xpath)
|
||||||
|
free(xpath);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Create creator data tree on the form (name:xpath*)*
|
||||||
|
*
|
||||||
|
* @param[in] xt XML top-level node, where to look for creator attributes
|
||||||
|
* @param[out] xcreators Created XML tree on the form <creators><creator>...
|
||||||
|
* @retval 0 OK
|
||||||
|
* @retval -1 Error
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xml_creator_tree(cxobj *xt,
|
||||||
|
cxobj **xcreators)
|
||||||
|
{
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
|
if ((*xcreators = xml_new("creators", NULL, CX_ELMNT)) == NULL)
|
||||||
|
goto done;
|
||||||
|
if (xmlns_set(*xcreators, NULL, CLIXON_LIB_NS) < 0)
|
||||||
|
goto done;
|
||||||
|
if (xml_apply(xt, CX_ELMNT, xml_creator_one, *xcreators) < 0)
|
||||||
|
goto done;
|
||||||
|
retval = 0;
|
||||||
|
done:
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ DATASTORE_TOP="config"
|
||||||
|
|
||||||
# clixon yang revisions occuring in tests (see eg yang/clixon/Makefile.in)
|
# clixon yang revisions occuring in tests (see eg yang/clixon/Makefile.in)
|
||||||
CLIXON_AUTOCLI_REV="2023-09-01"
|
CLIXON_AUTOCLI_REV="2023-09-01"
|
||||||
CLIXON_LIB_REV="2023-11-01"
|
CLIXON_LIB_REV="2024-01-01"
|
||||||
CLIXON_CONFIG_REV="2023-05-01"
|
CLIXON_CONFIG_REV="2023-05-01"
|
||||||
CLIXON_RESTCONF_REV="2022-08-01"
|
CLIXON_RESTCONF_REV="2022-08-01"
|
||||||
CLIXON_EXAMPLE_REV="2022-11-01"
|
CLIXON_EXAMPLE_REV="2022-11-01"
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ YANG_INSTALLDIR = @YANG_INSTALLDIR@
|
||||||
# Note: mirror these to test/config.sh.in
|
# Note: mirror these to test/config.sh.in
|
||||||
YANGSPECS = clixon-config@2023-11-01.yang # 6.5
|
YANGSPECS = clixon-config@2023-11-01.yang # 6.5
|
||||||
YANGSPECS += clixon-lib@2023-11-01.yang # 6.5
|
YANGSPECS += clixon-lib@2023-11-01.yang # 6.5
|
||||||
|
YANGSPECS += clixon-lib@2024-01-01.yang # 6.6
|
||||||
YANGSPECS += clixon-rfc5277@2008-07-01.yang
|
YANGSPECS += clixon-rfc5277@2008-07-01.yang
|
||||||
YANGSPECS += clixon-xml-changelog@2019-03-21.yang
|
YANGSPECS += clixon-xml-changelog@2019-03-21.yang
|
||||||
YANGSPECS += clixon-restconf@2022-08-01.yang # 5.9
|
YANGSPECS += clixon-restconf@2022-08-01.yang # 5.9
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,18 @@ module clixon-lib {
|
||||||
- objectexisted
|
- objectexisted
|
||||||
";
|
";
|
||||||
|
|
||||||
|
revision 2024-01-01 {
|
||||||
|
description
|
||||||
|
"Moved container creators to grouping/uses
|
||||||
|
Released in 6.6.0";
|
||||||
|
}
|
||||||
|
revision 2023-11-01 {
|
||||||
|
description
|
||||||
|
"Added ignore-compare extension
|
||||||
|
Added creator meta configuration
|
||||||
|
Removed obsolete extension autocli-op
|
||||||
|
Released in 6.5.0";
|
||||||
|
}
|
||||||
revision 2023-05-01 {
|
revision 2023-05-01 {
|
||||||
description
|
description
|
||||||
"Restructured and extended stats rpc to schema mountpoints
|
"Restructured and extended stats rpc to schema mountpoints
|
||||||
|
|
@ -179,7 +191,7 @@ module clixon-lib {
|
||||||
}
|
}
|
||||||
identity restconf {
|
identity restconf {
|
||||||
description
|
description
|
||||||
"RESTCONF either as HTTP/1 or /2, TLS or not, reverese proxy (eg fcgi/nginx) or native";
|
"RESTCONF either as HTTP/1 or /2, TLS or not, reverse proxy (eg fcgi/nginx) or native";
|
||||||
base ncm:transport;
|
base ncm:transport;
|
||||||
}
|
}
|
||||||
identity cli {
|
identity cli {
|
||||||
|
|
@ -187,20 +199,12 @@ module clixon-lib {
|
||||||
"A CLI session";
|
"A CLI session";
|
||||||
base ncm:transport;
|
base ncm:transport;
|
||||||
}
|
}
|
||||||
extension autocli-op {
|
extension ignore-compare {
|
||||||
description
|
description
|
||||||
"Takes an argument an operation defing how to modify the clispec at
|
"The object should be ignored when comparing device configs for equality.
|
||||||
this point in the YANG tree for the automated generated CLI.
|
One example is auto-created objects by the server, such as uid.
|
||||||
Note that this extension is only used in clixon_cli.
|
Another example is a plain-text password is changed to an encrypted by the server.";
|
||||||
Operations is expected to be extended, but the following operations are defined:
|
|
||||||
- hide This command is active but not shown by ? or TAB (meaning, it hides the auto-completion of commands)
|
|
||||||
- hide-database This command hides the database
|
|
||||||
- hide-database-auto-completion This command hides the database and the auto completion (meaning, this command acts as both commands above)
|
|
||||||
Obsolete: use clixon-autocli:hide and clixon-autocli:hide-show instead";
|
|
||||||
argument cliop;
|
|
||||||
status obsolete;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
md:annotation creator {
|
md:annotation creator {
|
||||||
type string;
|
type string;
|
||||||
description
|
description
|
||||||
|
|
@ -209,8 +213,26 @@ module clixon-lib {
|
||||||
create the same object. When such a service is deleted (or changed) one needs to keep
|
create the same object. When such a service is deleted (or changed) one needs to keep
|
||||||
track of which service created what.
|
track of which service created what.
|
||||||
Limitations: only objects that are actually added or deleted.
|
Limitations: only objects that are actually added or deleted.
|
||||||
A sub-object wil not be noted";
|
A sub-object will not be noted";
|
||||||
}
|
}
|
||||||
|
grouping clixon-creators{
|
||||||
|
container creators{
|
||||||
|
config false;
|
||||||
|
description "Meta-data for creator attribute.";
|
||||||
|
list creator {
|
||||||
|
key name;
|
||||||
|
leaf name {
|
||||||
|
description "Name of creator / service (instance) name";
|
||||||
|
type string;
|
||||||
|
}
|
||||||
|
leaf-list path {
|
||||||
|
description "Path to object";
|
||||||
|
type string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uses clixon-creators;
|
||||||
rpc debug {
|
rpc debug {
|
||||||
description "Set debug level of backend.";
|
description "Set debug level of backend.";
|
||||||
input {
|
input {
|
||||||
Loading…
Add table
Add a link
Reference in a new issue