mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
API call for activating a different boot environment
REST Request:
-------------------------------
PUT /sysadm/beadm
{
"target" : "bootthingy",
"action" : "activatebe"
}
WebSocket Request:
-------------------------------
{
"name" : "beadm",
"args" : {
"action" : "activatebe",
"target" : "bootthingy"
},
"namespace" : "sysadm",
"id" : "fooid"
}
Response:
-------------------------------
{
"args": {
"activatebe": {
"target": "bootthingy"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -197,14 +197,16 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmBEADMRequest(const QJsonValu
|
||||
QStringList keys = in_args.toObject().keys();
|
||||
bool ok = false;
|
||||
if(keys.contains("action")){
|
||||
QString act = JsonValueToString(in_args.toObject().value("action"));
|
||||
QString act = JsonValueToString(in_args.toObject().value("action")).toLower();
|
||||
if(act=="listbes"){
|
||||
ok = true;
|
||||
out->insert("listbes", sysadm::BEADM::listBEs());
|
||||
}
|
||||
if(act=="renamebe"){
|
||||
}else if(act=="renamebe"){
|
||||
ok = true;
|
||||
out->insert("renamebe", sysadm::BEADM::renameBE(in_args.toObject()));
|
||||
}else if(act=="activatebe"){
|
||||
ok = true;
|
||||
out->insert("activatebe", sysadm::BEADM::activateBE(in_args.toObject()));
|
||||
}
|
||||
} //end of "action" key usage
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ QJsonObject BEADM::listBEs() {
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Rename the specified source BE to a a new target BE name
|
||||
|
||||
QJsonObject BEADM::renameBE(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
|
||||
@@ -61,7 +63,6 @@ QJsonObject BEADM::renameBE(QJsonObject jsin) {
|
||||
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++)
|
||||
{
|
||||
@@ -75,3 +76,33 @@ QJsonObject BEADM::renameBE(QJsonObject jsin) {
|
||||
retObject.insert("target", target);
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Activate the given BeName for the next boot
|
||||
|
||||
QJsonObject BEADM::activateBE(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
|
||||
QStringList keys = jsin.keys();
|
||||
if (! keys.contains("target") ) {
|
||||
retObject.insert("error", "Missing required key(s) 'target'");
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Get the key values
|
||||
|
||||
QString target = jsin.value("target").toString();
|
||||
|
||||
|
||||
QStringList output = General::RunCommand("beadm activate " + 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("target", target);
|
||||
return retObject;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ class BEADM{
|
||||
public:
|
||||
static QJsonObject listBEs();
|
||||
static QJsonObject renameBE(QJsonObject);
|
||||
static QJsonObject activateBE(QJsonObject);
|
||||
};
|
||||
|
||||
} //end of pcbsd namespace
|
||||
|
||||
Reference in New Issue
Block a user