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
2e48479d
authored
Oct 12, 2014
by
Bach Dániel
Committed by
Your Name
Oct 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix logging
parent
5283434f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
fw.py
+5
-5
ovs.py
+10
-10
No files found.
fw.py
View file @
2e48479d
...
...
@@ -32,7 +32,7 @@ def reload_firewall(data4, data6, save_config=True):
ns_exec
((
'ip6tables-restore'
,
'-c'
),
data6
)
ns_exec
((
'iptables-restore'
,
'-c'
),
data4
)
except
:
logging
.
critical
(
'Unhandled exception: '
,
exc_info
=
True
)
logging
.
exception
(
'Unhandled exception: '
)
raise
if
save_config
:
...
...
@@ -146,8 +146,8 @@ def start_firewall():
with
open
(
FIREWALL_CONF
,
'r'
)
as
f
:
data4
,
data6
=
json
.
load
(
f
)
reload_firewall
(
data4
,
data6
,
True
)
except
Exception
as
e
:
logger
.
e
rror
(
'Unhandled exception:
%
s'
,
unicode
(
e
)
)
except
Exception
:
logger
.
e
xception
(
'Unhandled exception: '
)
def
start_networking
():
...
...
@@ -155,8 +155,8 @@ def start_networking():
with
open
(
VLAN_CONF
,
'r'
)
as
f
:
data
=
json
.
load
(
f
)
reload_firewall_vlan
(
data
,
True
)
except
Exception
as
e
:
logger
.
e
rror
(
'Unhandled exception:
%
s'
,
unicode
(
e
)
)
except
Exception
:
logger
.
e
xception
(
'Unhandled exception: '
)
def
main
():
...
...
ovs.py
View file @
2e48479d
...
...
@@ -5,7 +5,6 @@ import logging
from
utils
import
NETNS
,
sudo
,
ns_exec
,
HA
logger
=
logging
.
getLogger
(
__name__
)
logger
.
setLevel
(
logging
.
INFO
)
class
Interface
(
object
):
...
...
@@ -34,9 +33,9 @@ class Interface(object):
self
.
addresses
=
frozenset
()
def
__repr__
(
self
):
return
'<Interface:
%
s veth=
%
s|
%
s>'
%
(
self
.
name
,
self
.
is_veth
,
(
self
.
untagged
,
self
.
tagged
,
self
.
addresses
)
)
return
'<Interface:
%
s veth=
%
s|
untagged=
%
s tagged=
%
s addrs=
%
s>'
%
(
self
.
name
,
self
.
is_veth
,
self
.
untagged
,
self
.
tagged
,
self
.
addresses
)
def
__eq__
(
self
,
other
):
return
self
.
__dict__
==
other
.
__dict__
...
...
@@ -68,7 +67,7 @@ class Interface(object):
except
CalledProcessError
:
pass
logger
.
debug
(
'[ip-
%
s] show:
%
s'
%
(
self
.
name
,
str
(
retval
)
))
logger
.
debug
(
'[ip-
%
s] show:
%
s'
,
self
.
name
,
str
(
retval
))
return
retval
def
delete_address
(
self
,
address
):
...
...
@@ -88,8 +87,8 @@ class Interface(object):
to_delete
=
list
(
set
(
old_addresses
)
-
set
(
new_addresses
))
to_add
=
list
(
set
(
new_addresses
)
-
set
(
old_addresses
))
logger
.
debug
(
'[ip-
%
s] delete:
%
s'
%
(
self
.
name
,
str
(
to_delete
)
))
logger
.
debug
(
'[ip-
%
s] add:
%
s'
%
(
self
.
name
,
str
(
to_add
)
))
logger
.
debug
(
'[ip-
%
s] delete:
%
s'
,
self
.
name
,
str
(
to_delete
))
logger
.
debug
(
'[ip-
%
s] add:
%
s'
,
self
.
name
,
str
(
to_add
))
for
i
in
to_delete
:
self
.
delete_address
(
i
)
...
...
@@ -118,6 +117,7 @@ class Switch(object):
ovs
=
{}
bridge
=
None
port
=
None
# parse ovs-vsctl show
for
line
in
self
.
_run
(
'show'
)
.
splitlines
():
t
=
line
.
split
()
if
t
[
0
]
==
'Bridge'
:
...
...
@@ -155,7 +155,7 @@ class Switch(object):
'type'
,
'veth'
,
'peer'
,
'name'
,
interface
.
name
))
self
.
_setns
(
interface
.
name
)
except
:
pass
logger
.
exception
(
'Unhandled exception: '
)
self
.
_run
(
*
params
)
def
delete_port
(
self
,
interface
):
...
...
@@ -179,8 +179,8 @@ class Switch(object):
add
=
list
(
set
(
new_interfaces
)
.
difference
(
set
(
old_interfaces
)))
delete
=
list
(
set
(
old_interfaces
)
.
difference
(
set
(
new_interfaces
)))
logger
.
debug
(
'[ovs delete]:
%
s'
%
delete
)
logger
.
debug
(
'[ovs add]:
%
s'
%
add
)
logger
.
debug
(
'[ovs delete]:
%
s'
,
delete
)
logger
.
debug
(
'[ovs add]:
%
s'
,
add
)
for
interface
in
delete
:
self
.
delete_port
(
interface
)
...
...
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