Commit cd813da7 authored by Marco Mariani's avatar Marco Mariani

provided (mandatory) logger to Interface instances

parent 77035bfa
...@@ -179,6 +179,8 @@ def _getDict(instance): ...@@ -179,6 +179,8 @@ def _getDict(instance):
return instance return instance
result = {} result = {}
for key, value in dikt.iteritems(): for key, value in dikt.iteritems():
# do not attempt to serialize logger: it is both useless and recursive.
if not isinstance(instance, logging.Logger):
result[key] = _getDict(value) result[key] = _getDict(value)
return result return result
...@@ -663,7 +665,7 @@ class Tap(object): ...@@ -663,7 +665,7 @@ class Tap(object):
class Interface(object): class Interface(object):
"""Represent a network interface on the system""" """Represent a network interface on the system"""
def __init__(self, name, ipv4_local_network, ipv6_interface=None, logger=None): def __init__(self, logger, name, ipv4_local_network, ipv6_interface=None):
""" """
Attributes: Attributes:
name: String, the name of the interface name: String, the name of the interface
...@@ -924,8 +926,8 @@ def parse_computer_definition(config, definition_path): ...@@ -924,8 +926,8 @@ def parse_computer_definition(config, definition_path):
address, netmask = computer_definition.get('computer', 'address').split('/') address, netmask = computer_definition.get('computer', 'address').split('/')
if config.alter_network and config.interface_name is not None \ if config.alter_network and config.interface_name is not None \
and config.ipv4_local_network is not None: and config.ipv4_local_network is not None:
interface = Interface(config.interface_name, config.ipv4_local_network, interface = Interface(config.logger, config.interface_name, config.ipv4_local_network,
config.ipv6_interface, logger=config.logger) config.ipv6_interface)
computer = Computer( computer = Computer(
reference=config.computer_id, reference=config.computer_id,
interface=interface, interface=interface,
...@@ -961,14 +963,14 @@ def parse_computer_xml(config, xml_path): ...@@ -961,14 +963,14 @@ def parse_computer_xml(config, xml_path):
reference=config.computer_id, reference=config.computer_id,
ipv6_interface=config.ipv6_interface) ipv6_interface=config.ipv6_interface)
# Connect to the interface defined by the configuration # Connect to the interface defined by the configuration
computer.interface = Interface(config.interface_name, config.ipv4_local_network, computer.interface = Interface(config.logger, config.interface_name, config.ipv4_local_network,
config.ipv6_interface) config.ipv6_interface)
else: else:
# If no pre-existent configuration found, create a new computer object # If no pre-existent configuration found, create a new computer object
config.logger.warning('Creating new data computer with id %r' % config.computer_id) config.logger.warning('Creating new data computer with id %r' % config.computer_id)
computer = Computer( computer = Computer(
reference=config.computer_id, reference=config.computer_id,
interface=Interface(config.interface_name, config.ipv4_local_network, interface=Interface(config.logger, config.interface_name, config.ipv4_local_network,
config.ipv6_interface), config.ipv6_interface),
addr=None, addr=None,
netmask=None, netmask=None,
......
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 to comment