Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
fwdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
efb55aec
authored
Mar 27, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(re)add LEGACY firewall support
parent
f9472799
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
fw.py
+15
-8
No files found.
fw.py
View file @
efb55aec
...
@@ -14,25 +14,32 @@ FIREWALL_CONF = getenv('FIREWALL_CONF', 'firewall.conf')
...
@@ -14,25 +14,32 @@ FIREWALL_CONF = getenv('FIREWALL_CONF', 'firewall.conf')
CACHE_URI
=
getenv
(
'CACHE_URI'
)
CACHE_URI
=
getenv
(
'CACHE_URI'
)
AMQP_URI
=
getenv
(
'AMQP_URI'
)
AMQP_URI
=
getenv
(
'AMQP_URI'
)
LEGACY
=
getenv
(
'LEGACY'
,
'False'
)
.
upper
()
==
'TRUE'
celery
=
Celery
(
'tasks'
,)
celery
=
Celery
(
'tasks'
,)
celery
.
conf
.
update
(
CELERY_CACHE_BACKEND
=
CACHE_URI
,
celery
.
conf
.
update
(
CELERY_TASK_RESULT_EXPIRES
=
300
,
CELERY_RESULT_BACKEND
=
'cache'
,
CELERY_TASK_RESULT_EXPIRES
=
300
,
BROKER_URL
=
AMQP_URI
,
BROKER_URL
=
AMQP_URI
,
CELERY_CREATE_MISSING_QUEUES
=
True
)
CELERY_CREATE_MISSING_QUEUES
=
True
)
if
not
LEGACY
:
celery
.
conf
.
update
(
CELERY_CACHE_BACKEND
=
CACHE_URI
,
CELERY_RESULT_BACKEND
=
'cache'
)
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
@task
(
name
=
"firewall.reload_firewall"
)
@task
(
name
=
"firewall.reload_firewall"
)
def
reload_firewall
(
data4
,
data6
,
save_config
=
True
):
def
reload_firewall
(
data4
,
data6
,
save_config
=
True
):
ns_exec
(
NETNS
,
(
'/sbin/ip6tables-restore'
,
'-c'
),
if
isinstance
(
data4
,
dict
):
'
\n
'
.
join
(
data6
[
'filter'
])
+
'
\n
'
)
data4
=
(
'
\n
'
.
join
(
data4
[
'filter'
])
+
'
\n
'
+
'
\n
'
.
join
(
data4
[
'nat'
])
+
'
\n
'
)
if
isinstance
(
data6
,
dict
):
data6
=
(
'
\n
'
.
join
(
data6
[
'filter'
])
+
'
\n
'
)
ns_exec
(
NETNS
,
(
'/sbin/ip6tables-restore'
,
'-c'
),
data6
)
ns_exec
(
NETNS
,
(
'/sbin/iptables-restore'
,
'-c'
),
ns_exec
(
NETNS
,
(
'/sbin/iptables-restore'
,
'-c'
),
data4
)
(
'
\n
'
.
join
(
data4
[
'filter'
])
+
'
\n
'
+
'
\n
'
.
join
(
data4
[
'nat'
])
+
'
\n
'
))
if
save_config
:
if
save_config
:
with
open
(
FIREWALL_CONF
,
'w'
)
as
f
:
with
open
(
FIREWALL_CONF
,
'w'
)
as
f
:
...
...
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