Commit 8ddf8f87 by Kálmán Viktor

Merge branch 'synchronous_reload' into 'master'

Synchronous firewall reload

See merge request !345
parents acb2f78f 55a0a8e5
......@@ -23,5 +23,16 @@ from firewall.tasks.local_tasks import reloadtask
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('--sync',
action='store_const',
dest='sync',
const=True,
default=False,
help='synchronous reload')
def handle(self, *args, **options):
reloadtask('Vlan')
reloadtask('Vlan', sync=options["sync"])
......@@ -60,7 +60,7 @@ def get_firewall_queues():
return list(retval)
@celery.task(ignore_result=True)
@celery.task
def reloadtask_worker():
from firewall.fw import BuildFirewall, dhcp, dns, ipset, vlan
from remote_tasks import (reload_dns, reload_dhcp, reload_firewall,
......@@ -92,7 +92,7 @@ def reloadtask_worker():
@celery.task
def reloadtask(type='Host', timeout=15):
def reloadtask(type='Host', timeout=15, sync=False):
reload = {
'Host': ['dns', 'dhcp', 'firewall'],
'Record': ['dns'],
......@@ -107,4 +107,6 @@ def reloadtask(type='Host', timeout=15):
logger.info("Reload %s on next periodic iteration applying change to %s.",
", ".join(reload), type)
if all([cache.add("%s_lock" % i, 'true', 30) for i in reload]):
reloadtask_worker.apply_async(queue='localhost.man', countdown=5)
res = reloadtask_worker.apply_async(queue='localhost.man', countdown=5)
if sync:
res.get(15)
......@@ -31,7 +31,7 @@ python-dateutil==2.4.2
pyinotify==0.9.5
pytz==2015.4
requests==2.7.0
salt==2015.5.1
salt==2014.7.1
shutilwhich==1.1.0
simplejson==3.7.2
six==1.9.0
......
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 sign in to comment