- Rewrote process control to simpler state model: stopped/running/exiting
- Stricter CLICON_BACKEND_RESTCONF_PROCESS : - if set, restconf daemon queries backend for its config - if not set, restconf daemon reads its config from main config file
This commit is contained in:
parent
9f5176adf5
commit
953326d39f
11 changed files with 517 additions and 310 deletions
|
|
@ -238,12 +238,14 @@ restconf_pseudo_process_commit(clicon_handle h,
|
|||
{
|
||||
int retval = -1;
|
||||
cxobj *xtarget;
|
||||
cxobj *xsource;
|
||||
cxobj *cx;
|
||||
int enabled = 0;
|
||||
cxobj *xb;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
xtarget = transaction_target(td);
|
||||
xsource = transaction_src(td);
|
||||
if (xpath_first(xtarget, NULL, "/restconf[enable='true']") != NULL)
|
||||
enabled++;
|
||||
/* Get debug flag of restconf config, set the restconf start -D daemon flag according
|
||||
|
|
@ -271,10 +273,18 @@ restconf_pseudo_process_commit(clicon_handle h,
|
|||
/* A restart can terminate a restconf connection (cut the tree limb you are sitting on)
|
||||
* Specifically, the socket is terminated where the reply is sent, which will
|
||||
* cause the curl to fail.
|
||||
* Note that it should really be a START if the process is stopped, but the
|
||||
* commit code need not know any of that
|
||||
*/
|
||||
if (clixon_process_operation(h, RESTCONF_PROCESS, PROC_OP_RESTART, 0) < 0)
|
||||
goto done;
|
||||
}
|
||||
else if ((cx = xpath_first(xsource, NULL, "/restconf")) != NULL &&
|
||||
xml_flag(cx, XML_FLAG_CHANGE|XML_FLAG_DEL)){
|
||||
/* Or something deleted */
|
||||
if (clixon_process_operation(h, RESTCONF_PROCESS, PROC_OP_RESTART, 0) < 0)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
retval = 0;
|
||||
|
|
|
|||
|
|
@ -431,15 +431,17 @@ main(int argc,
|
|||
if (clixon_plugin_start_all(h) < 0)
|
||||
goto done;
|
||||
|
||||
/* First try to get restconf config from local config-file */
|
||||
if ((xrestconf1 = clicon_conf_restconf(h)) != NULL){
|
||||
if ((ret = restconf_config_init(h, xrestconf1)) < 0)
|
||||
goto done;
|
||||
if (ret == 1)
|
||||
configure_done = 1;
|
||||
if (clicon_option_bool(h, "CLICON_BACKEND_RESTCONF_PROCESS") == 0){
|
||||
/* If not read from backend, try to get restconf config from local config-file */
|
||||
if ((xrestconf1 = clicon_conf_restconf(h)) != NULL){
|
||||
if ((ret = restconf_config_init(h, xrestconf1)) < 0)
|
||||
goto done;
|
||||
if (ret == 1)
|
||||
configure_done = 1;
|
||||
}
|
||||
}
|
||||
/* If no local config, or it is disabled, try to query backend of config. */
|
||||
if (!configure_done){
|
||||
else {
|
||||
/* Loop to wait for backend starting, try again if not done */
|
||||
while (1){
|
||||
if (clicon_hello_req(h, &id) < 0){
|
||||
|
|
|
|||
|
|
@ -1610,24 +1610,25 @@ restconf_clixon_init(clicon_handle h,
|
|||
goto done;
|
||||
if (clicon_nsctx_global_set(h, nsctx_global) < 0)
|
||||
goto done;
|
||||
|
||||
/* First try to get restconf config from local config-file */
|
||||
ret = 0;
|
||||
if ((xrestconf = clicon_conf_restconf(h)) != NULL){
|
||||
/*! Basic config init, set auth-type, pretty, etc ret 0 means disabled */
|
||||
if ((ret = restconf_config_init(h, xrestconf)) < 0)
|
||||
goto done;
|
||||
/* ret == 1 means this config is OK */
|
||||
if (ret == 0){
|
||||
xrestconf = NULL; /* Dont free since it is part of conf tree */
|
||||
}
|
||||
else
|
||||
if ((*xrestconfp = xml_dup(xrestconf)) == NULL)
|
||||
if (clicon_option_bool(h, "CLICON_BACKEND_RESTCONF_PROCESS") == 0){
|
||||
/* If not read from backend, try to get restconf config from local config-file */
|
||||
if ((xrestconf = clicon_conf_restconf(h)) != NULL){
|
||||
/*! Basic config init, set auth-type, pretty, etc ret 0 means disabled */
|
||||
if ((ret = restconf_config_init(h, xrestconf)) < 0)
|
||||
goto done;
|
||||
/* ret == 1 means this config is OK */
|
||||
if (ret == 0){
|
||||
xrestconf = NULL; /* Dont free since it is part of conf tree */
|
||||
}
|
||||
else
|
||||
if ((*xrestconfp = xml_dup(xrestconf)) == NULL)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
/* If no local config, or it is disabled, try to query backend of config. */
|
||||
if (ret == 0){
|
||||
assert(*xrestconfp == NULL);
|
||||
/* If no local config, or it is disabled, try to query backend of config.
|
||||
*/
|
||||
else {
|
||||
if ((ret = restconf_clixon_backend(h, xrestconfp)) < 0)
|
||||
goto done;
|
||||
if (ret == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue