mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Add new API call to get iohyve properties for a guest
Requires the "name" of the guest to get props for
REST Request:
-------------------------------
PUT /sysadm/iohyve
{
"action" : "getprops",
"name" : "bsdguest"
}
WebSocket Request:
-------------------------------
{
"id" : "fooid",
"namespace" : "sysadm",
"args" : {
"name" : "bsdguest",
"action" : "getprops"
},
"name" : "iohyve"
}
Response:
-------------------------------
{
"args": {
"getprops": {
"bsdguest": {
"autogrub": "\\n",
"bargs": "-A_-H_-P",
"boot": "0",
"con": "nmdm0",
"cpu": "1",
"description": "Tue",
"install": "no",
"loader": "bhyveload",
"name": "bsdguest",
"os": "default",
"persist": "1",
"ram": "256M",
"size": "10G",
"tap": "tap0"
}
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -615,9 +615,12 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmIohyveRequest(const QJsonVal
|
||||
}
|
||||
else if(act=="fetchiso"){
|
||||
ok = true;
|
||||
//DProcess fetchproc;
|
||||
out->insert("fetchiso", sysadm::Iohyve::fetchISO(in_args.toObject()));
|
||||
}
|
||||
else if(act=="getprops"){
|
||||
ok = true;
|
||||
out->insert("getprops", sysadm::Iohyve::getProps(in_args.toObject()));
|
||||
}
|
||||
else if(act=="install"){
|
||||
ok = true;
|
||||
out->insert("install", sysadm::Iohyve::installGuest(in_args.toObject()));
|
||||
|
||||
@@ -146,6 +146,42 @@ QJsonObject Iohyve::deleteGuest(QJsonObject jsin) {
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Get all the properties for a guest
|
||||
QJsonObject Iohyve::getProps(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
|
||||
QStringList keys = jsin.keys();
|
||||
if (! keys.contains("name") ) {
|
||||
retObject.insert("error", "Missing required key 'name'");
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Get the key values
|
||||
QString name = jsin.value("name").toString();
|
||||
|
||||
QStringList output = General::RunCommand("iohyve", QStringList() << "getall" << name).split("\n");
|
||||
|
||||
QJsonObject props;
|
||||
|
||||
for ( int i = 0; i < output.size(); i++)
|
||||
{
|
||||
if ( output.at(i).indexOf("Getting ") != -1 )
|
||||
continue;
|
||||
|
||||
if ( output.at(i).isEmpty() )
|
||||
break;
|
||||
|
||||
QString line = output.at(i).simplified();
|
||||
QString prop = line.section(" ", 0, 0);
|
||||
QString val = line.section(" ", 1, 1);
|
||||
props.insert(prop, val);
|
||||
}
|
||||
|
||||
retObject.insert(name, props);
|
||||
return retObject;
|
||||
}
|
||||
|
||||
|
||||
// Queue the fetch of an ISO
|
||||
QJsonObject Iohyve::fetchISO(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
static QJsonObject deleteDisk(QJsonObject);
|
||||
static QJsonObject deleteGuest(QJsonObject);
|
||||
static QJsonObject fetchISO(QJsonObject);
|
||||
static QJsonObject getProps(QJsonObject);
|
||||
static QJsonObject installGuest(QJsonObject);
|
||||
static QJsonObject isSetup();
|
||||
static QJsonObject listDisks(QJsonObject);
|
||||
|
||||
Reference in New Issue
Block a user