+ #Core producer
+ self.producer.publish(key=msg_key, value=json.dumps(metrics_data), topic=topic)
+
+
+ def verify_metric(self, metric_info):
+ """Verify if metric is supported or not
+ """
+ metric_key_status = self.mon_plugin.verify_metric_support(metric_info)
+ return metric_key_status
+
+ def publish_create_metric_response(self, metric_info, metric_status):
+ """Publish create metric response
+ """
+ topic = 'metric_response'
+ msg_key = 'create_metric_response'
+ response_msg = {"schema_version":1.0,
+ "schema_type":"create_metric_response",
+ "correlation_id":metric_info['correlation_id'],
+ "metric_create_response":
+ {
+ "metric_uuid":0,
+ "resource_uuid":metric_info['metric_create']['resource_uuid'],
+ "status":metric_status
+ }
+ }
+ #Core producer
+ self.producer.publish(key=msg_key, value=json.dumps(response_msg), topic=topic)
+
+ def publish_update_metric_response(self, metric_info, metric_status):
+ """Publish update metric response
+ """
+ topic = 'metric_response'
+ msg_key = 'update_metric_response'
+ response_msg = {"schema_version":1.0,
+ "schema_type":"metric_update_response",
+ "correlation_id":metric_info['correlation_id'],
+ "metric_update_response":
+ {
+ "metric_uuid":0,
+ "resource_uuid":metric_info['metric_create']['resource_uuid'],
+ "status":metric_status
+ }
+ }
+ #Core producer
+ self.producer.publish(key=msg_key, value=json.dumps(response_msg), topic=topic)
+
+ def publish_delete_metric_response(self, metric_info):
+ """
+ """
+ topic = 'metric_response'
+ msg_key = 'delete_metric_response'
+ response_msg = {"schema_version":1.0,
+ "schema_type":"delete_metric_response",
+ "correlation_id":metric_info['correlation_id'],
+ "metric_name":metric_info['metric_name'],
+ "metric_uuid":0,
+ "resource_uuid":metric_info['resource_uuid'],
+ "tenant_uuid":metric_info['tenant_uuid'],
+ "status":False
+ }
+ #Core producer
+ self.producer.publish(key=msg_key, value=json.dumps(response_msg), topic=topic)
+
+ def list_alarms(self, list_alarm_input):
+ """
+ """
+ triggered_alarms = self.mon_plugin.get_triggered_alarms_list(list_alarm_input)
+ return triggered_alarms
+
+
+ def publish_list_alarm_response(self, triggered_alarm_list, list_alarm_input):
+ """
+ """
+ topic = 'alarm_response'
+ msg_key = 'list_alarm_response'
+ response_msg = {"schema_version":1.0,
+ "schema_type":"list_alarm_response",
+ "correlation_id":list_alarm_input['alarm_list_request']['correlation_id'],
+ "resource_uuid":list_alarm_input['alarm_list_request']['resource_uuid'],
+ "list_alarm_resp":triggered_alarm_list
+ }
+ #Core producer
+ self.producer.publish(key=msg_key, value=json.dumps(response_msg), topic=topic)
+
+
+def main():
+ log.basicConfig(filename='mon_vrops_log.log',level=log.DEBUG)
+ plugin_rcvr = PluginReceiver()
+ plugin_rcvr.consume()