From 56d73814dbf00b97cb7b9a3a8250a1de6256f752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Mon, 14 Jul 2014 04:14:20 +0200 Subject: [PATCH] =?UTF-8?q?[trigger]=20Am=C3=A9lioration=20de=20lisibilit?= =?UTF-8?q?=C3=A9=20dans=20les=20logs,=20et=20correctif=20mineur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Ordre des imports dans le service firewall foireux --- gestion/trigger/services/dhcp.py | 19 +++++++++++++++---- gestion/trigger/services/event.py | 2 +- gestion/trigger/services/firewall.py | 2 +- gestion/trigger/trigger.py | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gestion/trigger/services/dhcp.py b/gestion/trigger/services/dhcp.py index 93278084..b9d07a98 100644 --- a/gestion/trigger/services/dhcp.py +++ b/gestion/trigger/services/dhcp.py @@ -6,6 +6,11 @@ # # Author : Pierre-Elliott Bécue # Licence : GPLv3 +# Date : 14/07/2014 +# +# TODO : Take care of each XXX or TODO think about updating +# gestion/config/dhcp when submitting for production, because +# of .test files. import socket import os @@ -78,12 +83,18 @@ class Dhcp(BasicService): if body and isinstance(body, dict): for (mac, ip, name) in body.get("add", []): - cls.add_dhcp_host(mac, ip, name) + logger.info("Updating DHCP db by adding %s, %s, %s", mac, ip, name) + # XXX - Uncommend this when we need to start prod + # cls.add_dhcp_host(mac, ip, name) for (mac, ip) in body.get("delete", []): - cls.delete_dhcp_host(mac, ip) + logger.info("Updating DHCP db by deleting %s, %s", mac, ip) + # XXX - Uncommend this when we need to start prod + # cls.delete_dhcp_host(mac, ip) for (rmac, rip, mac, ip, name) in body.get("update", []): - cls.delete_dhcp_host(rmac, rip) - cls.add_dhcp_host(mac, ip, name) + logger.info("Updating DHCP db by modifying %s, %s to %s, %s, %s", rmac, rip, mac, ip, name) + # XXX - Uncommend this when we need to start prod + # cls.delete_dhcp_host(rmac, rip) + # cls.add_dhcp_host(mac, ip, name) elif body == True: hosts = {} host_template = """ diff --git a/gestion/trigger/services/event.py b/gestion/trigger/services/event.py index 56b5a473..c26e0f63 100644 --- a/gestion/trigger/services/event.py +++ b/gestion/trigger/services/event.py @@ -48,7 +48,7 @@ class EventProducer(cmb.BasicProducer): """Extended """ - logger.info("Starting trigger EventProducer program…") + logger.info("Starting trigger EventProducer program for app %s…", app_id) super(EventProducer, self).__init__(trigger_config.master, 'trigger', app_id) self._connection = self.connect() self.get_chan() diff --git a/gestion/trigger/services/firewall.py b/gestion/trigger/services/firewall.py index 203e2adb..fd4332dc 100644 --- a/gestion/trigger/services/firewall.py +++ b/gestion/trigger/services/firewall.py @@ -15,11 +15,11 @@ it to regenerate what needs to. """ import cranslib.clogger as clogger +import gestion.config.trigger as trigger_config logger = clogger.CLogger("trigger", "firewall", "debug", trigger_config.debug) import lc_ldap.shortcuts -import gestion.config.trigger as trigger_config from gestion.trigger.services.service import BasicService import gestion.trigger.firewall4.firewall4 as firewall4 diff --git a/gestion/trigger/trigger.py b/gestion/trigger/trigger.py index fee6e16a..ad61ec42 100755 --- a/gestion/trigger/trigger.py +++ b/gestion/trigger/trigger.py @@ -61,9 +61,9 @@ class EvenementListener(cmb.AsynchronousConsumer): # Peut-être utile plus tard #origin = properties.app_id #message_id = properties.message_id + body = cPickle.loads(body) logger.info('Received message # %s from %s: %s', basic_deliver.delivery_tag, properties.app_id, body) - body = cPickle.loads(body) # On tente d'invoquer le trigger attendu, à l'aide de la méthode trigger # about contient le nom de la fonction à appeler, body lui est filé en argument. try: