Add LifePreserver API first list-cron call

This commit is contained in:
Kris Moore
2016-01-05 13:19:01 -05:00
parent b1e451b385
commit 528c247607
6 changed files with 42 additions and 13 deletions

View File

@@ -8,6 +8,7 @@
//sysadm library interface classes
#include "sysadm-general.h"
#include "sysadm-network.h"
#include "sysadm-lifepreserver.h"
#include "syscache-client.h"
#include "dispatcher-client.h"
@@ -30,6 +31,8 @@ RestOutputStruct::ExitCode WebSocket::EvaluateBackendRequest(QString namesp, QSt
return EvaluateSyscacheRequest(args, out);
}else if(namesp=="sysadm" && name=="network"){
return EvaluateSysadmNetworkRequest(args, out);
}else if(namesp=="sysadm" && name=="lifepreserver"){
return EvaluateSysadmLifePreserverRequest(args, out);
}else{
return RestOutputStruct::BADREQUEST;
}
@@ -130,3 +133,27 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmNetworkRequest(const QJsonVa
}
return RestOutputStruct::OK;
}
//==== SYSADM -- LifePreserver ====
RestOutputStruct::ExitCode WebSocket::EvaluateSysadmLifePreserverRequest(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=="listcron"){
ok = true;
out->insert("listcron", sysadm::LifePreserver::listCron());
}
} //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;
}