Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
ff4144e6
authored
Mar 05, 2013
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: celery periodic task added
parent
8b14a3f3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
27 deletions
+31
-27
cloud/settings.py
+1
-0
firewall/tasks.py
+30
-27
No files found.
cloud/settings.py
View file @
ff4144e6
...
@@ -187,6 +187,7 @@ CELERY_ROUTES = {
...
@@ -187,6 +187,7 @@ CELERY_ROUTES = {
'firewall.tasks.reload_firewall_task'
:
{
'queue'
:
'firewall'
},
'firewall.tasks.reload_firewall_task'
:
{
'queue'
:
'firewall'
},
'firewall.tasks.reload_dhcp_task'
:
{
'queue'
:
'dhcp'
},
'firewall.tasks.reload_dhcp_task'
:
{
'queue'
:
'dhcp'
},
'firewall.tasks.reload_blacklist_task'
:
{
'queue'
:
'firewall'
},
'firewall.tasks.reload_blacklist_task'
:
{
'queue'
:
'firewall'
},
'firewall.tasks.Periodic'
:
{
'queue'
:
'local'
},
}
}
store_settings
=
{
store_settings
=
{
...
...
firewall/tasks.py
View file @
ff4144e6
...
@@ -19,44 +19,47 @@ def reload_dhcp_task(data):
...
@@ -19,44 +19,47 @@ def reload_dhcp_task(data):
def
reload_blacklist_task
(
data
):
def
reload_blacklist_task
(
data
):
pass
pass
class
ReloadTask
(
Task
):
class
Periodic
(
Periodic
Task
):
def
run
(
self
,
type
=
'Host'
):
run_every
=
timedelta
(
seconds
=
60
)
sleep
=
False
def
run
(
self
,
**
kwargs
):
if
type
in
[
"Host"
,
"Records"
,
"Domain"
,
"Vlan"
]:
if
cache
.
get
(
'dns_lock'
):
lock
=
lambda
:
cache
.
add
(
"dns_lock"
,
"true"
,
9
)
cache
.
delete
(
"dns_lock"
)
if
lock
():
if
not
sleep
:
sleep
=
True
time
.
sleep
(
10
)
reload_dns_task
.
delay
(
dns
())
reload_dns_task
.
delay
(
dns
())
print
"dns ujratoltese kesz"
if
type
==
"Host"
:
if
cache
.
get
(
'dhcp_lock'
):
lock
=
lambda
:
cache
.
add
(
"dhcp_lock"
,
"true"
,
9
)
cache
.
delete
(
"dhcp_lock"
)
if
lock
():
if
not
sleep
:
sleep
=
True
time
.
sleep
(
10
)
reload_dhcp_task
.
delay
(
dhcp
())
reload_dhcp_task
.
delay
(
dhcp
())
print
"dhcp ujratoltese kesz"
if
type
in
[
"Host"
,
"Rule"
,
"Firewall"
]:
if
cache
.
get
(
'firewall_lock'
):
lock
=
lambda
:
cache
.
add
(
"firewall_lock"
,
"true"
,
9
)
cache
.
delete
(
"firewall_lock"
)
if
lock
():
if
not
sleep
:
sleep
=
True
time
.
sleep
(
10
)
ipv4
=
Firewall
()
.
get
()
ipv4
=
Firewall
()
.
get
()
ipv6
=
Firewall
(
True
)
.
get
()
ipv6
=
Firewall
(
True
)
.
get
()
reload_firewall_task
.
delay
(
ipv4
,
ipv6
)
reload_firewall_task
.
delay
(
ipv4
,
ipv6
)
print
"firewall ujratoltese kesz"
if
type
==
"Blacklist"
:
if
cache
.
get
(
'blacklist_lock'
):
lock
=
lambda
:
cache
.
add
(
"blacklist_lock"
,
"true"
,
9
)
cache
.
delete
(
"blacklist_lock"
)
if
lock
():
if
not
sleep
:
sleep
=
True
time
.
sleep
(
10
)
reload_blacklist_task
.
delay
(
list
(
ipset
()))
reload_blacklist_task
.
delay
(
list
(
ipset
()))
print
"blacklist ujratoltese kesz"
class
ReloadTask
(
Task
):
def
run
(
self
,
type
=
'Host'
):
if
type
in
[
"Host"
,
"Records"
,
"Domain"
,
"Vlan"
]:
cache
.
add
(
"dns_lock"
,
"true"
,
30
)
if
type
==
"Host"
:
cache
.
add
(
"dhcp_lock"
,
"true"
,
30
)
if
type
in
[
"Host"
,
"Rule"
,
"Firewall"
]:
cache
.
add
(
"firewall_lock"
,
"true"
,
30
)
if
type
==
"Blacklist"
:
cache
.
add
(
"blacklist_lock"
,
"true"
,
30
)
print
type
print
type
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