Commit 56d73814 authored by Pierre-Elliott Bécue's avatar Pierre-Elliott Bécue
Browse files

[trigger] Amélioration de lisibilité dans les logs, et correctif mineur

 * Ordre des imports dans le service firewall foireux
parent ccaf4312
......@@ -6,6 +6,11 @@
#
# Author : Pierre-Elliott Bécue <becue@crans.org>
# 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 = """
......
......@@ -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()
......
......@@ -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
......
......@@ -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:
......
Supports Markdown
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