mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Add the first iocage sysadm API call
REST Request:
-------------------------------
PUT /sysadm/iocage
{
"action" : "listjails"
}
REST Response:
-------------------------------
{
"args": {
"listjails": {
"611c89ae-c43c-11e5-9602-54ee75595566": {
"boot": "off",
"jid": "-",
"state": "down",
"tag": "testjail",
"type": "basejail"
}
}
}
}
WebSocket Request:
-------------------------------
{
"args" : {
"action" : "listjails"
},
"name" : "iocage",
"id" : "fooid",
"namespace" : "sysadm"
}
WebSocket Response:
-------------------------------
{
"args": {
"listjails": {
"611c89ae-c43c-11e5-9602-54ee75595566": {
"boot": "off",
"jid": "-",
"state": "down",
"tag": "testjail",
"type": "basejail"
}
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
//sysadm library interface classes
|
||||
#include "sysadm-general.h"
|
||||
#include "sysadm-iocage.h"
|
||||
#include "sysadm-lifepreserver.h"
|
||||
#include "sysadm-network.h"
|
||||
#include "sysadm-systeminfo.h"
|
||||
@@ -73,14 +74,16 @@ RestOutputStruct::ExitCode WebSocket::EvaluateBackendRequest(const RestInputStru
|
||||
//Go through and forward this request to the appropriate sub-system
|
||||
if(namesp=="rpc" && name=="query"){
|
||||
return AvailableSubsystems(IN.fullaccess, out);
|
||||
}else if(namesp=="rpc" && name=="syscache"){
|
||||
return EvaluateSyscacheRequest(IN.args, out);
|
||||
}else if(namesp=="rpc" && name=="dispatcher"){
|
||||
return EvaluateDispatcherRequest(IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="network"){
|
||||
return EvaluateSysadmNetworkRequest(IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="iocage"){
|
||||
return EvaluateSysadmIocageRequest(IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="lifepreserver"){
|
||||
return EvaluateSysadmLifePreserverRequest(IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="network"){
|
||||
return EvaluateSysadmNetworkRequest(IN.args, out);
|
||||
}else if(namesp=="rpc" && name=="syscache"){
|
||||
return EvaluateSyscacheRequest(IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="systeminfo"){
|
||||
return EvaluateSysadmSystemInfoRequest(IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="update"){
|
||||
@@ -332,3 +335,27 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmUpdateRequest(const QJsonVal
|
||||
}
|
||||
return RestOutputStruct::OK;
|
||||
}
|
||||
|
||||
//==== SYSADM -- iocage ====
|
||||
RestOutputStruct::ExitCode WebSocket::EvaluateSysadmIocageRequest(const QJsonValue in_args, QJsonObject *out){
|
||||
if(in_args.isObject()){
|
||||
QStringList keys = in_args.toObject().keys();
|
||||
bool ok = false;
|
||||
if(keys.contains("action")){
|
||||
QString act = JsonValueToString(in_args.toObject().value("action"));
|
||||
if(act=="listjails"){
|
||||
ok = true;
|
||||
out->insert("listjails", sysadm::Iocage::listJails());
|
||||
}
|
||||
|
||||
} //end of "action" key usage
|
||||
|
||||
//If nothing done - return the proper code
|
||||
if(!ok){
|
||||
return RestOutputStruct::BADREQUEST;
|
||||
}
|
||||
}else{ // if(in_args.isArray()){
|
||||
return RestOutputStruct::BADREQUEST;
|
||||
}
|
||||
return RestOutputStruct::OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user