mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 18:20:23 +00:00
Add new API class and call for 'beadm', with the initial listbes
API call
REST Request:
-------------------------------
PUT /sysadm/beadm
{
"action" : "listbes"
}
WebSocket Request:
-------------------------------
{
"name" : "beadm",
"namespace" : "sysadm",
"id" : "fooid",
"args" : {
"action" : "listbes"
}
}
Response:
-------------------------------
{
"args": {
"listbes": {
"11.0-CURRENTJAN2016-up-20160128_150853": {
"active": "NR",
"date": "2016-01-28",
"mount": "/",
"nick": "14:57",
"space": "10.2G"
},
"initial": {
"active": "-",
"date": "2016-01-28",
"mount": "-",
"nick": "07:00",
"space": "1.2G"
}
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <WebSocket.h>
|
||||
|
||||
//sysadm library interface classes
|
||||
#include "library/sysadm-beadm.h"
|
||||
#include "library/sysadm-general.h"
|
||||
#include "library/sysadm-iocage.h"
|
||||
#include "library/sysadm-iohyve.h"
|
||||
@@ -36,6 +37,11 @@ RestOutputStruct::ExitCode WebSocket::AvailableSubsystems(bool allaccess, QJsonO
|
||||
out->insert("rpc/syscache","read"); //no write to syscache - only reads
|
||||
}
|
||||
|
||||
// - beadm
|
||||
if(QFile::exists("/usr/local/sbin/beadm")){
|
||||
out->insert("sysadm/beadm", "read/write");
|
||||
}
|
||||
|
||||
// - dispatcher (Internal to server - always available)
|
||||
//"read" is the event notifications, "write" is the ability to queue up jobs
|
||||
out->insert("rpc/dispatcher", allaccess ? "read/write" : "read");
|
||||
@@ -90,6 +96,8 @@ RestOutputStruct::ExitCode WebSocket::EvaluateBackendRequest(const RestInputStru
|
||||
//Go through and forward this request to the appropriate sub-system
|
||||
if(namesp=="rpc" && name=="dispatcher"){
|
||||
return EvaluateDispatcherRequest(IN.fullaccess, IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="beadm"){
|
||||
return EvaluateSysadmBEADMRequest(IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="iocage"){
|
||||
return EvaluateSysadmIocageRequest(IN.args, out);
|
||||
}else if(namesp=="sysadm" && name=="iohyve"){
|
||||
@@ -182,6 +190,29 @@ RestOutputStruct::ExitCode WebSocket::EvaluateDispatcherRequest(bool allaccess,
|
||||
return RestOutputStruct::OK;
|
||||
}
|
||||
|
||||
//==== SYSADM -- BEADM ====
|
||||
RestOutputStruct::ExitCode WebSocket::EvaluateSysadmBEADMRequest(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=="listbes"){
|
||||
ok = true;
|
||||
out->insert("listbes", sysadm::BEADM::listBEs());
|
||||
}
|
||||
} //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;
|
||||
}
|
||||
|
||||
//==== SYSADM -- Network ====
|
||||
RestOutputStruct::ExitCode WebSocket::EvaluateSysadmNetworkRequest(const QJsonValue in_args, QJsonObject *out){
|
||||
if(in_args.isObject()){
|
||||
|
||||
Reference in New Issue
Block a user