Commit bcde02e1 authored by Christos Stavrakakis's avatar Christos Stavrakakis

gtools: Make the eventd send heartbeat messages

Make 'snf-ganeti-eventd' daemon to send heartbeat messages which can
be used to check that the daemon is working correctly, i.e. that it is watching
the Ganeti queue and that it can send messages to the AMQP broker. The
daemon is triggered to send a heartbeat message by setting a special tag
to the Ganeti cluster in 'dry-run' mode.

Heartbeat messages are send with the 'eventd.heartbeat' routing key.

Refs Issue #23
parent a82ae57c
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2011 GRNET S.A. All rights reserved.
# Copyright 2011-2014 GRNET S.A. All rights reserved.
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
......@@ -190,7 +190,8 @@ class JobFileHandler(pyinotify.ProcessEvent):
self.op_handlers = {"INSTANCE": self.process_instance_op,
"NETWORK": self.process_network_op,
"CLUSTER": self.process_cluster_op}
"CLUSTER": self.process_cluster_op,
"TAGS": self.process_tag_op}
# "GROUP": self.process_group_op}
def process_IN_CLOSE_WRITE(self, event):
......@@ -359,6 +360,28 @@ class JobFileHandler(pyinotify.ProcessEvent):
return msg, routekey
def process_tag_op(self, op, job_id):
""" Process OP_TAGS_* opcodes.
input = op.input
op_id = input.OP_ID
if op_id == "OP_TAGS_SET":
if op.status == "waiting" and input.tags and input.dry_run and\
input.kind == "cluster":
# Special where a prefixed cluster tag operation in dry-run
# mode is used in order to trigger eventd to send a
# heartbeat message.
tag = input.tags[0]
if tag.startswith("snf:eventd:heartbeat"):
self.logger.debug("Received heartbeat tag '%s'."
" Sending response.", tag)
msg = {"type": "eventd-heartbeat",
"cluster": self.cluster_name}
return msg, "eventd.heartbeat"
return None, None
def find_cluster_name():
global handler_logger
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment