* New yang changelog experimental feature for automatic upgrade
* Added modules-state diff parameter to xmldb_get datastore function for startup scenarios. * Allowed Yang extended Xpath functions (syntax only): * re-match, deref, derived-from, derived-from-or-self, enum-value, bit-is-set * XSD regular expression handling of dash(`-`) *: Translate XDS `[xxx\-yyy]` to POSIX `[xxxyyy-]`. * YANG Anydata treated same as Anyxml
This commit is contained in:
parent
434f0b930e
commit
3f68cca06c
37 changed files with 1475 additions and 351 deletions
|
|
@ -273,7 +273,7 @@ startup_validate(clicon_handle h,
|
|||
int retval = -1;
|
||||
yang_spec *yspec;
|
||||
int ret;
|
||||
cxobj *xms = NULL;
|
||||
modstate_diff_t *msd = NULL;
|
||||
transaction_data_t *td = NULL;
|
||||
|
||||
/* Handcraft a transition with only target and add trees */
|
||||
|
|
@ -282,11 +282,17 @@ startup_validate(clicon_handle h,
|
|||
/* 2. Parse xml trees
|
||||
* This is the state we are going to
|
||||
* Note: xmsdiff contains non-matching modules
|
||||
* Only if CLICON_XMLDB_MODSTATE is enabled
|
||||
*/
|
||||
if (xmldb_get(h, db, "/", 1, &td->td_target, &xms) < 0)
|
||||
if (clicon_option_bool(h, "CLICON_XMLDB_MODSTATE"))
|
||||
if ((msd = modstate_diff_new()) == NULL)
|
||||
goto done;
|
||||
if (xmldb_get(h, db, "/", 1, &td->td_target, msd) < 0)
|
||||
goto done;
|
||||
if (xms && clixon_plugin_upgrade(h, xms) < 0)
|
||||
if ((ret = clixon_module_upgrade(h, td->td_target, msd, cbret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
|
||||
/* Handcraft transition with with only add tree */
|
||||
if (cxvec_append(td->td_target, &td->td_avec, &td->td_alen) < 0)
|
||||
|
|
@ -318,8 +324,8 @@ startup_validate(clicon_handle h,
|
|||
done:
|
||||
if (td)
|
||||
transaction_free(td);
|
||||
if (xms)
|
||||
xml_free(xms);
|
||||
if (msd)
|
||||
modstate_diff_free(msd);
|
||||
return retval;
|
||||
fail: /* cbret should be set */
|
||||
if (cbuf_len(cbret)==0){
|
||||
|
|
|
|||
|
|
@ -96,7 +96,10 @@ backend_terminate(clicon_handle h)
|
|||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
if ((ss = clicon_socket_get(h)) != -1)
|
||||
close(ss);
|
||||
modules_state_cache_set(h, NULL);
|
||||
if ((x = clicon_module_state_get(h)) != NULL)
|
||||
xml_free(x);
|
||||
if ((x = clicon_yang_changelog_get(h)) != NULL)
|
||||
xml_free(x);
|
||||
if ((yspec = clicon_dbspec_yang(h)) != NULL)
|
||||
yspec_free(yspec);
|
||||
if ((yspec = clicon_config_yang(h)) != NULL)
|
||||
|
|
@ -639,6 +642,11 @@ main(int argc,
|
|||
if (backend_rpc_init(h) < 0)
|
||||
goto done;
|
||||
|
||||
/* Must be after netconf_module_load, but before startup code */
|
||||
if (clicon_option_bool(h, "CLICON_YANG_CHANGELOG"))
|
||||
if (clixon_yang_changelog_init(h) < 0)
|
||||
goto done;
|
||||
|
||||
/* Save modules state of the backend (server). Compare with startup XML */
|
||||
if (startup_module_state(h, yspec) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -156,31 +156,6 @@ clixon_plugin_statedata(clicon_handle h,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! Call configuration upgrade routines in backend plugins
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] xms XML tree of module state differences
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error in one (first) of user callbacks
|
||||
*/
|
||||
int
|
||||
clixon_plugin_upgrade(clicon_handle h,
|
||||
cxobj *xmodst)
|
||||
{
|
||||
int retval = -1;
|
||||
clixon_plugin *cp = NULL;
|
||||
upgrade_cb_t *fn; /* Plugin configuration upgrade fn */
|
||||
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
if ((fn = cp->cp_api.ca_upgrade) == NULL)
|
||||
continue;
|
||||
if (fn(h, xmodst) < 0)
|
||||
goto done;
|
||||
}
|
||||
retval = 0;
|
||||
done:
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*! Create and initialize transaction */
|
||||
transaction_data_t *
|
||||
transaction_new(void)
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ int backend_plugin_initiate(clicon_handle h);
|
|||
int clixon_plugin_reset(clicon_handle h, char *db);
|
||||
|
||||
int clixon_plugin_statedata(clicon_handle h, yang_spec *yspec, char *xpath, cxobj **xtop);
|
||||
int clixon_plugin_upgrade(clicon_handle h, cxobj *xmodst);
|
||||
transaction_data_t * transaction_new(void);
|
||||
int transaction_free(transaction_data_t *);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue