Commit 2e48479d by Bach Dániel Committed by Your Name

fix logging

parent 5283434f
...@@ -32,7 +32,7 @@ def reload_firewall(data4, data6, save_config=True): ...@@ -32,7 +32,7 @@ def reload_firewall(data4, data6, save_config=True):
ns_exec(('ip6tables-restore', '-c'), data6) ns_exec(('ip6tables-restore', '-c'), data6)
ns_exec(('iptables-restore', '-c'), data4) ns_exec(('iptables-restore', '-c'), data4)
except: except:
logging.critical('Unhandled exception: ', exc_info=True) logging.exception('Unhandled exception: ')
raise raise
if save_config: if save_config:
...@@ -146,8 +146,8 @@ def start_firewall(): ...@@ -146,8 +146,8 @@ def start_firewall():
with open(FIREWALL_CONF, 'r') as f: with open(FIREWALL_CONF, 'r') as f:
data4, data6 = json.load(f) data4, data6 = json.load(f)
reload_firewall(data4, data6, True) reload_firewall(data4, data6, True)
except Exception as e: except Exception:
logger.error('Unhandled exception: %s', unicode(e)) logger.exception('Unhandled exception: ')
def start_networking(): def start_networking():
...@@ -155,8 +155,8 @@ def start_networking(): ...@@ -155,8 +155,8 @@ def start_networking():
with open(VLAN_CONF, 'r') as f: with open(VLAN_CONF, 'r') as f:
data = json.load(f) data = json.load(f)
reload_firewall_vlan(data, True) reload_firewall_vlan(data, True)
except Exception as e: except Exception:
logger.error('Unhandled exception: %s', unicode(e)) logger.exception('Unhandled exception: ')
def main(): def main():
......
...@@ -5,7 +5,6 @@ import logging ...@@ -5,7 +5,6 @@ import logging
from utils import NETNS, sudo, ns_exec, HA from utils import NETNS, sudo, ns_exec, HA
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
class Interface(object): class Interface(object):
...@@ -34,9 +33,9 @@ class Interface(object): ...@@ -34,9 +33,9 @@ class Interface(object):
self.addresses = frozenset() self.addresses = frozenset()
def __repr__(self): def __repr__(self):
return '<Interface: %s veth=%s| %s>' % ( return '<Interface: %s veth=%s| untagged=%s tagged=%s addrs=%s>' % (
self.name, self.is_veth, (self.untagged, self.tagged, self.name, self.is_veth, self.untagged, self.tagged,
self.addresses)) self.addresses)
def __eq__(self, other): def __eq__(self, other):
return self.__dict__ == other.__dict__ return self.__dict__ == other.__dict__
...@@ -68,7 +67,7 @@ class Interface(object): ...@@ -68,7 +67,7 @@ class Interface(object):
except CalledProcessError: except CalledProcessError:
pass pass
logger.debug('[ip-%s] show: %s' % (self.name, str(retval))) logger.debug('[ip-%s] show: %s', self.name, str(retval))
return retval return retval
def delete_address(self, address): def delete_address(self, address):
...@@ -88,8 +87,8 @@ class Interface(object): ...@@ -88,8 +87,8 @@ class Interface(object):
to_delete = list(set(old_addresses) - set(new_addresses)) to_delete = list(set(old_addresses) - set(new_addresses))
to_add = list(set(new_addresses) - set(old_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] delete: %s', self.name, str(to_delete))
logger.debug('[ip-%s] add: %s' % (self.name, str(to_add))) logger.debug('[ip-%s] add: %s', self.name, str(to_add))
for i in to_delete: for i in to_delete:
self.delete_address(i) self.delete_address(i)
...@@ -118,6 +117,7 @@ class Switch(object): ...@@ -118,6 +117,7 @@ class Switch(object):
ovs = {} ovs = {}
bridge = None bridge = None
port = None port = None
# parse ovs-vsctl show
for line in self._run('show').splitlines(): for line in self._run('show').splitlines():
t = line.split() t = line.split()
if t[0] == 'Bridge': if t[0] == 'Bridge':
...@@ -155,7 +155,7 @@ class Switch(object): ...@@ -155,7 +155,7 @@ class Switch(object):
'type', 'veth', 'peer', 'name', interface.name)) 'type', 'veth', 'peer', 'name', interface.name))
self._setns(interface.name) self._setns(interface.name)
except: except:
pass logger.exception('Unhandled exception: ')
self._run(*params) self._run(*params)
def delete_port(self, interface): def delete_port(self, interface):
...@@ -179,8 +179,8 @@ class Switch(object): ...@@ -179,8 +179,8 @@ class Switch(object):
add = list(set(new_interfaces).difference(set(old_interfaces))) add = list(set(new_interfaces).difference(set(old_interfaces)))
delete = list(set(old_interfaces).difference(set(new_interfaces))) delete = list(set(old_interfaces).difference(set(new_interfaces)))
logger.debug('[ovs delete]: %s' % delete) logger.debug('[ovs delete]: %s', delete)
logger.debug('[ovs add]: %s' % add) logger.debug('[ovs add]: %s', add)
for interface in delete: for interface in delete:
self.delete_port(interface) self.delete_port(interface)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment