mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Add new API call to iohyve to rename an existing ISO file on
disk
REST Request:
-------------------------------
PUT /sysadm/iohyve
{
"source" : "test.iso",
"target" : "102.iso",
"action" : "renameiso"
}
WebSocket Request:
-------------------------------
{
"args" : {
"target" : "102.iso",
"source" : "test.iso",
"action" : "renameiso"
},
"id" : "fooid",
"name" : "iohyve",
"namespace" : "sysadm"
}
Response:
-------------------------------
{
"args": {
"renameiso": {
"source": "test.iso",
"target": "102.iso"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -445,6 +445,10 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmIohyveRequest(const QJsonVal
|
||||
ok = true;
|
||||
out->insert("fetchiso", sysadm::Iohyve::fetchISO(in_args.toObject()));
|
||||
}
|
||||
if(act=="renameiso"){
|
||||
ok = true;
|
||||
out->insert("renameiso", sysadm::Iohyve::renameISO(in_args.toObject()));
|
||||
}
|
||||
|
||||
} //end of "action" key usage
|
||||
|
||||
|
||||
@@ -69,3 +69,33 @@ QJsonObject Iohyve::listVMs() {
|
||||
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Rename an ISO file
|
||||
QJsonObject Iohyve::renameISO(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
|
||||
QStringList keys = jsin.keys();
|
||||
if (! keys.contains("source") || ! keys.contains("target") ) {
|
||||
retObject.insert("error", "Missing required key(s) 'source / target'");
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Get the key values
|
||||
QString source = jsin.value("source").toString();
|
||||
QString target = jsin.value("target").toString();
|
||||
|
||||
QStringList output = General::RunCommand("iohyve renameiso " + source + " " + 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("source", source);
|
||||
retObject.insert("target", target);
|
||||
return retObject;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class Iohyve{
|
||||
public:
|
||||
static QJsonObject fetchISO(QJsonObject);
|
||||
static QJsonObject listVMs();
|
||||
static QJsonObject renameISO(QJsonObject);
|
||||
};
|
||||
|
||||
} //end of pcbsd namespace
|
||||
|
||||
Reference in New Issue
Block a user