C-API: Added cli_process_control(), added uid to cli_process_control()
This commit is contained in:
parent
bd6a67f1d9
commit
080eef0278
12 changed files with 103 additions and 20 deletions
|
|
@ -1626,3 +1626,64 @@ cvec_append(cvec *cvv0,
|
|||
}
|
||||
return cvv2;
|
||||
}
|
||||
|
||||
/*! Process control as defined by clixon-lib API
|
||||
*
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] cvv Not used
|
||||
* @param[in] arg Two strings: <process name> <process operation>
|
||||
* @code
|
||||
* actions-daemon("Actions daemon operations") start,
|
||||
* cli_process_control("Action process", "start");
|
||||
* @endcode
|
||||
*/
|
||||
int
|
||||
cli_process_control(clicon_handle h,
|
||||
cvec *cvv,
|
||||
cvec *argv)
|
||||
{
|
||||
int retval = -1;
|
||||
char *name;
|
||||
char *opstr;
|
||||
cbuf *cb = NULL;
|
||||
cxobj *xret = NULL;
|
||||
cxobj *xerr;
|
||||
|
||||
if (cvec_len(argv) != 2){
|
||||
clicon_err(OE_PLUGIN, EINVAL, "Requires two element: process name and operation");
|
||||
goto done;
|
||||
}
|
||||
name = cv_string_get(cvec_i(argv, 0));
|
||||
opstr = cv_string_get(cvec_i(argv, 1));
|
||||
if (clixon_process_op_str2int(opstr) == -1){
|
||||
clicon_err(OE_UNIX, 0, "No such process op: %s", opstr);
|
||||
goto done;
|
||||
}
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cb, "<rpc xmlns=\"%s\"", NETCONF_BASE_NAMESPACE);
|
||||
cprintf(cb, " %s", NETCONF_MESSAGE_ID_ATTR);
|
||||
cprintf(cb, ">");
|
||||
cprintf(cb, "<process-control xmlns=\"%s\">", CLIXON_LIB_NS);
|
||||
cprintf(cb, "<name>%s</name>", name);
|
||||
cprintf(cb, "<operation>%s</operation>", opstr);
|
||||
cprintf(cb, "</process-control>");
|
||||
cprintf(cb, "</rpc>");
|
||||
if (clicon_rpc_netconf(h, cbuf_get(cb), &xret, NULL) < 0)
|
||||
goto done;
|
||||
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "Get configuration", NULL);
|
||||
goto done;
|
||||
}
|
||||
if (clixon_xml2file(stdout, xml_child_i(xret, 0), 0, 1, NULL, cligen_output, 0, 1) < 0)
|
||||
goto done;
|
||||
retval = 0;
|
||||
done:
|
||||
if (xret)
|
||||
xml_free(xret);
|
||||
if (cb)
|
||||
cbuf_free(cb);
|
||||
return retval;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1515,7 +1515,6 @@ cli_show_statistics(clicon_handle h,
|
|||
if (clixon_xml2file(stdout, xml_child_i(xret, 0), 0, 1, NULL, cligen_output, 0, 1) < 0)
|
||||
goto done;
|
||||
fprintf(stdout, "CLI:\n");
|
||||
|
||||
retval = 0;
|
||||
done:
|
||||
if (xret)
|
||||
|
|
|
|||
|
|
@ -80,8 +80,6 @@ int cli_notification_register(clicon_handle h, char *stream, enum format_enum fo
|
|||
char *filter, int status,
|
||||
int (*fn)(int, void*), void *arg);
|
||||
|
||||
/* cli_common.c: CLIgen new vector callbacks */
|
||||
|
||||
int mtpoint_paths(yang_stmt *yspec0, char *mtpoint, char *api_path_fmt1, char **api_path_fmt01);
|
||||
int dbxml_body(cxobj *xbot, cvec *cvv);
|
||||
int identityref_add_ns(cxobj *x, void *arg);
|
||||
|
|
@ -113,6 +111,7 @@ int cli_unlock(clicon_handle h, cvec *cvv, cvec *argv);
|
|||
int cli_copy_config(clicon_handle h, cvec *cvv, cvec *argv);
|
||||
int cli_help(clicon_handle h, cvec *vars, cvec *argv);
|
||||
cvec *cvec_append(cvec *cvv0, cvec *cvv1);
|
||||
int cli_process_control(clicon_handle h, cvec *vars, cvec *argv);
|
||||
|
||||
/* In cli_show.c */
|
||||
int expand_dbvar(void *h, char *name, cvec *cvv, cvec *argv,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue