mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Add new iocage API call to clean all jails.
REST Request:
-------------------------------
PUT /sysadm/iocage
{
"action" : "cleanjails"
}
WebSocket Request:
-------------------------------
{
"namespace" : "sysadm",
"args" : {
"action" : "cleanjails"
},
"id" : "fooid",
"name" : "iocage"
}
Response:
-------------------------------
{
"args": {
"cleanjails": {
"success": "All jails have been cleaned."
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -389,6 +389,10 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmIocageRequest(const QJsonVal
|
||||
bool ok = false;
|
||||
if(keys.contains("action")){
|
||||
QString act = JsonValueToString(in_args.toObject().value("action"));
|
||||
if(act=="cleanjails"){
|
||||
ok = true;
|
||||
out->insert("cleanjails", sysadm::Iocage::cleanJails());
|
||||
}
|
||||
if(act=="capjail"){
|
||||
ok = true;
|
||||
out->insert("capjail", sysadm::Iocage::capJail(in_args.toObject()));
|
||||
|
||||
@@ -12,6 +12,29 @@ using namespace sysadm;
|
||||
|
||||
//PLEASE: Keep the functions in the same order as listed in pcbsd-general.h
|
||||
|
||||
// Clean all jails on a box
|
||||
QJsonObject Iocage::cleanJails() {
|
||||
QJsonObject retObject;
|
||||
|
||||
QStringList output = General::RunCommand("iocage clean -fj ").split("\n");
|
||||
|
||||
for ( int i = 0; i < output.size(); i++)
|
||||
{
|
||||
// This means either a mount is stuck or a jail cannot be stopped,
|
||||
// give them the error.
|
||||
if ( output.at(i).indexOf("ERROR:") != -1 ) {
|
||||
retObject.insert("error", output.at(i));
|
||||
break;
|
||||
} else {
|
||||
// iocage does a spinner for these that is distracting to see returned,
|
||||
// returning what a user wants to actually see.
|
||||
retObject.insert("success", "All jails have been cleaned.");
|
||||
}
|
||||
}
|
||||
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Resource cap a jail on the box
|
||||
QJsonObject Iocage::capJail(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace sysadm{
|
||||
|
||||
class Iocage{
|
||||
public:
|
||||
static QJsonObject cleanJails();
|
||||
static QJsonObject capJail(QJsonObject);
|
||||
static QJsonObject deactivatePool(QJsonObject);
|
||||
static QJsonObject activatePool(QJsonObject);
|
||||
|
||||
Reference in New Issue
Block a user