Add a new API call to the iohyve subsystem: action="listisos"

This will list all the known ISO files which iohyve can use.

REST Request:
-------------------------------
PUT /sysadm/iohyve
{
   "action" : "listisos"
}

WebSocket Request:
-------------------------------
{
   "name" : "iohyve",
   "namespace" : "sysadm",
   "id" : "fooid",
   "args" : {
      "action" : "listisos"
   }
}

Response:
-------------------------------
{
  "args": {
    "listisos": [
      "TRUEOS10.2-RELEASE-08-19-2015-x64-netinstall.iso"
    ]
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
This commit is contained in:
Ken Moore
2016-03-02 14:56:39 -05:00
parent 10df62f69f
commit 1b0cd22e84
3 changed files with 26 additions and 9 deletions

View File

@@ -584,42 +584,46 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmIohyveRequest(const QJsonVal
ok = true;
out->insert("create", sysadm::Iohyve::createGuest(in_args.toObject()));
}
if(act=="listvms"){
else if(act=="listvms"){
ok = true;
out->insert("listvms", sysadm::Iohyve::listVMs());
}
if(act=="fetchiso"){
else if(act=="listisos"){
ok = true;
out->insert("listisos", sysadm::Iohyve::listISOs());
}
else if(act=="fetchiso"){
ok = true;
DProcess fetchproc;
out->insert("fetchiso", sysadm::Iohyve::fetchISO(in_args.toObject(), &fetchproc));
connect(&fetchproc, SIGNAL(ProcessOutput(QString)), this, SLOT(slotIohyveFetchProcessOutput(QString)) );
connect(&fetchproc, SIGNAL(Finished(QString, int, QString)), this, SLOT(slotIohyveFetchDone(QString, int, QString)) );
}
if(act=="install"){
else if(act=="install"){
ok = true;
out->insert("install", sysadm::Iohyve::installGuest(in_args.toObject()));
}
if(act=="issetup"){
else if(act=="issetup"){
ok = true;
out->insert("issetup", sysadm::Iohyve::isSetup());
}
if(act=="renameiso"){
else if(act=="renameiso"){
ok = true;
out->insert("renameiso", sysadm::Iohyve::renameISO(in_args.toObject()));
}
if(act=="rmiso"){
else if(act=="rmiso"){
ok = true;
out->insert("rmiso", sysadm::Iohyve::rmISO(in_args.toObject()));
}
if(act=="setup"){
else if(act=="setup"){
ok = true;
out->insert("setup", sysadm::Iohyve::setupIohyve(in_args.toObject()));
}
if(act=="start"){
else if(act=="start"){
ok = true;
out->insert("start", sysadm::Iohyve::startGuest(in_args.toObject()));
}
if(act=="stop"){
else if(act=="stop"){
ok = true;
out->insert("stop", sysadm::Iohyve::stopGuest(in_args.toObject()));
}

View File

@@ -143,6 +143,18 @@ QJsonObject Iohyve::listVMs() {
return retObject;
}
// List the ISOs on the box
QJsonArray Iohyve::listISOs(){
QJsonArray arr;
QStringList output = General::RunCommand("iohyve isolist").split("\n");
for(int i=1; i<output.length(); i++){ //first line is headers
if(output[i].isEmpty()){ continue; }
arr.append(output[i]);
}
return arr;
}
// Rename an ISO file
QJsonObject Iohyve::renameISO(QJsonObject jsin) {
QJsonObject retObject;

View File

@@ -20,6 +20,7 @@ public:
static QJsonObject installGuest(QJsonObject);
static QJsonObject isSetup();
static QJsonObject listVMs();
static QJsonArray listISOs();
static QJsonObject renameISO(QJsonObject);
static QJsonObject rmISO(QJsonObject);
static QJsonObject setupIohyve(QJsonObject);