Commit 6816eb2f authored by Ad Schellevis's avatar Ad Schellevis

(proxy) add cron for acl update

parent 6c02d112
...@@ -30,6 +30,7 @@ namespace OPNsense\Proxy\Api; ...@@ -30,6 +30,7 @@ namespace OPNsense\Proxy\Api;
use \OPNsense\Base\ApiControllerBase; use \OPNsense\Base\ApiControllerBase;
use \OPNsense\Proxy\Proxy; use \OPNsense\Proxy\Proxy;
use \OPNsense\Cron\Cron;
use \OPNsense\Core\Config; use \OPNsense\Core\Config;
use \OPNsense\Base\UIModelGrid; use \OPNsense\Base\UIModelGrid;
...@@ -266,4 +267,41 @@ class SettingsController extends ApiControllerBase ...@@ -266,4 +267,41 @@ class SettingsController extends ApiControllerBase
} }
return $result; return $result;
} }
/**
* create new cron item for remote acl or return already available one
* @return array status action
*/
public function fetchRBCronAction()
{
$result = array("result" => "failed");
if ($this->request->isPost()) {
$mdlProxy = new Proxy();
if ((string)$mdlProxy->forward->acl->remoteACLs->UpdateCron == "") {
$mdlCron = new Cron();
// update cron relation (if this doesn't break consistency)
$uuid = $mdlCron->newDailyJob("Proxy", "proxy fetchacls", "fetch proxy acls", "1");
$mdlProxy->forward->acl->remoteACLs->UpdateCron = $uuid;
if ($mdlCron->performValidation()->count() == 0) {
$mdlCron->serializeToConfig();
// save data to config, do not validate because the current in memory model doesn't know about the
// cron item just created.
$mdlProxy->serializeToConfig($validateFullModel = false, $disable_validation = true);
Config::getInstance()->save();
$result['result'] = "new";
$result['uuid'] = $uuid;
} else {
$result['result'] = "unable to add cron";
}
} else {
$result['result'] = "existing";
$result['uuid'] = (string)$mdlProxy->forward->acl->remoteACLs->UpdateCron;
}
}
return $result;
}
} }
...@@ -220,6 +220,20 @@ ...@@ -220,6 +220,20 @@
</description> </description>
</blacklist> </blacklist>
</blacklists> </blacklists>
<UpdateCron type="ModelRelationField">
<Model>
<queues>
<source>OPNsense.Cron.Cron</source>
<items>jobs.job</items>
<display>description</display>
<filters>
<origin>/Proxy/</origin>
</filters>
</queues>
</Model>
<ValidationMessage>Related cron not found</ValidationMessage>
<Required>N</Required>
</UpdateCron>
</remoteACLs> </remoteACLs>
</acl> </acl>
<authentication> <authentication>
......
...@@ -58,7 +58,7 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -58,7 +58,7 @@ POSSIBILITY OF SUCH DAMAGE.
/** /**
* *
* Reconfigure poxy - activate changes * Reconfigure proxy - activate changes
*/ */
$("#reconfigureAct").click(function(){ $("#reconfigureAct").click(function(){
$("#reconfigureAct_progress").addClass("fa fa-spinner fa-pulse"); $("#reconfigureAct_progress").addClass("fa fa-spinner fa-pulse");
...@@ -97,6 +97,20 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -97,6 +97,20 @@ POSSIBILITY OF SUCH DAMAGE.
}); });
}); });
/**
* setup cron item
*/
$("#ScheduleAct").click(function() {
$("#scheduleAct_progress").addClass("fa fa-spinner fa-pulse");
ajaxCall(url="/api/proxy/settings/fetchRBCron", sendData={}, callback=function(data,status) {
$("#scheduleAct_progress").removeClass("fa fa-spinner fa-pulse");
if (data.uuid !=undefined) {
// redirect to cron page
$(location).attr('href',"/ui/cron/item/open/"+data.uuid);
}
});
});
// form save event handlers for all defined forms // form save event handlers for all defined forms
$('[id*="save_"]').each(function(){ $('[id*="save_"]').each(function(){
$(this).click(function() { $(this).click(function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment