Commit d7c23416 by Guba Sándor

firewall: refactoring tasks

parent 49173ff9
...@@ -778,8 +778,8 @@ class Blacklist(models.Model): ...@@ -778,8 +778,8 @@ class Blacklist(models.Model):
def send_task(sender, instance, created, **kwargs): def send_task(sender, instance, created, **kwargs):
from firewall.tasks import reloadtask from firewall.tasks.local_tasks import reloadtask
reloadtask.apply_async(args=[sender.__name__]) reloadtask.apply_async(args=[sender.__name__], queue='localhost.firewall')
post_save.connect(send_task, sender=Host) post_save.connect(send_task, sender=Host)
......
import celery from manager.mancelery import celery
from django.core.cache import cache from django.core.cache import cache
from firewall.fw import Firewall, dhcp, dns, ipset from firewall.fw import Firewall, dhcp, dns, ipset
import django.conf import django.conf
import remote_tasks
settings = django.conf.settings.FIREWALL_SETTINGS settings = django.conf.settings.FIREWALL_SETTINGS
@celery.task @celery.task
def reload_dns_task(data):
pass
@celery.task
def reload_firewall_task(data4, data6):
pass
@celery.task
def reload_dhcp_task(data):
pass
@celery.task
def reload_blacklist_task(data):
pass
@celery.task
def get_dhcp_clients_task(data):
pass
@celery.task
def periodic_task(): def periodic_task():
if cache.get('dns_lock'): if cache.get('dns_lock'):
cache.delete("dns_lock") cache.delete("dns_lock")
reload_dns_task.delay(dns()) remote_tasks.reload_dns_task.apply_async(args=[dns()],
queue='firewall')
print "dns ujratoltese kesz" print "dns ujratoltese kesz"
if cache.get('dhcp_lock'): if cache.get('dhcp_lock'):
cache.delete("dhcp_lock") cache.delete("dhcp_lock")
reload_dhcp_task.delay(dhcp()) remote_tasks.reload_dhcp_task.delay(dhcp())
print "dhcp ujratoltese kesz" print "dhcp ujratoltese kesz"
if cache.get('firewall_lock'): if cache.get('firewall_lock'):
cache.delete("firewall_lock") cache.delete("firewall_lock")
ipv4 = Firewall().get() ipv4 = Firewall().get()
ipv6 = Firewall(True).get() ipv6 = Firewall(True).get()
reload_firewall_task.delay(ipv4, ipv6) remote_tasks.reload_firewall_task.delay(ipv4, ipv6)
print "firewall ujratoltese kesz" print "firewall ujratoltese kesz"
if cache.get('blacklist_lock'): if cache.get('blacklist_lock'):
cache.delete("blacklist_lock") cache.delete("blacklist_lock")
reload_blacklist_task.delay(list(ipset())) remote_tasks.reload_blacklist_task.delay(list(ipset()))
print "blacklist ujratoltese kesz" print "blacklist ujratoltese kesz"
......
from manager.mancelery import celery
@celery.task(name='firewall.reload_dns')
def reload_dns(data):
pass
@celery.task(name='firewall.reload_firewall')
def reload_firewall(data4, data6):
pass
@celery.task(name='firewall.reload_dhcp')
def reload_dhcp(data):
pass
@celery.task(name='firewall.reload_blacklist')
def reload_blacklist(data):
pass
@celery.task(name='firewall.get_dhcp_clients')
def get_dhcp_clients(data):
pass
...@@ -6,7 +6,8 @@ HOSTNAME = "localhost" ...@@ -6,7 +6,8 @@ HOSTNAME = "localhost"
celery = Celery('manager', backend='amqp', celery = Celery('manager', backend='amqp',
broker=getenv("AMQP_URI"), broker=getenv("AMQP_URI"),
include=['vm.tasks.local_tasks', 'storage.tasks.local_tasks']) include=['vm.tasks.local_tasks', 'storage.tasks.local_tasks',
'firewall.tasks.local_tasks'])
celery.conf.update( celery.conf.update(
CELERY_QUEUES=( CELERY_QUEUES=(
......
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