mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Add API call for BEADM to rename a boot environment
REST Request:
-------------------------------
PUT /sysadm/beadm
{
"source" : "newname",
"action" : "renamebe",
"target" : "bootthingy"
}
WebSocket Request:
-------------------------------
{
"namespace" : "sysadm",
"name" : "beadm",
"id" : "fooid",
"args" : {
"source" : "newname",
"target" : "bootthingy",
"action" : "renamebe"
}
}
Response:
-------------------------------
{
"args": {
"renamebe": {
"source": "newname",
"target": "bootthingy"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
This commit is contained in:
1
src/server/library/.~lock.sysadm-beadm.cpp#
Normal file
1
src/server/library/.~lock.sysadm-beadm.cpp#
Normal file
@@ -0,0 +1 @@
|
||||
,josh,localhost,08.02.2016 13:33,file:///usr/home/josh/.config/libreoffice/4;
|
||||
@@ -47,3 +47,31 @@ QJsonObject BEADM::listBEs() {
|
||||
|
||||
return retObject;
|
||||
}
|
||||
|
||||
QJsonObject BEADM::renameBE(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("beadm rename " + source + " " + target).split("\n");
|
||||
for ( int i = 0; i < output.size(); i++)
|
||||
{
|
||||
if ( output.at(i).indexOf("ERROR") != -1 ) {
|
||||
retObject.insert("error", output.at(i));
|
||||
return retObject;
|
||||
}
|
||||
}
|
||||
|
||||
retObject.insert("source", source);
|
||||
retObject.insert("target", target);
|
||||
return retObject;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace sysadm{
|
||||
class BEADM{
|
||||
public:
|
||||
static QJsonObject listBEs();
|
||||
static QJsonObject renameBE(QJsonObject);
|
||||
};
|
||||
|
||||
} //end of pcbsd namespace
|
||||
|
||||
Reference in New Issue
Block a user