Update sysadm-update with the upcoming startUpdates() internal

call, will doc it later when its finished
This commit is contained in:
Kris Moore
2016-02-01 12:13:59 -05:00
parent a95404c88d
commit df3500b274
2 changed files with 52 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
#include <QUuid>
#include "sysadm-general.h"
#include "sysadm-update.h"
#include "sysadm-global.h"
@@ -98,3 +99,53 @@ QJsonObject Update::listBranches() {
return retObject;
}
// Kickoff an update process
QJsonObject Update::startUpdate(QJsonObject jsin) {
QJsonObject retObject;
QStringList keys = jsin.keys();
if (! keys.contains("target") ) {
retObject.insert("error", "Missing required key 'target'");
return retObject;
}
// Save the target
QString target;
target = jsin.value("target").toString();
QString flags;
if ( target == "chbranch" ) {
if (! keys.contains("branch") ) {
retObject.insert("error", "Missing required key 'branch'");
return retObject;
}
flags = "chbranch " + jsin.value("branch").toString();
} else if ( target == "pkgupdate" ) {
flags = "pkgupdate";
} else if ( target == "fbsdupdate" ) {
flags = "fbsdupdate";
} else if ( target == "fbsdupdatepkgs" ) {
flags = "fbsdupdatepkgs";
} else if ( target == "standalone" ) {
if (! keys.contains("tag") ) {
retObject.insert("error", "Missing required key 'tag'");
return retObject;
}
flags = "install " + jsin.value("tag").toString();
} else {
// Ruh-roh
retObject.insert("error", "Unknown target key: " + target);
return retObject;
}
// Create a unique ID for this queued action
QString ID = QUuid::createUuid().toString();
//DISPATCHER::queueProcess(ID, "pc-updatemanager " + flags).split("\n");
// Return some details to user that the action was queued
retObject.insert("command", "pc-updatemanger " + flags);
retObject.insert("comment", "Task Queued");
retObject.insert("queueid", ID);
return retObject;
}

View File

@@ -16,6 +16,7 @@ class Update{
public:
static QJsonObject checkUpdates();
static QJsonObject listBranches();
static QJsonObject startUpdate(QJsonObject);
};
} //end of pcbsd namespace