incremental debuggung
This commit is contained in:
parent
6d8acdea9f
commit
6169ea6bed
17 changed files with 203 additions and 64 deletions
|
|
@ -502,6 +502,44 @@ from_client_load(clicon_handle h,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! Internal message: Copy file from file1 to file2
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] s Socket where request arrived, and where replies are sent
|
||||
* @param[in] pid Unix process id
|
||||
* @param[in] msg Message
|
||||
* @param[in] label Memory chunk
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error. Send error message back to client.
|
||||
*/
|
||||
static int
|
||||
from_client_copy(clicon_handle h,
|
||||
int s,
|
||||
int pid,
|
||||
struct clicon_msg *msg,
|
||||
const char *label)
|
||||
{
|
||||
char *db1;
|
||||
char *db2;
|
||||
int retval = -1;
|
||||
|
||||
if (clicon_msg_copy_decode(msg,
|
||||
&db1,
|
||||
&db2,
|
||||
label) < 0){
|
||||
send_msg_err(s, clicon_errno, clicon_suberrno,
|
||||
clicon_err_reason);
|
||||
goto done;
|
||||
}
|
||||
if (xmldb_copy(h, db1, db2) < 0)
|
||||
goto done;
|
||||
if (send_msg_ok(s) < 0)
|
||||
goto done;
|
||||
retval = 0;
|
||||
done:
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*! Internal message: Kill session (Kill the process)
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] s Client socket where request arrived, and where replies are sent
|
||||
|
|
@ -736,6 +774,10 @@ from_client(int s, void* arg)
|
|||
if (from_client_load(h, ce->ce_s, ce->ce_pid, msg, __FUNCTION__) < 0)
|
||||
goto done;
|
||||
break;
|
||||
case CLICON_MSG_COPY:
|
||||
if (from_client_copy(h, ce->ce_s, ce->ce_pid, msg, __FUNCTION__) < 0)
|
||||
goto done;
|
||||
break;
|
||||
case CLICON_MSG_KILL:
|
||||
if (from_client_kill(h, ce->ce_s, msg, __FUNCTION__) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -542,13 +542,11 @@ main(int argc, char **argv)
|
|||
if (rundb_main(h, app_config_file) < 0)
|
||||
goto done;
|
||||
|
||||
/* Initiate the shared candidate. Maybe we should not do this? */
|
||||
/* Initiate the shared candidate. Maybe we should not do this?
|
||||
* Too strict access
|
||||
*/
|
||||
if (xmldb_copy(h, "running", "candidate") < 0)
|
||||
goto done;
|
||||
#ifdef OBSOLETE
|
||||
/* XXX Hack for now. Change mode so that we all can write. Security issue*/
|
||||
chmod(candidate_db, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
|
||||
#endif
|
||||
if (once)
|
||||
goto done;
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ init_candidate_db(clicon_handle h)
|
|||
goto err;
|
||||
}
|
||||
if (xmldb_exists(h, "candidate") != 1)
|
||||
if (xmldb_copy(h, "running", "candidate") < 0)
|
||||
if (clicon_rpc_copy(h, "running", "candidate") < 0)
|
||||
goto err;
|
||||
retval = 0;
|
||||
err:
|
||||
|
|
@ -648,7 +648,7 @@ compare_dbs(clicon_handle h, cvec *cvv, cg_var *arg)
|
|||
}
|
||||
|
||||
|
||||
/*! Modify xml database frm a callback using xml key format strings
|
||||
/*! Modify xml database from a callback using xml key format strings
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] cvv Vector of cli string and instantiated variables
|
||||
* @param[in] arg An xml key format string, eg /aaa/%s
|
||||
|
|
@ -676,18 +676,6 @@ cli_dbxml(clicon_handle h,
|
|||
cg_var *cval;
|
||||
char *val = NULL;
|
||||
|
||||
/*
|
||||
* clicon_rpc_xmlput(h, db, MERGE,"<interfaces><interface><name>eth0</name><type>hej</type></interface><interfaces>");
|
||||
* Wanted database content:
|
||||
* /interfaces
|
||||
* /interfaces/interface/eth0
|
||||
* /interfaces/interface/eth0/name eth0
|
||||
* /interfaces/interface/eth0/type hej
|
||||
* Algorithm alt1:
|
||||
* arg = "<interfaces><interface><name>$1</name><type>$2</type></interface><interfaces>"
|
||||
* Where is arg computed? In eg yang2cli_leaf, otherwise in yang_parse,..
|
||||
* Create string using cbuf and save that.
|
||||
*/
|
||||
xkfmt = cv_string_get(arg);
|
||||
if (xmlkeyfmt2key(xkfmt, cvv, &xk) < 0)
|
||||
goto done;
|
||||
|
|
@ -944,22 +932,21 @@ delete_all(clicon_handle h, cvec *cvv, cg_var *arg)
|
|||
clicon_err(OE_PLUGIN, 0, "No such db name: %s", dbstr);
|
||||
goto done;
|
||||
}
|
||||
if (xmldb_delete(h, dbstr) < 0)
|
||||
goto done;
|
||||
if (xmldb_init(h, dbstr) < 0)
|
||||
goto done;
|
||||
if (clicon_rpc_change(h, "candidate",
|
||||
OP_REMOVE,
|
||||
"/", "") < 0)
|
||||
goto done;
|
||||
retval = 0;
|
||||
done:
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*! Discard all changes in candidate and replace with running
|
||||
* Utility function used by cligen spec file
|
||||
*/
|
||||
int
|
||||
discard_changes(clicon_handle h, cvec *cvv, cg_var *arg)
|
||||
{
|
||||
return xmldb_copy(h, "running", "candidate");
|
||||
return clicon_rpc_copy(h, "running", "candidate");
|
||||
}
|
||||
|
||||
/*! Generic function for showing configurations.
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ main(int argc, char **argv)
|
|||
}
|
||||
if (dumpdb){
|
||||
/* Here db must be local file-path */
|
||||
if (xmldb_dump(stdout, db, matchkey)) {
|
||||
if (xmldb_dump_local(stdout, db, matchkey)) {
|
||||
fprintf(stderr, "Match error\n");
|
||||
goto done;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -505,7 +505,7 @@ netconf_copy_config(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
#endif
|
||||
if (xmldb_copy(h, source, target) < 0){
|
||||
if (clicon_rpc_copy(h, source, target) < 0){
|
||||
netconf_create_rpc_error(cb_err, xorig,
|
||||
"operation-failed",
|
||||
"protocol", "error",
|
||||
|
|
@ -556,7 +556,9 @@ netconf_delete_config(clicon_handle h,
|
|||
"<bad-element>target</bad-element>");
|
||||
goto done;
|
||||
}
|
||||
if (xmldb_delete(h, target) < 0){
|
||||
if (clicon_rpc_change(h, "candidate",
|
||||
OP_REMOVE,
|
||||
"/", "") < 0){
|
||||
netconf_create_rpc_error(cb_err, xorig,
|
||||
"operation-failed",
|
||||
"protocol", "error",
|
||||
|
|
@ -750,7 +752,7 @@ netconf_discard_changes(clicon_handle h,
|
|||
{
|
||||
int retval = -1;
|
||||
|
||||
if (xmldb_copy(h, "running", "candidate") < 0){
|
||||
if (clicon_rpc_copy(h, "running", "candidate") < 0){
|
||||
netconf_create_rpc_error(cb_err, xorig,
|
||||
"operation-failed",
|
||||
"protocol", "error",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue