mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 02:20:17 +00:00
NEW API: sysadm/iocage "action"="createplugin"
This will fetch/create a new plugin jail.
Required Arguements:
"action"="createplugin"
"plugin"="name_of_plugin"
"net_device"="network_device_to_use"
"ip4" *or* "ip6" with the address to assign to the new jail (IPv4 or IPv6 address)
Changelog: yes
------------
REST Request (example):
-------------------------------
PUT /sysadm/iocage
{
"plugin" : "gitlab",
"net_device" : "re0",
"action" : "createplugin",
"ip4" : "10.20.0.130"
}
WebSocket Request:
-------------------------------
{
"id" : "fooid",
"name" : "iocage",
"args" : {
"ip4" : "10.20.0.130",
"plugin" : "gitlab",
"net_device" : "re0",
"action" : "createplugin"
},
"namespace" : "sysadm"
}
Response:
-------------------------------
{
"args": {
"createplugin": {
"started_dispatcher_id": "sysadm_iocage_fetch_plugin_gitlab"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -703,11 +703,18 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmIocageRequest(const QJsonVal
|
||||
ok = true;
|
||||
out->insert("getjailsettings", sysadm::Iocage::getJailSettings(in_args.toObject()));
|
||||
}*/
|
||||
|
||||
//JAILS (GENERIC)
|
||||
else if(act=="listjails"){ retObj = sysadm::Iocage::listJails(); }
|
||||
//TEMPLATES
|
||||
else if(act=="listtemplates"){ retObj = sysadm::Iocage::listTemplates(); }
|
||||
//RELEASES
|
||||
else if(act=="listreleases"){ retObj = sysadm::Iocage::listReleases(); }
|
||||
else if(act=="fetchreleases"){ retObj = sysadm::Iocage::fetchReleases(in_args.toObject()); }
|
||||
//PLUGINS
|
||||
else if(act=="listplugins"){ retObj = sysadm::Iocage::listPlugins(); }
|
||||
else if(act=="createplugin"){ retObj = sysadm::Iocage::fetchPlugin(in_args.toObject()); }
|
||||
|
||||
ok = !retObj.keys().isEmpty();
|
||||
if(ok){ out->insert(act,retObj); }
|
||||
} //end of "action" key usage
|
||||
|
||||
@@ -201,23 +201,25 @@ QJsonObject Iocage::fetchReleases(QJsonObject inobj){
|
||||
return retObject;
|
||||
}
|
||||
|
||||
QJsonObject Iocage::fetchPlugins(QJsonObject inobj){
|
||||
QJsonObject Iocage::fetchPlugin(QJsonObject inobj){
|
||||
QJsonObject retObject;
|
||||
if(!inobj.contains("plugins")){ return retObject; } //nothing to do
|
||||
QStringList plugins;
|
||||
if(inobj.value("plugins").isArray()){ plugins = General::JsonArrayToStringList(inobj.value("plugins").toArray()); }
|
||||
else if(inobj.value("plugins").isString()){ plugins << inobj.value("plugins").toString(); }
|
||||
if(!inobj.contains("plugin") || !inobj.contains("net_device") || ! (inobj.contains("ip4") || inobj.contains("ip6")) ){ return retObject; } //nothing to do
|
||||
QString plugin = inobj.value("plugin").toString();
|
||||
QString dev = inobj.value("net_device").toString();
|
||||
QString inet;
|
||||
if(inobj.contains("ip6")){
|
||||
inet = "ip6_addr=\""+dev+"|"+inobj.value("ip6").toString()+"\"";
|
||||
}else{
|
||||
inet = "ip4_addr=\""+dev+"|"+inobj.value("ip4").toString()+"\"";
|
||||
}
|
||||
|
||||
//Now start up each of these downloads as appropriate
|
||||
QStringList cids = DISPATCHER->listJobs().value("no_queue").toObject().keys(); //all currently running/pending jobs
|
||||
QString jobprefix = "sysadm_iocage_fetch_plugin_";
|
||||
QJsonArray started;
|
||||
for(int i=0; i<plugins.length(); i++){
|
||||
plugins[i] = plugins[i].section(" ",0,0, QString::SectionSkipEmpty); //all valid releases are a single word - do not allow injection of other commands
|
||||
if(cids.contains(jobprefix+plugins[i]) ){ continue; } //this fetch job is already running - skip it for now
|
||||
DISPATCHER->queueProcess(jobprefix+plugins[i], "iocage fetch --plugins --verify "+plugins[i]);
|
||||
started << jobprefix+plugins[i];
|
||||
}
|
||||
if(started.count()>0){ retObject.insert("started_dispatcher_id", started); }
|
||||
plugin = plugin.section(" ",0,0, QString::SectionSkipEmpty); //all valid releases are a single word - do not allow injection of other commands
|
||||
if(cids.contains(jobprefix+plugin) ){ return QJsonObject(); } //this fetch job is already running
|
||||
DISPATCHER->queueProcess(jobprefix+plugin, "iocage fetch -P "+plugin+" "+inet);
|
||||
retObject.insert("started_dispatcher_id", jobprefix+plugin);
|
||||
return retObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
static QJsonObject listReleases();
|
||||
static QJsonObject listPlugins();
|
||||
static QJsonObject fetchReleases(QJsonObject);
|
||||
static QJsonObject fetchPlugins(QJsonObject);
|
||||
static QJsonObject fetchPlugin(QJsonObject);
|
||||
static QJsonObject cleanTemplates();
|
||||
static QJsonObject cleanReleases();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user