mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Add new iocage API call to list resource usage for jails.
REST Request:
-------------------------------
PUT /sysadm/iocage
{
"action" : "df"
}
WebSocket Request:
-------------------------------
{
"namespace" : "sysadm",
"name" : "iocage",
"id" : "fooid",
"args" : {
"action" : "df"
}
}
Response:
-------------------------------
{
"args": {
"df": {
"f250ab25-d062-11e5-8209-d05099728dbf": {
"ava": "83.4G",
"crt": "2.30x",
"qta": "none",
"res": "none",
"tag": "test",
"use": "1.69M"
},
"f39318ae-d064-11e5-8209-d05099728dbf": {
"ava": "83.4G",
"crt": "2.30x",
"qta": "none",
"res": "none",
"tag": "test2",
"use": "1.69M"
}
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -471,6 +471,10 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmIocageRequest(const QJsonVal
|
||||
bool ok = false;
|
||||
if(keys.contains("action")){
|
||||
QString act = JsonValueToString(in_args.toObject().value("action"));
|
||||
if(act=="df"){
|
||||
ok = true;
|
||||
out->insert("df", sysadm::Iocage::df());
|
||||
}
|
||||
if(act=="destroyjail"){
|
||||
ok = true;
|
||||
out->insert("destroyjail", sysadm::Iocage::destroyJail(in_args.toObject()));
|
||||
|
||||
@@ -12,6 +12,41 @@ using namespace sysadm;
|
||||
|
||||
//PLEASE: Keep the functions in the same order as listed in pcbsd-general.h
|
||||
|
||||
// Show resource usage for jails on the box
|
||||
QJsonObject Iocage::df() {
|
||||
QJsonObject retObject;
|
||||
|
||||
// Get the key values
|
||||
QStringList output = General::RunCommand("iocage df").split("\n");
|
||||
QJsonObject vals;
|
||||
|
||||
for ( int i = 0; i < output.size(); i++)
|
||||
{
|
||||
// Null output at first
|
||||
if ( output.at(i).isEmpty() )
|
||||
continue;
|
||||
|
||||
QJsonObject jail;
|
||||
QString line = output.at(i).simplified();
|
||||
QString uuid = line.section(" ", 0, 0);
|
||||
|
||||
// Otherwise we get a list of what we already know.
|
||||
if ( line.section(" ", 0, 0) == "UUID" )
|
||||
continue;
|
||||
|
||||
jail.insert("crt", line.section(" ", 1, 1));
|
||||
jail.insert("res", line.section(" ", 2, 2));
|
||||
jail.insert("qta", line.section(" ", 3, 3));
|
||||
jail.insert("use", line.section(" ", 4, 4));
|
||||
jail.insert("ava", line.section(" ", 5, 5));
|
||||
jail.insert("tag", line.section(" ", 6, 6));
|
||||
|
||||
retObject.insert(uuid, jail);
|
||||
}
|
||||
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Destroy a jail on the box
|
||||
QJsonObject Iocage::destroyJail(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace sysadm{
|
||||
|
||||
class Iocage{
|
||||
public:
|
||||
static QJsonObject df();
|
||||
static QJsonObject destroyJail(QJsonObject);
|
||||
static QJsonObject createJail(QJsonObject);
|
||||
static QJsonObject cloneJail(QJsonObject);
|
||||
|
||||
Reference in New Issue
Block a user