diff --git a/CHANGELOG.md b/CHANGELOG.md index dd30fc82..bd925207 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,11 @@ ### API changes on existing features (you may need to change your code) +* Structural change: removed datastore plugin and directory, and merged into regulat clixon lib code. + * The CLICON_XMLDB_PLUGIN config option is obsolete, you should remove it from your config file + * The datastore directory is removed, code is moved to lib/src/clixon_datastore*.c + * removed clixon_backend -x command-line options +* Moved out code from clixon_options.[ch] into a new file: clixon_data.[ch] where non-option data resides. * Directory change: Moved example to example/main to make room for other examples. * Removed argc/argv parameters from ca_start plugin API function: * You may need to change signatures of your startup in your plugins, eg from: diff --git a/Makefile.in b/Makefile.in index b5f418bc..08335ac7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -52,7 +52,7 @@ INSTALL = @INSTALL@ INCLUDES = -I. -I@srcdir@ @INCLUDES@ SHELL = /bin/sh -SUBDIRS = lib apps include etc datastore yang +SUBDIRS = lib apps include etc yang .PHONY: doc example all clean depend $(SUBDIRS) install loc TAGS .config.status docker test diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c index feba64f5..16855189 100644 --- a/apps/backend/backend_client.c +++ b/apps/backend/backend_client.c @@ -111,7 +111,6 @@ ce_event_cb(clicon_handle h, break; } } - clicon_debug(1, "%s retval:0", __FUNCTION__); return 0; } @@ -227,10 +226,10 @@ client_statedata(clicon_handle h, int i; yang_spec *yspec; - if ((yspec = clicon_dbspec_yang(h)) == NULL){ + if ((yspec = clicon_dbspec_yang(h)) == NULL){ clicon_err(OE_YANG, ENOENT, "No yang spec"); goto done; - } + } if (clicon_option_bool(h, "CLICON_STREAM_DISCOVERY_RFC5277")) if ((retval = client_get_streams(h, yspec, xpath, "clixon-rfc5277", "netconf", xret)) != 0) goto done; @@ -245,7 +244,6 @@ client_statedata(clicon_handle h, /* Code complex to filter out anything that is outside of xpath */ if (xpath_vec(*xret, "%s", &xvec, &xlen, xpath?xpath:"/") < 0) goto done; - /* If vectors are specified then mark the nodes found and * then filter out everything else, * otherwise return complete tree. @@ -263,6 +261,7 @@ client_statedata(clicon_handle h, goto done; retval = 0; /* OK */ done: + clicon_debug(1, "%s %d", __FUNCTION__, retval); if (xvec) free(xvec); return retval; @@ -812,6 +811,7 @@ from_client_get(clicon_handle h, ok: retval = 0; done: + clicon_debug(1, "%s retval:%d", __FUNCTION__, retval); if (xnacm) xml_free(xnacm); if (xvec) diff --git a/apps/backend/backend_commit.c b/apps/backend/backend_commit.c index 74c51360..fdf8eeb1 100644 --- a/apps/backend/backend_commit.c +++ b/apps/backend/backend_commit.c @@ -172,6 +172,7 @@ startup_common(clicon_handle h, int ret; modstate_diff_t *msd = NULL; cxobj *xt = NULL; + cxobj *x; /* If CLICON_XMLDB_MODSTATE is enabled, then get the db XML with * potentially non-matching module-state in msd @@ -198,8 +199,11 @@ startup_common(clicon_handle h, goto done; /* Handcraft transition with with only add tree */ td->td_target = xt; - if (cxvec_append(td->td_target, &td->td_avec, &td->td_alen) < 0) - goto done; + x = NULL; + while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL){ + if (cxvec_append(x, &td->td_avec, &td->td_alen) < 0) + goto done; + } /* 4. Call plugin transaction start callbacks */ if (plugin_transaction_begin(h, td) < 0) diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index e77cccb2..cb2ec8d9 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -74,7 +74,7 @@ #include "backend_startup.h" /* Command line options to be passed to getopt(3) */ -#define BACKEND_OPTS "hD:f:l:d:p:b:Fza:u:P:1s:c:g:y:x:o:" +#define BACKEND_OPTS "hD:f:l:d:p:b:Fza:u:P:1s:c:g:y:o:" #define BACKEND_LOGFILE "/usr/local/var/clixon_backend.log" @@ -96,8 +96,14 @@ backend_terminate(clicon_handle h) clicon_debug(1, "%s", __FUNCTION__); if ((ss = clicon_socket_get(h)) != -1) close(ss); - if ((x = clicon_module_state_get(h)) != NULL) + /* Disconnect datastore */ + xmldb_disconnect(h); + /* Clear module state caches */ + if ((x = clicon_modst_cache_get(h, 0)) != NULL) xml_free(x); + if ((x = clicon_modst_cache_get(h, 1)) != NULL) + xml_free(x); + /* Free changelog */ if ((x = clicon_xml_changelog_get(h)) != NULL) xml_free(x); if ((yspec = clicon_dbspec_yang(h)) != NULL) @@ -119,8 +125,6 @@ backend_terminate(clicon_handle h) unlink(pidfile); if (sockfamily==AF_UNIX && lstat(sockpath, &st) == 0) unlink(sockpath); - - xmldb_plugin_unload(h); /* unload storage plugin */ backend_handle_exit(h); /* Also deletes streams. Cannot use h after this. */ event_exit(); clicon_debug(1, "%s done", __FUNCTION__); @@ -289,7 +293,6 @@ usage(clicon_handle h, "\t-g \tClient membership required to this group (default: %s)\n" "\t-y \tLoad yang spec file (override yang main module)\n" - "\t-x \tXMLDB plugin\n" "\t-o \"