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 templates.
REST Request:
-------------------------------
PUT /sysadm/iocage
{
"action" : "cleantemplates"
}
WebSocket Request:
-------------------------------
{
"args" : {
"action" : "cleantemplates"
},
"name" : "iocage",
"id" : "fooid",
"namespace" : "sysadm"
}
Response:
-------------------------------
{
"args": {
"cleantemplates": {
"success": "All templates 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=="cleantemplates"){
|
||||
ok = true;
|
||||
out->insert("cleantemplates", sysadm::Iocage::cleanTemplates());
|
||||
}
|
||||
if(act=="cleanreleases"){
|
||||
ok = true;
|
||||
out->insert("cleanreleases", sysadm::Iocage::cleanReleases());
|
||||
|
||||
@@ -12,6 +12,29 @@ using namespace sysadm;
|
||||
|
||||
//PLEASE: Keep the functions in the same order as listed in pcbsd-general.h
|
||||
|
||||
// Clean all templates on a box
|
||||
QJsonObject Iocage::cleanTemplates() {
|
||||
QJsonObject retObject;
|
||||
|
||||
QStringList output = General::RunCommand("iocage clean -ft ").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 templates have been cleaned.");
|
||||
}
|
||||
}
|
||||
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Clean all RELEASEs on a box
|
||||
QJsonObject Iocage::cleanReleases() {
|
||||
QJsonObject retObject;
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace sysadm{
|
||||
|
||||
class Iocage{
|
||||
public:
|
||||
static QJsonObject cleanTemplates();
|
||||
static QJsonObject cleanReleases();
|
||||
static QJsonObject cleanJails();
|
||||
static QJsonObject capJail(QJsonObject);
|
||||
|
||||
Reference in New Issue
Block a user