mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Add new API call to do the initial setup of Iohyve
Both the pool/nic are required for setup to complete.
REST Request:
-------------------------------
PUT /sysadm/iohyve
{
"nic" : "re0",
"pool" : "tank",
"action" : "setup"
}
WebSocket Request:
-------------------------------
{
"id" : "fooid",
"name" : "iohyve",
"args" : {
"pool" : "tank",
"nic" : "re0",
"action" : "setup"
},
"namespace" : "sysadm"
}
Response:
-------------------------------
{
"args": {
"setup": {
"nic": "re0",
"pool": "tank"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -511,6 +511,10 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmIohyveRequest(const QJsonVal
|
||||
ok = true;
|
||||
out->insert("rmiso", sysadm::Iohyve::rmISO(in_args.toObject()));
|
||||
}
|
||||
if(act=="setup"){
|
||||
ok = true;
|
||||
out->insert("setup", sysadm::Iohyve::setupIohyve(in_args.toObject()));
|
||||
}
|
||||
} //end of "action" key usage
|
||||
|
||||
//If nothing done - return the proper code
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
using namespace sysadm;
|
||||
|
||||
//PLEASE: Keep the functions in the same order as listed in pcbsd-general.h
|
||||
|
||||
// Queue the fetch of an ISO
|
||||
QJsonObject Iohyve::fetchISO(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
@@ -123,3 +122,37 @@ QJsonObject Iohyve::rmISO(QJsonObject jsin) {
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// setup iohyve
|
||||
QJsonObject Iohyve::setupIohyve(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
|
||||
QStringList keys = jsin.keys();
|
||||
if (! keys.contains("pool") || ! keys.contains("nic") ) {
|
||||
retObject.insert("error", "Missing required key(s) 'pool / nic'");
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Get the key values
|
||||
QString pool = jsin.value("pool").toString();
|
||||
QString nic = jsin.value("nic").toString();
|
||||
|
||||
// Enable the rc.conf values
|
||||
if ( ! General::setConfFileValue("/etc/rc.conf", "iohyve_flags=", "iohyve_flags=\"kmod=1 net=" + nic + "\"", -1 ) ) {
|
||||
retObject.insert("error", "Failed enabling rc.conf iohyve_flags");
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Do the setup right now
|
||||
QStringList output = General::RunCommand("iohyve setup pool=" + pool + " kmod=1 net=" + nic).split("\n");
|
||||
for ( int i = 0; i < output.size(); i++)
|
||||
{
|
||||
if ( output.at(i).indexOf("cannot create") != -1 ) {
|
||||
retObject.insert("error", output.at(i));
|
||||
return retObject;
|
||||
}
|
||||
}
|
||||
|
||||
retObject.insert("pool", pool);
|
||||
retObject.insert("nic", nic);
|
||||
return retObject;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
static QJsonObject listVMs();
|
||||
static QJsonObject renameISO(QJsonObject);
|
||||
static QJsonObject rmISO(QJsonObject);
|
||||
static QJsonObject setupIohyve(QJsonObject);
|
||||
};
|
||||
|
||||
} //end of pcbsd namespace
|
||||
|
||||
Reference in New Issue
Block a user