datastore repair test branch
This commit is contained in:
parent
76a4d31c4b
commit
3748eefb8e
7 changed files with 265 additions and 11 deletions
|
|
@ -159,6 +159,16 @@ typedef int (trans_cb_t)(clicon_handle h, transaction_data td);
|
|||
*/
|
||||
typedef char *(cli_prompthook_t)(clicon_handle, char *mode);
|
||||
|
||||
/*! Datastore repair callback
|
||||
* Gets called on startup after initial XML parsing, but before upgrading and before validation
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] db Name of datastore, eg "running"
|
||||
* @param[in] xt XML tree. Repair this "in place"
|
||||
* @retval -1 Error
|
||||
* @retval 0 OK
|
||||
*/
|
||||
typedef int (xmldb_repair_t)(clicon_handle h, char *db, cxobj *xt);
|
||||
|
||||
/*! Startup status for use in startup-callback
|
||||
* Note that for STARTUP_ERR and _INVALID, running runs in failsafe mode
|
||||
* and startup contains the erroneous or invalid database.
|
||||
|
|
@ -206,8 +216,9 @@ struct clixon_plugin_api{
|
|||
trans_cb_t *cb_trans_revert; /* Transaction revert */
|
||||
trans_cb_t *cb_trans_end; /* Transaction completed */
|
||||
trans_cb_t *cb_trans_abort; /* Transaction aborted */
|
||||
} cau_backend;
|
||||
xmldb_repair_t *cb_xmldb_repair; /* Repair datastore on load */
|
||||
|
||||
} cau_backend;
|
||||
} u;
|
||||
};
|
||||
/* Access fields */
|
||||
|
|
@ -224,6 +235,8 @@ struct clixon_plugin_api{
|
|||
#define ca_trans_revert u.cau_backend.cb_trans_revert
|
||||
#define ca_trans_end u.cau_backend.cb_trans_end
|
||||
#define ca_trans_abort u.cau_backend.cb_trans_abort
|
||||
#define ca_xmldb_repair u.cau_backend.cb_xmldb_repair
|
||||
|
||||
|
||||
/*
|
||||
* Macros
|
||||
|
|
@ -271,6 +284,8 @@ int clixon_plugin_auth(clicon_handle h, void *arg);
|
|||
|
||||
int clixon_plugin_extension(clicon_handle h, yang_stmt *yext, yang_stmt *ys);
|
||||
|
||||
int clixon_plugin_xmldb_repair(clicon_handle h, char *db, cxobj *xt);
|
||||
|
||||
/* rpc callback API */
|
||||
int rpc_callback_register(clicon_handle h, clicon_rpc_cb cb, void *arg, char *namespace, char *name);
|
||||
int rpc_callback_delete_all(clicon_handle h);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ int xml_diff(yang_stmt *yspec, cxobj *x0, cxobj *x1,
|
|||
cxobj ***changed_x0, cxobj ***changed_x1, size_t *changedlen);
|
||||
int xml_tree_prune_flagged_sub(cxobj *xt, int flag, int test, int *upmark);
|
||||
int xml_tree_prune_flagged(cxobj *xt, int flag, int test);
|
||||
int add_namespace(cxobj *x1, cxobj *x1p, char *prefix1, char *namespace);
|
||||
int xml_default(cxobj *x, void *arg);
|
||||
int xml_sanity(cxobj *x, void *arg);
|
||||
int xml_non_config_data(cxobj *xt, void *arg);
|
||||
|
|
|
|||
|
|
@ -467,6 +467,33 @@ clixon_plugin_extension(clicon_handle h,
|
|||
}
|
||||
return retval;
|
||||
}
|
||||
/*! Call plugin module repair in all plugins
|
||||
*
|
||||
* Repair datastore on load before or as an alternative to the upgrading mechanism
|
||||
* @param[in] h Clicon handle
|
||||
* Call plugin start functions (if defined)
|
||||
* @note Start functions used to have argc/argv. Use clicon_argv_get() instead
|
||||
*/
|
||||
int
|
||||
clixon_plugin_xmldb_repair(clicon_handle h,
|
||||
char *db,
|
||||
cxobj *xt)
|
||||
{
|
||||
clixon_plugin *cp;
|
||||
int i;
|
||||
xmldb_repair_t *repairfn;
|
||||
|
||||
for (i = 0; i < _clixon_nplugins; i++) {
|
||||
cp = &_clixon_plugins[i];
|
||||
if ((repairfn = cp->cp_api.ca_xmldb_repair) == NULL)
|
||||
continue;
|
||||
if (repairfn(h, db, xt) < 0) {
|
||||
clicon_debug(1, "%s() failed", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------
|
||||
* RPC callbacks for both client/frontend and backend plugins.
|
||||
|
|
|
|||
|
|
@ -708,7 +708,7 @@ xml_tree_prune_flagged(cxobj *xt,
|
|||
|
||||
/*! Add prefix:namespace pair to xml node, set cache, prefix, etc
|
||||
*/
|
||||
static int
|
||||
int
|
||||
add_namespace(cxobj *x1, /* target */
|
||||
cxobj *x1p,
|
||||
char *prefix1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue