On splitte services et parsers (qui ne sont utilisés que par civet.event)
This commit is contained in:
parent
f24e463da5
commit
06095f5580
7 changed files with 96 additions and 46 deletions
|
@ -20,7 +20,7 @@ logger = clogger.CLogger("trigger", "firewall", trigger_config.log_level, trigge
|
|||
|
||||
import lc_ldap.shortcuts
|
||||
|
||||
from gestion.trigger.host import record_service, record_parser
|
||||
from gestion.trigger.host import record_service
|
||||
import gestion.trigger.firewall4.firewall4 as firewall4
|
||||
|
||||
class FwFactory(object):
|
||||
|
@ -41,26 +41,6 @@ class FwFactory(object):
|
|||
def fwrecord(fun):
|
||||
FwFactory.register(fun.func_name, fun)
|
||||
|
||||
@record_parser(lc_ldap.attributs.macAddress.ldap_name, lc_ldap.attributs.ipHostNumber.ldap_name)
|
||||
def send_mac_ip(body, diff):
|
||||
"""Computes mac_ip data to send from body and diff
|
||||
|
||||
"""
|
||||
macs = tuple([body[i].get(lc_ldap.attributs.macAddress.ldap_name, [''])[0] for i in xrange(1, 3)])
|
||||
ips = tuple([body[i].get(lc_ldap.attributs.ipHostNumber.ldap_name, [''])[0] for i in xrange(1, 3)])
|
||||
|
||||
# Mise à jour du parefeu mac_ip
|
||||
if not macs[0]:
|
||||
# Création d'une nouvelle machine.
|
||||
fw = {'add': [(macs[1], ips[1])]}
|
||||
elif not macs[1]:
|
||||
# Destruction d'une machine.
|
||||
fw = {'delete': [(macs[0], ips[0])]}
|
||||
else:
|
||||
# Mise à jour.
|
||||
fw = {'update': [(macs[0], ips[0], macs[1], ips[1])]}
|
||||
return ("firewall", ("mac_ip", fw))
|
||||
|
||||
@record_service
|
||||
def firewall(body=()):
|
||||
"""Regens the specific service
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue