mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
New API call for creating a new boot environment. An optional flag is shown below.
By specifying clonefrom which passes along the -e flag it will clone from a inactive boot environment.
REST Request:
-------------------------------
PUT /sysadm/beadm
{
"action" : "createbe",
"newbe" : "red",
"clonefrom" : "green"
}
WebSocket Request:
-------------------------------
{
"id" : "fooid",
"args" : {
"newbe" : "red",
"clonefrom" : "green",
"action" : "createbe"
},
"namespace" : "sysadm",
"name" : "beadm"
}
Response:
-------------------------------
{
"args": {
"createbe": {
"clonefrom": "green",
"newbe": "red"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -91,7 +91,7 @@ RestOutputStruct::ExitCode WebSocket::EvaluateBackendRequest(const RestInputStru
|
||||
}else{
|
||||
QJsonObject avail;
|
||||
AvailableSubsystems(IN.fullaccess, &avail);
|
||||
if(!avail.contains(namesp+"/"+name)){ return RestOutputStruct::BADREQUEST; }
|
||||
if(!avail.contains(namesp+"/"+name)){ return RestOutputStruct::NOTFOUND; }
|
||||
}
|
||||
|
||||
//Go through and forward this request to the appropriate sub-system
|
||||
@@ -207,6 +207,9 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmBEADMRequest(const QJsonValu
|
||||
}else if(act=="activatebe"){
|
||||
ok = true;
|
||||
out->insert("activatebe", sysadm::BEADM::activateBE(in_args.toObject()));
|
||||
}else if(act=="createbe"){
|
||||
ok = true;
|
||||
out->insert("createbe", sysadm::BEADM::createBE(in_args.toObject()));
|
||||
}
|
||||
} //end of "action" key usage
|
||||
|
||||
|
||||
@@ -105,4 +105,41 @@ QJsonObject BEADM::activateBE(QJsonObject jsin) {
|
||||
|
||||
retObject.insert("target", target);
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// createbe (optional flag -e for cloning from an inactive BE) : Create a new Boot environment
|
||||
|
||||
QJsonObject BEADM::createBE(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
|
||||
QStringList keys = jsin.keys();
|
||||
if (! keys.contains("newbe") ) {
|
||||
retObject.insert("error", "Missing required key(s) 'target'");
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Get the key values
|
||||
|
||||
QString newbe = jsin.value("newbe").toString();
|
||||
QString flags;
|
||||
if ( keys.contains("clonefrom") ) {
|
||||
flags = "-e " + jsin.value("clonefrom").toString();
|
||||
}
|
||||
|
||||
QStringList output = General::RunCommand("beadm create " + flags + " " + newbe).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("newbe", newbe);
|
||||
if ( keys.contains("clonefrom") ) {
|
||||
retObject.insert("clonefrom", jsin.value("clonefrom").toString());
|
||||
}
|
||||
return retObject;
|
||||
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
static QJsonObject listBEs();
|
||||
static QJsonObject renameBE(QJsonObject);
|
||||
static QJsonObject activateBE(QJsonObject);
|
||||
static QJsonObject createBE(QJsonObject);
|
||||
};
|
||||
|
||||
} //end of pcbsd namespace
|
||||
|
||||
Reference in New Issue
Block a user