datastore upgrade bugs
This commit is contained in:
parent
cdd22bc33d
commit
fa257ebb88
4 changed files with 24 additions and 12 deletions
|
|
@ -71,11 +71,15 @@ static int _reset = 0;
|
|||
*/
|
||||
static int _state = 0;
|
||||
|
||||
/*! Variable to control upgrade callbacks.
|
||||
/*! Variable to control module-specific upgrade callbacks.
|
||||
* If set, call test-case for upgrading ietf-interfaces, otherwise call
|
||||
* auto-upgrade
|
||||
*/
|
||||
static int _upgrade = 0;
|
||||
static int _module_upgrade = 0;
|
||||
|
||||
/*! Variable to control general-purpose upgrade callbacks.
|
||||
*/
|
||||
static int _general_upgrade = 0;
|
||||
|
||||
/*! Variable to control transaction logging (for debug)
|
||||
* If set, call syslog for every transaction callback
|
||||
|
|
@ -456,9 +460,11 @@ example_upgrade(clicon_handle h,
|
|||
int i;
|
||||
const char **pp;
|
||||
|
||||
if (_general_upgrade == 0)
|
||||
goto ok;
|
||||
if (strcmp(db, "startup") != 0) /* skip other than startup datastore */
|
||||
goto ok;
|
||||
if (msd->md_status) /* skip if there is proper module-state in datastore */
|
||||
if (msd && msd->md_status) /* skip if there is proper module-state in datastore */
|
||||
goto ok;
|
||||
yspec = clicon_dbspec_yang(h); /* Get all yangs */
|
||||
/* Get canonical namespaces for using "normalized" prefixes */
|
||||
|
|
@ -793,7 +799,7 @@ static clixon_plugin_api api = {
|
|||
.ca_trans_revert=main_revert, /* trans revert */
|
||||
.ca_trans_end=main_end, /* trans end */
|
||||
.ca_trans_abort=main_abort, /* trans abort */
|
||||
.ca_datastore_upgrade=example_upgrade /* gneral-purpose upgrade. */
|
||||
.ca_datastore_upgrade=example_upgrade /* general-purpose upgrade. */
|
||||
};
|
||||
|
||||
/*! Backend plugin initialization
|
||||
|
|
@ -818,7 +824,7 @@ clixon_plugin_init(clicon_handle h)
|
|||
goto done;
|
||||
opterr = 0;
|
||||
optind = 1;
|
||||
while ((c = getopt(argc, argv, "rsut:")) != -1)
|
||||
while ((c = getopt(argc, argv, "rsuUt:")) != -1)
|
||||
switch (c) {
|
||||
case 'r':
|
||||
_reset = 1;
|
||||
|
|
@ -826,8 +832,11 @@ clixon_plugin_init(clicon_handle h)
|
|||
case 's':
|
||||
_state = 1;
|
||||
break;
|
||||
case 'u':
|
||||
_upgrade = 1;
|
||||
case 'u': /* module-specific upgrade */
|
||||
_module_upgrade = 1;
|
||||
break;
|
||||
case 'U': /* general-purpose upgrade */
|
||||
_general_upgrade = 1;
|
||||
break;
|
||||
case 't': /* transaction log */
|
||||
_transaction_log = 1;
|
||||
|
|
@ -885,7 +894,7 @@ clixon_plugin_init(clicon_handle h)
|
|||
/* Upgrade callback: if you start the backend with -- -u you will get the
|
||||
* test interface example. Otherwise the auto-upgrade feature is enabled.
|
||||
*/
|
||||
if (_upgrade){
|
||||
if (_module_upgrade == 1){
|
||||
if (upgrade_callback_register(h, upgrade_2016, "urn:example:interfaces", 20140508, 20160101, NULL) < 0)
|
||||
goto done;
|
||||
if (upgrade_callback_register(h, upgrade_2018, "urn:example:interfaces", 20160101, 20180220, NULL) < 0)
|
||||
|
|
|
|||
|
|
@ -265,7 +265,6 @@ text_read_modstate(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
}
|
||||
continue; /* ignore other tags, such as module-set-id */
|
||||
if (strcmp(xml_name(xm), "module"))
|
||||
continue; /* ignore other tags, such as module-set-id */
|
||||
if ((name = xml_find_body(xm, "name")) == NULL)
|
||||
|
|
|
|||
|
|
@ -373,6 +373,10 @@ xp_eval_step(xp_ctx *xc0,
|
|||
if (cxvec_append(x, &xc->xc_nodeset, &xc->xc_size) < 0)
|
||||
goto done;
|
||||
}
|
||||
if (vec){
|
||||
free(vec);
|
||||
vec = NULL;
|
||||
}
|
||||
break;
|
||||
case A_DESCENDANT:
|
||||
for (i=0; i<xc->xc_size; i++){
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ EOF
|
|||
)
|
||||
|
||||
testrun(){
|
||||
new "test params: -f $cfg"
|
||||
new "test params: -f $cfg -- -U"
|
||||
# Bring your own backend
|
||||
if [ $BE -ne 0 ]; then
|
||||
# kill old backend (if any)
|
||||
|
|
@ -90,8 +90,8 @@ testrun(){
|
|||
if [ $? -ne 0 ]; then
|
||||
err
|
||||
fi
|
||||
new "start backend -s startup -f $cfg"
|
||||
start_backend -s startup -f $cfg
|
||||
new "start backend -s startup -f $cfg -- -U"
|
||||
start_backend -s startup -f $cfg -- -U
|
||||
|
||||
new "waiting"
|
||||
wait_backend
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue