API Change: Add a simple "pkg_autoremove" action for the sysadm/pkg subsystem (no additional inputs). This will queue up the pkg autoremove action which prunes all orphaned packages on the systems.

This commit is contained in:
Ken Moore
2016-04-26 09:41:58 -04:00
parent e4db11a0f7
commit b07f11bfe3
3 changed files with 18 additions and 1 deletions

View File

@@ -797,6 +797,8 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmPkgRequest(const QJsonValue
out->insert("pkg_upgrade", sysadm::PKG::pkg_upgrade());
}else if(act=="pkg_audit"){
out->insert("pkg_audit", sysadm::PKG::pkg_audit());
}else if(act=="pkg_autoremove"){
out->insert("pkg_autoremove", sysadm::PKG::pkg_autoremove());
}else{
//unknown action
return RestOutputStruct::BADREQUEST;

View File

@@ -440,3 +440,17 @@ QJsonObject PKG::pkg_audit(){
obj.insert("proc_id",ID);
return obj;
}
QJsonObject PKG::pkg_autoremove(){
//Generate the command to run
QString cmd = "pkg autoremove -y";
//Now kick off the dispatcher process (within the pkg queue - since only one pkg process can run at a time)
QString ID = "sysadm_pkg_autoremove-"+QUuid::createUuid().toString(); //create a random tag for the process
DISPATCHER->queueProcess(Dispatcher::PKG_QUEUE, ID, cmd);
//Now return the info about the process
QJsonObject obj;
obj.insert("status", "pending");
obj.insert("proc_cmd",cmd);
obj.insert("proc_id",ID);
return obj;
}

View File

@@ -36,9 +36,10 @@ public:
static QJsonObject pkg_check_upgrade(); //Check for updates to pkgs
static QJsonObject pkg_upgrade(); //upgrade all pkgs (use sysadm/updates if possible instead)
static QJsonObject pkg_audit(); //List details of vulnerable packages
static QJsonObject pkg_autoremove(); //Autoremove orphaned packages
};
} //end of sysadm namespace
#endif
#endif