mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Add new API call to remove a replication task / target
REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
"dataset" : "tank",
"host" : "192.168.0.10",
"action" : "removereplication"
}
REST Response:
-------------------------------
{
"args": {
"removereplication": {
"dataset": "tank",
"host": "192.168.0.10"
}
}
}
WebSocket Request:
-------------------------------
{
"id" : "fooid",
"args" : {
"action" : "removereplication",
"dataset" : "tank",
"host" : "192.168.0.10"
},
"name" : "lifepreserver",
"namespace" : "sysadm"
}
WebSocket Response:
-------------------------------
{
"args": {
"removereplication": {
"dataset": "tank",
"host": "192.168.0.10"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -287,6 +287,47 @@ QJsonObject LifePreserver::listSnap(QJsonObject jsin) {
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Remove a replication task
|
||||
QJsonObject LifePreserver::removeReplication(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
QString dataset, host;
|
||||
|
||||
QStringList keys = jsin.keys();
|
||||
if(! keys.contains("dataset") || ! keys.contains("host")){
|
||||
retObject.insert("error", "Requires dataset and host keys");
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Get the dataset / host
|
||||
dataset = jsin.value("dataset").toString();
|
||||
host = jsin.value("host").toString();
|
||||
|
||||
// Make sure we have the dataset / host key(s)
|
||||
if ( dataset.isEmpty() || host.isEmpty() ) {
|
||||
retObject.insert("error", "Empty dataset or host keys ");
|
||||
return retObject;
|
||||
}
|
||||
|
||||
QStringList output;
|
||||
output = General::RunCommand("lpreserver replicate remove " + dataset + " " + host).split("\n");
|
||||
|
||||
// Check for any errors
|
||||
for ( int i = 0; i < output.size(); i++)
|
||||
{
|
||||
if ( output.at(i).indexOf("ERROR:") != -1 ) {
|
||||
retObject.insert("error", output.at(i));
|
||||
return retObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Got to the end, return the good json
|
||||
QJsonObject values;
|
||||
values.insert("dataset", dataset);
|
||||
values.insert("host", host);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
// Remove a snapshot
|
||||
QJsonObject LifePreserver::removeSnapshot(QJsonObject jsin) {
|
||||
QJsonObject retObject;
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
static QJsonObject listCron();
|
||||
static QJsonObject listReplication();
|
||||
static QJsonObject listSnap(QJsonObject jsin);
|
||||
static QJsonObject removeReplication(QJsonObject jsin);
|
||||
static QJsonObject removeSnapshot(QJsonObject jsin);
|
||||
static QJsonObject revertSnapshot(QJsonObject jsin);
|
||||
static QJsonObject saveSettings(QJsonObject jsin);
|
||||
|
||||
@@ -205,6 +205,10 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmLifePreserverRequest(const Q
|
||||
ok = true;
|
||||
out->insert("listsnap", sysadm::LifePreserver::listSnap(in_args.toObject()));
|
||||
}
|
||||
if(act=="removereplication"){
|
||||
ok = true;
|
||||
out->insert("removereplication", sysadm::LifePreserver::removeReplication(in_args.toObject()));
|
||||
}
|
||||
if(act=="removesnap"){
|
||||
ok = true;
|
||||
out->insert("removesnap", sysadm::LifePreserver::removeSnapshot(in_args.toObject()));
|
||||
|
||||
Reference in New Issue
Block a user