* Regexp improvements

* Added check for libxml in configure';
  * Added clixon_util_regexp utility function
* Yang state get improvements
  * Integrated state and config into same tree on retrieval, not separate trees
  * Added cli functions `cli_show_config_state()` and `cli_show_auto_state()` for showing combined config and state info.
  * Added integrated state in the main example: `interface/oper-state`.
  * Added performance tests for getting state, see [test/test_perf_state.sh].
This commit is contained in:
Olof hagsand 2019-05-20 16:03:29 +02:00
parent c17784cfe9
commit bc54f2d04c
26 changed files with 895 additions and 185 deletions

View file

@ -69,7 +69,6 @@
#include <sys/param.h>
#include <netinet/in.h>
#include <libgen.h>
#include <regex.h>
/* cligen */
#include <cligen/cligen.h>
@ -3323,6 +3322,12 @@ ys_parse_sub(yang_stmt *ys,
cv_uint32_set(ys->ys_cv, minmax);
}
break;
case Y_MODIFIER:
if (strcmp(yang_argument_get(ys), "invert-match")){
clicon_err(OE_YANG, EINVAL, "modifier %s, expected invert-match", yang_argument_get(ys));
goto done;
}
break;
case Y_UNKNOWN: /* XXX This code assumes ymod already loaded
but it may not be */
if (extra == NULL)

View file

@ -75,6 +75,7 @@
#include "clixon_data.h"
#include "clixon_plugin.h"
#include "clixon_netconf_lib.h"
#include "clixon_xml_map.h"
#include "clixon_yang_module.h"
#include "clixon_yang_internal.h" /* internal */
@ -289,11 +290,16 @@ yang_modules_state_get(clicon_handle h,
cxobj *x1;
cbuf *cb = NULL;
int ret;
cxobj **xvec = NULL;
size_t xlen;
int i;
msid = clicon_option_str(h, "CLICON_MODULE_SET_ID");
if ((x = clicon_modst_cache_get(h, brief)) != NULL){
/* x is here: <modules-state>...
* and x is original tree, need to copy */
if ((x = xml_wrap(x, "top")) < 0)
goto done;
if (xpath_first(x, "%s", xpath)){
if ((x1 = xml_dup(x)) == NULL)
goto done;
@ -301,6 +307,9 @@ yang_modules_state_get(clicon_handle h,
}
else
x = NULL;
/* unwrap */
if (x && xml_rootchild(x, 0, &x) < 0)
goto done;
}
else { /* No cache -> build the tree */
if ((cb = cbuf_new()) == NULL){
@ -322,10 +331,21 @@ yang_modules_state_get(clicon_handle h,
if (clicon_modst_cache_set(h, brief, x) < 0) /* move to fn above? */
goto done;
}
if (x){
/* Wrap x (again) with new top-level node "top" which merge wants */
if (x){ /* x is here a copy (This code is ugly and I think wrong) */
/* Wrap x (again) with new top-level node "top" which xpath wants */
if ((x = xml_wrap(x, "top")) < 0)
goto done;
/* extract xpath part of module-state tree */
if (xpath_vec(x, "%s", &xvec, &xlen, xpath?xpath:"/") < 0)
goto done;
if (xvec != NULL){
for (i=0; i<xlen; i++)
xml_flag_set(xvec[i], XML_FLAG_MARK);
}
/* Remove everything that is not marked */
if (xml_tree_prune_flagged_sub(x, XML_FLAG_MARK, 1, NULL) < 0)
goto done;
if ((ret = netconf_trymerge(x, yspec, xret)) < 0)
goto done;
if (ret == 0)
@ -334,6 +354,8 @@ yang_modules_state_get(clicon_handle h,
retval = 1;
done:
clicon_debug(1, "%s %d", __FUNCTION__, retval);
if (xvec)
free(xvec);
if (cb)
cbuf_free(cb);
if (x)

View file

@ -51,7 +51,8 @@ struct ys_stack{
};
struct clicon_yang_yacc_arg{ /* XXX: mostly unrelevant */
char *yy_name; /* Name of syntax (for error string) */
char *yy_name; /* Name of syntax, typically filename
(for error string) */
int yy_linenum; /* Number of \n in parsed buffer */
char *yy_parse_string; /* original (copy of) parse string */
void *yy_lexbuf; /* internal parse buffer from lex */