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
b1757b8c
authored
Feb 24, 2015
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow BRIDGE_TYPE=NONE option
parent
bbcea33e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
fw.py
+6
-8
utils.py
+13
-0
No files found.
fw.py
View file @
b1757b8c
...
@@ -4,8 +4,7 @@ import re
...
@@ -4,8 +4,7 @@ import re
import
json
import
json
import
logging
import
logging
from
ovs
import
Switch
,
Bridge
from
utils
import
(
ns_exec
,
sudo
,
ADDRESSES
,
get_network_type
,
from
utils
import
(
ns_exec
,
sudo
,
ADDRESSES
,
dhcp_no_free_re
,
dhcp_ack_re
)
dhcp_no_free_re
,
dhcp_ack_re
)
DHCP_LOGFILE
=
getenv
(
'DHCP_LOGFILE'
,
'/var/log/syslog'
)
DHCP_LOGFILE
=
getenv
(
'DHCP_LOGFILE'
,
'/var/log/syslog'
)
...
@@ -26,12 +25,6 @@ celery.conf.update(CELERY_CACHE_BACKEND=CACHE_URI,
...
@@ -26,12 +25,6 @@ celery.conf.update(CELERY_CACHE_BACKEND=CACHE_URI,
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
if
getenv
(
'BRIDGE_TYPE'
,
'OVS'
)
==
'BRIDGE'
:
network_type
=
Bridge
else
:
network_type
=
Switch
@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
):
try
:
try
:
...
@@ -50,6 +43,11 @@ def reload_firewall(data4, data6, save_config=True):
...
@@ -50,6 +43,11 @@ def reload_firewall(data4, data6, save_config=True):
@task
(
name
=
"firewall.reload_firewall_vlan"
)
@task
(
name
=
"firewall.reload_firewall_vlan"
)
def
reload_firewall_vlan
(
data
,
save_config
=
True
):
def
reload_firewall_vlan
(
data
,
save_config
=
True
):
network_type
=
get_network_type
()
if
network_type
is
None
:
logger
.
info
(
"Ignored reload_firewall_vlan() network type=
%
s"
,
network_type
)
return
# Add additional addresses from config
# Add additional addresses from config
for
k
,
v
in
ADDRESSES
.
items
():
for
k
,
v
in
ADDRESSES
.
items
():
data
[
k
][
'addresses'
]
+=
v
data
[
k
][
'addresses'
]
+=
v
...
...
utils.py
View file @
b1757b8c
...
@@ -13,6 +13,16 @@ MAC = getenv('MAC')
...
@@ -13,6 +13,16 @@ MAC = getenv('MAC')
ADDRESSES
=
json
.
loads
(
getenv
(
'ADDRESSES'
,
'{}'
))
ADDRESSES
=
json
.
loads
(
getenv
(
'ADDRESSES'
,
'{}'
))
HA
=
bool
(
getenv
(
'HA'
,
False
))
HA
=
bool
(
getenv
(
'HA'
,
False
))
def
get_network_type
():
from
ovs
import
Switch
,
Bridge
if
getenv
(
'BRIDGE_TYPE'
,
'OVS'
)
==
'BRIDGE'
:
return
Bridge
elif
getenv
(
'BRIDGE_TYPE'
,
'OVS'
)
==
'NONE'
:
return
None
else
:
return
Switch
# 2013-06-26 12:16:59 DHCPACK on 10.4.0.14 to 5c:b5:24:e6:5c:81
# 2013-06-26 12:16:59 DHCPACK on 10.4.0.14 to 5c:b5:24:e6:5c:81
# (android_b555bfdba7c837d) via vlan0004
# (android_b555bfdba7c837d) via vlan0004
...
@@ -45,5 +55,8 @@ def sudo(args, stdin=None):
...
@@ -45,5 +55,8 @@ def sudo(args, stdin=None):
def
ns_exec
(
args
,
stdin
=
None
):
def
ns_exec
(
args
,
stdin
=
None
):
if
get_network_type
()
is
None
:
return
sudo
(
args
,
stdin
)
else
:
return
sudo
((
'/sbin/ip'
,
'netns'
,
'exec'
,
return
sudo
((
'/sbin/ip'
,
'netns'
,
'exec'
,
NETNS
)
+
args
,
stdin
)
NETNS
)
+
args
,
stdin
)
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