* xml-stats moved from clixon-config.yang as state data to an rpc datastatsin clixon-lib.yang
* Two new plugin callbacks added * ca_daemon: Called just after a server has "daemonized", ie put in background. * ca_trans_commit_done: Called when all plugin commits have been done.
This commit is contained in:
parent
65806f1ef2
commit
1c99bd6a9b
20 changed files with 290 additions and 112 deletions
|
|
@ -46,8 +46,10 @@
|
|||
/*! Clixon configuration namespace
|
||||
* Probably should be defined somewhere else or extracted from yang
|
||||
* @see clixon-config.yang
|
||||
* @see clixon-lib.yang
|
||||
*/
|
||||
#define CLIXON_CONF_NS "http://clicon.org/config"
|
||||
#define CLIXON_LIB_NS "http://clicon.org/lib"
|
||||
|
||||
/*
|
||||
* Types
|
||||
|
|
|
|||
|
|
@ -105,6 +105,12 @@ typedef int (*clicon_upgrade_cb)(
|
|||
*/
|
||||
typedef int (plgstart_t)(clicon_handle); /* Plugin start */
|
||||
|
||||
/* Called just after a server has "daemonized", ie put in background.
|
||||
* Backend: If daemon privileges are dropped this callback is called *before* privileges are dropped.
|
||||
* If daemon is started in foreground (-F) it is still called.
|
||||
*/
|
||||
typedef int (plgdaemon_t)(clicon_handle); /* Plugin daemonized */
|
||||
|
||||
/* Called just before plugin unloaded.
|
||||
*/
|
||||
typedef int (plgexit_t)(clicon_handle); /* Plugin exit */
|
||||
|
|
@ -211,12 +217,14 @@ struct clixon_plugin_api{
|
|||
struct { /* netconf-specific */
|
||||
} cau_netconf;
|
||||
struct { /* backend-specific */
|
||||
plgdaemon_t *cb_daemon; /* Plugin daemonized */
|
||||
plgreset_t *cb_reset; /* Reset system status */
|
||||
plgstatedata_t *cb_statedata; /* Get state data from plugin (backend only) */
|
||||
trans_cb_t *cb_trans_begin; /* Transaction start */
|
||||
trans_cb_t *cb_trans_validate; /* Transaction validation */
|
||||
trans_cb_t *cb_trans_complete; /* Transaction validation complete */
|
||||
trans_cb_t *cb_trans_commit; /* Transaction commit */
|
||||
trans_cb_t *cb_trans_commit_done; /* Transaction when commit done */
|
||||
trans_cb_t *cb_trans_revert; /* Transaction revert */
|
||||
trans_cb_t *cb_trans_end; /* Transaction completed */
|
||||
trans_cb_t *cb_trans_abort; /* Transaction aborted */
|
||||
|
|
@ -229,12 +237,14 @@ struct clixon_plugin_api{
|
|||
#define ca_suspend u.cau_cli.ci_suspend
|
||||
#define ca_interrupt u.cau_cli.ci_interrupt
|
||||
#define ca_auth u.cau_restconf.cr_auth
|
||||
#define ca_daemon u.cau_backend.cb_daemon
|
||||
#define ca_reset u.cau_backend.cb_reset
|
||||
#define ca_statedata u.cau_backend.cb_statedata
|
||||
#define ca_trans_begin u.cau_backend.cb_trans_begin
|
||||
#define ca_trans_validate u.cau_backend.cb_trans_validate
|
||||
#define ca_trans_complete u.cau_backend.cb_trans_complete
|
||||
#define ca_trans_commit u.cau_backend.cb_trans_commit
|
||||
#define ca_trans_commit_done u.cau_backend.cb_trans_commit_done
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ typedef struct clixon_xml_vec clixon_xvec; /* struct defined in clicon_xml_vec.c
|
|||
*/
|
||||
char *xml_type2str(enum cxobj_type type);
|
||||
int xml_stats_global(uint64_t *nr);
|
||||
size_t xml_stats(cxobj *xt, uint64_t *nrp, size_t *szp);
|
||||
int xml_stats(cxobj *xt, uint64_t *nrp, size_t *szp);
|
||||
char *xml_name(cxobj *xn);
|
||||
int xml_name_set(cxobj *xn, char *name);
|
||||
char *xml_prefix(cxobj *xn);
|
||||
|
|
|
|||
|
|
@ -471,7 +471,7 @@ clixon_plugin_extension(clicon_handle h,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! Call plugingeneral-purpose datastore upgrade in all plugins
|
||||
/*! Call plugin general-purpose datastore upgrade in all plugins
|
||||
*
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] db Name of datastore, eg "running", "startup" or "tmp"
|
||||
|
|
|
|||
|
|
@ -1011,7 +1011,10 @@ clicon_rpc_debug(clicon_handle h,
|
|||
goto done;
|
||||
username = clicon_username_get(h);
|
||||
if ((msg = clicon_msg_encode(session_id,
|
||||
"<rpc username=\"%s\"><debug xmlns=\"http://clicon.org/lib\"><level>%d</level></debug></rpc>", username?username:"", level)) == NULL)
|
||||
"<rpc username=\"%s\"><debug xmlns=\"%s\"><level>%d</level></debug></rpc>",
|
||||
username?username:"",
|
||||
CLIXON_LIB_NS,
|
||||
level)) == NULL)
|
||||
goto done;
|
||||
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -284,18 +284,24 @@ xml_stats_one(cxobj *x,
|
|||
}
|
||||
|
||||
/*! Return statistics of an XML tree recursively
|
||||
* @param[in] x XML object
|
||||
* @param[in] xt XML object
|
||||
* @param[out] szp Size of this XML obj recursively
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
size_t
|
||||
int
|
||||
xml_stats(cxobj *xt,
|
||||
uint64_t *nrp,
|
||||
size_t *szp)
|
||||
{
|
||||
int retval = -1;
|
||||
size_t sz = 0;
|
||||
cxobj *xc;
|
||||
|
||||
if (xt == NULL){
|
||||
clicon_err(OE_XML, EINVAL, "xml node is NULL");
|
||||
goto done;
|
||||
}
|
||||
*nrp += 1;
|
||||
xml_stats_one(xt, &sz);
|
||||
if (szp)
|
||||
|
|
@ -308,7 +314,9 @@ xml_stats(cxobj *xt,
|
|||
*szp += sz;
|
||||
}
|
||||
clicon_debug(1, "%s %zu", __FUNCTION__, *szp);
|
||||
return 0;
|
||||
retval = 0;
|
||||
done:
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue