mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 18:20:23 +00:00
Add a new API call: rpc/dispatcher -> "action":"kill"
This allows a user with full access to cancel pending/running jobs within the dispatcher system.
Required arguments: "job_id" : <ID string> or [<ID1>, <ID2>, etc..]
REST Request:
-------------------------------
PUT /rpc/dispatcher
{
"action" : "kill",
"job_id" : "sysadm_pkg_install-{9c079421-ace9-4b6e-8870-d023b48f4c49}"
}
WebSocket Request:
-------------------------------
{
"args" : {
"action" : "kill",
"job_id" : "sysadm_pkg_install-{9c079421-ace9-4b6e-8870-d023b48f4c49}"
},
"namespace" : "rpc",
"name" : "dispatcher",
"id" : "fooid"
}
Response:
-------------------------------
{
"args": {
"killed": {
"jobs": ["sysadm_pkg_install-{9c079421-ace9-4b6e-8870-d023b48f4c49}"]
}
},
"id": "fooid",
"name": "response",
"namespace": "rpc"
}
This commit is contained in:
@@ -290,6 +290,14 @@ RestOutputStruct::ExitCode WebSocket::EvaluateDispatcherRequest(bool allaccess,
|
||||
}else if(act=="list"){
|
||||
QJsonObject info = DISPATCHER->listJobs();
|
||||
out->insert("jobs", info);
|
||||
}else if(act=="kill" && in_args.toObject().contains("job_id") ){
|
||||
if(!allaccess){ return RestOutputStruct::FORBIDDEN; } //this user does not have permission to modify jobs
|
||||
QStringList ids;
|
||||
QJsonValue val = in_args.toObject().value("job_id");
|
||||
if(val.isArray()){ ids = JsonArrayToStringList(val.toArray()); }
|
||||
else if(val.isString()){ ids << val.toString(); }
|
||||
else{ return RestOutputStruct::BADREQUEST; }
|
||||
out->insert("killed", DISPATCHER->killJobs(ids));
|
||||
}else{
|
||||
return RestOutputStruct::BADREQUEST;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user