From 1b0cd22e843127f22fdba7726333fcc0db334652 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 2 Mar 2016 14:56:39 -0500 Subject: [PATCH] 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" } --- src/server/WebBackend.cpp | 22 +++++++++++++--------- src/server/library/sysadm-iohyve.cpp | 12 ++++++++++++ src/server/library/sysadm-iohyve.h | 1 + 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/server/WebBackend.cpp b/src/server/WebBackend.cpp index 60f0a39..348d494 100644 --- a/src/server/WebBackend.cpp +++ b/src/server/WebBackend.cpp @@ -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())); } diff --git a/src/server/library/sysadm-iohyve.cpp b/src/server/library/sysadm-iohyve.cpp index 2e485cb..071b7d0 100644 --- a/src/server/library/sysadm-iohyve.cpp +++ b/src/server/library/sysadm-iohyve.cpp @@ -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