mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Add new API call to iohyve to remove a iso dataset
Target is the iso we are removing from iohyve
REST Request:
-------------------------------
PUT /sysadm/iohyve
{
"action" : "rmiso",
"target" : "FreeBSD-10.2-RELEASE-amd64-bootonly.iso"
}
WebSocket Request:
-------------------------------
{
"id" : "fooid",
"name" : "iohyve",
"args" : {
"target" : "FreeBSD-10.2-RELEASE-amd64-bootonly.iso",
"action" : "rmiso"
},
"namespace" : "sysadm"
}
Response:
-------------------------------
{
"args": {
"rmiso": {
"target": "FreeBSD-10.2-RELEASE-amd64-bootonly.iso"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -449,7 +449,10 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmIohyveRequest(const QJsonVal
|
||||
ok = true;
|
||||
out->insert("renameiso", sysadm::Iohyve::renameISO(in_args.toObject()));
|
||||
}
|
||||
|
||||
if(act=="rmiso"){
|
||||
ok = true;
|
||||
out->insert("rmiso", sysadm::Iohyve::rmISO(in_args.toObject()));
|
||||
}
|
||||
} //end of "action" key usage
|
||||
|
||||
//If nothing done - return the proper code
|
||||
|
||||
@@ -98,4 +98,28 @@ QJsonObject Iohyve::renameISO(QJsonObject jsin) {
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Remove an ISO file
|
||||
QJsonObject Iohyve::rmISO(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
|
||||
QStringList keys = jsin.keys();
|
||||
if (! keys.contains("target") ) {
|
||||
retObject.insert("error", "Missing required key 'target'");
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Get the key values
|
||||
QString target = jsin.value("target").toString();
|
||||
|
||||
QStringList output = General::RunCommand("iohyve rmiso " + target).split("\n");
|
||||
for ( int i = 0; i < output.size(); i++)
|
||||
{
|
||||
if ( output.at(i).indexOf("cannot open") != -1 ) {
|
||||
retObject.insert("error", output.at(i));
|
||||
return retObject;
|
||||
}
|
||||
}
|
||||
retObject.insert("target", target);
|
||||
return retObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
static QJsonObject fetchISO(QJsonObject);
|
||||
static QJsonObject listVMs();
|
||||
static QJsonObject renameISO(QJsonObject);
|
||||
static QJsonObject rmISO(QJsonObject);
|
||||
};
|
||||
|
||||
} //end of pcbsd namespace
|
||||
|
||||
Reference in New Issue
Block a user