Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d7c23416
authored
Sep 30, 2013
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: refactoring tasks
parent
49173ff9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
34 deletions
+37
-34
circle/firewall/models.py
+2
-2
circle/firewall/tasks/__init__.py
+0
-0
circle/firewall/tasks/local_tasks.py
+7
-31
circle/firewall/tasks/remote_tasks.py
+26
-0
circle/manager/mancelery.py
+2
-1
No files found.
circle/firewall/models.py
View file @
d7c23416
...
@@ -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
)
...
...
circle/firewall/tasks/__init__.py
0 → 100644
View file @
d7c23416
circle/firewall/tasks.py
→
circle/firewall/tasks
/local_tasks
.py
View file @
d7c23416
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
())
re
mote_tasks
.
re
load_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
)
re
mote_tasks
.
re
load_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
()))
re
mote_tasks
.
re
load_blacklist_task
.
delay
(
list
(
ipset
()))
print
"blacklist ujratoltese kesz"
print
"blacklist ujratoltese kesz"
...
...
circle/firewall/tasks/remote_tasks.py
0 → 100644
View file @
d7c23416
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
circle/manager/mancelery.py
View file @
d7c23416
...
@@ -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
=
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment