Commit 696bce30 by Czémán Arnold

firewall: add --timeout switch for reload_firewall_command

parent d5c57c8f
...@@ -21,6 +21,8 @@ from django.core.management.base import BaseCommand ...@@ -21,6 +21,8 @@ from django.core.management.base import BaseCommand
from firewall.tasks.local_tasks import reloadtask from firewall.tasks.local_tasks import reloadtask
from argparse import ArgumentTypeError
class Command(BaseCommand): class Command(BaseCommand):
...@@ -33,6 +35,20 @@ class Command(BaseCommand): ...@@ -33,6 +35,20 @@ class Command(BaseCommand):
default=False, default=False,
help='synchronous reload') help='synchronous reload')
parser.add_argument('--timeout',
action='store',
dest='timeout',
default=15,
type=self.positive_int,
help='timeout for synchronous reload')
def handle(self, *args, **options): def handle(self, *args, **options):
reloadtask('Vlan', sync=options["sync"]) reloadtask('Vlan', sync=options["sync"], timeout=options["timeout"])
def positive_int(self, val):
if not val.isdigit():
raise ArgumentTypeError("'%s' is not a valid positive int" % val)
return int(val)
...@@ -109,4 +109,4 @@ def reloadtask(type='Host', timeout=15, sync=False): ...@@ -109,4 +109,4 @@ def reloadtask(type='Host', timeout=15, sync=False):
if all([cache.add("%s_lock" % i, 'true', 30) for i in reload]): if all([cache.add("%s_lock" % i, 'true', 30) for i in reload]):
res = reloadtask_worker.apply_async(queue='localhost.man', countdown=5) res = reloadtask_worker.apply_async(queue='localhost.man', countdown=5)
if sync: if sync:
res.get(15) res.get(timeout)
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