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
0043974b
authored
Dec 22, 2013
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: add ovs support
parent
0c366826
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
16 deletions
+59
-16
firewall/fw.py
+12
-0
firewall/models.py
+4
-11
firewall/tasks.py
+43
-5
No files found.
firewall/fw.py
View file @
0043974b
...
...
@@ -500,3 +500,15 @@ for mac, name, ipend in [("18:a9:05:64:19:aa", "mega6", 16), ("00:1e:0b:e9:79:1e
print "nemok
%
s"
%
name
'''
def
vlan
():
obj
=
models
.
Vlan
.
objects
.
values
(
'vid'
,
'interface'
,
'ipv4'
,
'prefix4'
,
'ipv6'
,
'prefix6'
)
return
{
x
[
'interface'
]:
{
'tag'
:
x
[
'vid'
],
'type'
:
'internal'
,
'interfaces'
:
[
x
[
'interface'
]],
'addresses'
:
[
'
%
s/
%
s'
%
(
x
[
'ipv4'
],
x
[
'prefix4'
]),
'
%
s/
%
s'
%
(
x
[
'ipv6'
],
x
[
'prefix6'
])]}
for
x
in
obj
}
firewall/models.py
View file @
0043974b
...
...
@@ -8,7 +8,7 @@ from firewall.fields import *
from
south.modelsinspector
import
add_introspection_rules
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
import
django.conf
from
django.db.models.signals
import
post_save
from
django.db.models.signals
import
post_save
,
post_delete
import
re
import
random
...
...
@@ -416,13 +416,6 @@ def send_task(sender, instance, created, **kwargs):
from
firewall.tasks
import
ReloadTask
ReloadTask
.
apply_async
(
args
=
[
sender
.
__name__
])
post_save
.
connect
(
send_task
,
sender
=
Host
)
post_save
.
connect
(
send_task
,
sender
=
Rule
)
post_save
.
connect
(
send_task
,
sender
=
Domain
)
post_save
.
connect
(
send_task
,
sender
=
Record
)
post_save
.
connect
(
send_task
,
sender
=
Vlan
)
post_save
.
connect
(
send_task
,
sender
=
Firewall
)
post_save
.
connect
(
send_task
,
sender
=
Group
)
post_save
.
connect
(
send_task
,
sender
=
Host
)
post_save
.
connect
(
send_task
,
sender
=
Blacklist
)
for
sender
in
[
Host
,
Rule
,
Domain
,
Record
,
Vlan
,
Firewall
,
Group
,
Blacklist
]:
post_save
.
connect
(
send_task
,
sender
=
sender
)
# post_delete.connect(send_task, sender=sender)
firewall/tasks.py
View file @
0043974b
...
...
@@ -21,6 +21,28 @@ def reload_dhcp_task(data):
def
reload_blacklist_task
(
data
):
pass
# new tasks
@celery.task
(
name
=
'firewall.reload_firewall'
)
def
reload_firewall
(
data4
,
data6
):
pass
@celery.task
(
name
=
'firewall.reload_firewall_vlan'
)
def
reload_firewall_vlan
(
data
):
pass
@celery.task
(
name
=
'firewall.reload_dhcp'
)
def
reload_dhcp
(
data
):
pass
@celery.task
(
name
=
'firewall.reload_blacklist'
)
def
reload_blacklist
(
data
):
pass
class
Periodic
(
PeriodicTask
):
run_every
=
timedelta
(
seconds
=
10
)
...
...
@@ -34,20 +56,33 @@ class Periodic(PeriodicTask):
if
cache
.
get
(
'dhcp_lock'
):
cache
.
delete
(
"dhcp_lock"
)
reload_dhcp_task
.
delay
(
dhcp
())
reload_dhcp
_task
.
apply_async
((
dhcp
(),
)
,
queue
=
'dhcp2'
)
reload_dhcp
.
apply_async
(
args
=
[
dhcp
()]
,
queue
=
'dhcp2'
)
print
"dhcp ujratoltese kesz"
if
cache
.
get
(
'firewall_lock'
):
cache
.
delete
(
"firewall_lock"
)
ipv4
=
Firewall
()
.
get
()
ipv6
=
Firewall
(
True
)
.
get
()
reload_firewall_task
.
delay
(
ipv4
,
ipv6
)
reload_firewall_task
.
apply_async
((
ipv4
,
ipv6
),
queue
=
'firewall2'
)
# old
reload_firewall_task
.
apply_async
((
ipv4
,
ipv6
),
queue
=
'firewall'
)
# new
reload_firewall
.
apply_async
(
args
=
[
ipv4
,
ipv6
],
queue
=
'firewall2'
)
print
"firewall ujratoltese kesz"
if
cache
.
get
(
'firewall_vlan_lock'
):
cache
.
delete
(
"firewall_vlan_lock"
)
data
=
vlan
()
# reload_firewall_vlan.apply_async(args=[data], queue='firewall')
reload_firewall_vlan
.
apply_async
(
args
=
[
data
],
queue
=
'firewall2'
)
print
"firewall_vlan ujratoltese kesz"
if
cache
.
get
(
'blacklist_lock'
):
cache
.
delete
(
"blacklist_lock"
)
# old
reload_blacklist_task
.
delay
(
list
(
ipset
()))
# new
reload_blacklist
.
apply_async
(
args
=
[
list
(
ipset
())],
queue
=
'firewall2'
)
print
"blacklist ujratoltese kesz"
class
ReloadTask
(
Task
):
...
...
@@ -56,14 +91,17 @@ class ReloadTask(Task):
if
type
in
[
"Host"
,
"Records"
,
"Domain"
,
"Vlan"
]:
cache
.
add
(
"dns_lock"
,
"true"
,
30
)
if
type
==
"Host"
:
if
type
in
[
"Host"
,
"Vlan"
]
:
cache
.
add
(
"dhcp_lock"
,
"true"
,
30
)
if
type
in
[
"Host"
,
"Rule"
,
"Firewall"
]:
if
type
in
[
"Host"
,
"Rule"
,
"Firewall"
,
"Vlan"
]:
cache
.
add
(
"firewall_lock"
,
"true"
,
30
)
if
type
==
"Blacklist"
:
cache
.
add
(
"blacklist_lock"
,
"true"
,
30
)
if
type
in
[
"Vlan"
]:
cache
.
add
(
"firewall_vlan_lock"
,
"true"
,
30
)
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