Fix for 1433 Add dummy write to kafka 51/10651/1 branch-ng-ro-refactor-start branch-sol006v331-start
authorpalsus <subhankar.pal@aricent.com>
Fri, 16 Apr 2021 07:36:15 +0000 (07:36 +0000)
committerpalsus <subhankar.pal@aricent.com>
Fri, 16 Apr 2021 07:37:08 +0000 (07:37 +0000)
Change-Id: I4c102e52612a50a8fe3d562c6435d95426a56b4f
Signed-off-by: palsus <subhankar.pal@aricent.com>
osm_mon/cmd/mon_utils.py

index 6d383d0..9640543 100644 (file)
@@ -19,7 +19,7 @@ import time
 import socket
 import logging
 import kafka
-from osm_mon.core.message_bus_client import MessageBusClient
+
 
 def wait_till_commondb_is_ready(config, process_name="osm-mon", commondb_wait_time=5):
 
@@ -59,14 +59,16 @@ def wait_till_kafka_is_ready(config, process_name="osm-mon", kafka_wait_time=5):
                                                    bootstrap_servers=[config.conf.get("message", {}).get("host",
                                                                       "kafka") + ":" + config.conf["message"]
                                                                       .get("port")])
-                    topics = consumer.topics()
-                    logging.debug("Number of topics found: %s", len(topics))
+                    all_topics = consumer.topics()
+                    logging.debug("Number of topics found: %s", len(all_topics))
 
                     # Send dummy message in kafka topics. If kafka is not ready exception will be thrown.
-                    msg_bus = MessageBusClient(config)
-                    topics = ["alarm_request", "users", "project"]
-                    for topic in topics:
-                        msg_bus.aiowrite(topic, 'echo', 'dummy message')
+                    producer = kafka.KafkaProducer(bootstrap_servers=[config.conf.get("message", {}).get("host",
+                                                                      "kafka") + ":" + config.conf["message"]
+                                                                      .get("port")])
+                    mon_topics = ["alarm_request", "users", "project"]
+                    for mon_topic in mon_topics:
+                        producer.send(mon_topic, key=b"echo", value=b"dummy message")
 
                     # Kafka is ready now
                     kafka_ready = True