[trigger] Ajout d'un trigger mac_ip pour le parefeu.
This commit is contained in:
parent
31df6dc770
commit
f41ab72706
3 changed files with 62 additions and 16 deletions
|
@ -128,7 +128,7 @@ def event(body=()):
|
|||
|
||||
"""
|
||||
|
||||
logger.info("Received message %s…", body)
|
||||
logger.info("Received message %r…", body)
|
||||
|
||||
diff = diff_o_matic(body)
|
||||
|
||||
|
@ -157,14 +157,18 @@ def trigger_mac_ip(body, diff):
|
|||
fw = {'add': (macs[1], ips[1])}
|
||||
elif not macs[1]:
|
||||
# Destruction d'une machine.
|
||||
to_send = {'delete': (macs[0], ips[0])}
|
||||
dhcp = {'delete': (macs[0], ips[0])}
|
||||
fw = {'delete': (macs[0], ips[0])}
|
||||
else:
|
||||
# Mise à jour.
|
||||
to_send = {'update': (macs[0], ips[0], macs[1], ips[1], hostnames[1])}
|
||||
dhcp = {'update': (macs[0], ips[0], macs[1], ips[1], hostnames[1])}
|
||||
fw = {'update': (macs[0], ips[0], macs[1], ips[1])}
|
||||
trigger_send('dhcp', to_send)
|
||||
trigger_send('firewall_mac_ip', fw)
|
||||
logger.info("Sending DHCP trigger with body %r", dhcp)
|
||||
trigger_send("dhcp", dhcp)
|
||||
logger.info("Sending firewall trigger for mac_ip with body %r", fw)
|
||||
trigger_send("firewall", ("mac_ip", fw))
|
||||
logger.info("trigger_mac_ip done.")
|
||||
|
||||
def trigger_send(ttype, to_send):
|
||||
print "Sending trigger %s with %s…" % (ttype, to_send)
|
||||
def trigger_send(routing_key, body):
|
||||
sender = Event("civet")
|
||||
sender.send_message(routing_key, body)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue