Changed module-specific upgrade API, not backward compatible. The API has been simplified which means more has to be done by the programmer.
* In summary, a user registers an upgrade callback per module. The callback is called at startup if the module is added, has been removed or if the revision on file is different from the one in the system. * The register function has removed `from` and `rev` parameters: `upgrade_callback_register(h, cb, namespace, arg)` * The callback function has a new `op` parameter with possible values: `XML_FLAG_ADD`, `XML_FLAG_CHANGE` or `XML_FLAG_CHANGE`: `clicon_upgrade_cb(h, xn, ns, op, from, to, arg, cbret)`
This commit is contained in:
parent
e2b3cdb3f6
commit
8f1de15ad3
10 changed files with 257 additions and 185 deletions
|
|
@ -177,19 +177,19 @@ startup_common(clicon_handle h,
|
|||
int retval = -1;
|
||||
yang_stmt *yspec;
|
||||
int ret;
|
||||
modstate_diff_t *msd = NULL;
|
||||
modstate_diff_t *msdiff = NULL;
|
||||
cxobj *xt = NULL;
|
||||
cxobj *x;
|
||||
cxobj *xret = NULL;
|
||||
|
||||
/* If CLICON_XMLDB_MODSTATE is enabled, then get the db XML with
|
||||
* potentially non-matching module-state in msd
|
||||
* potentially non-matching module-state in msdiff
|
||||
*/
|
||||
if (clicon_option_bool(h, "CLICON_XMLDB_MODSTATE"))
|
||||
if ((msd = modstate_diff_new()) == NULL)
|
||||
if ((msdiff = modstate_diff_new()) == NULL)
|
||||
goto done;
|
||||
clicon_debug(1, "Reading startup config from %s", db);
|
||||
if (xmldb_get0(h, db, NULL, "/", 0, &xt, msd) < 0)
|
||||
if (xmldb_get0(h, db, NULL, "/", 0, &xt, msdiff) < 0)
|
||||
goto done;
|
||||
clicon_debug(1, "Reading startup config done");
|
||||
/* Clear flags xpath for get */
|
||||
|
|
@ -202,13 +202,15 @@ startup_common(clicon_handle h,
|
|||
}
|
||||
/* Here xt is old syntax */
|
||||
/* General purpose datastore upgrade */
|
||||
if (clixon_plugin_datastore_upgrade_all(h, db, xt, msd) < 0)
|
||||
if (clixon_plugin_datastore_upgrade_all(h, db, xt, msdiff) < 0)
|
||||
goto done;
|
||||
/* Module-specific upgrade callbacks */
|
||||
if ((ret = clixon_module_upgrade(h, xt, msd, cbret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
if (msdiff){
|
||||
if ((ret = clixon_module_upgrade(h, xt, msdiff, cbret)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
goto fail;
|
||||
}
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
clicon_err(OE_YANG, 0, "Yang spec not set");
|
||||
goto done;
|
||||
|
|
@ -257,8 +259,8 @@ startup_common(clicon_handle h,
|
|||
xml_free(xret);
|
||||
if (xt)
|
||||
xml_free(xt);
|
||||
if (msd)
|
||||
modstate_diff_free(msd);
|
||||
if (msdiff)
|
||||
modstate_diff_free(msdiff);
|
||||
return retval;
|
||||
fail:
|
||||
retval = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue