Github user nickwallen commented on a diff in the pull request:
https://github.com/apache/metron/pull/799#discussion_r144955205
--- Diff:
metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/metron_service.py
---
@@ -201,15 +200,123 @@ def init_kafka_topics(params, topics):
user=params.kafka_user, tries=3, try_sleep=5, logoutput=True)
Logger.info("Done creating Kafka topics")
-def init_kafka_acls(params, topics, groups):
- Logger.info('Creating Kafka ACLs')
+def check_kafka_topics(params, topics):
+
+ if params.security_enabled:
+ kinit(params.kinit_path_local,
+ params.metron_keytab_path,
+ params.metron_principal_name,
+ execute_user=params.metron_user)
+
+ cmd = """{0}/kafka-topics.sh \
+ --zookeeper {1} \
+ --list | \
+ awk 'BEGIN {{cnt=0;}} /{2}/ {{cnt++}} END {{if (cnt > 0) {{exit 0}}
else {{exit 1}}}}'"""
+ for topic in topics:
+ Logger.info("Checking existence of Kafka topic '{0}'".format(topic))
+ try:
+ Execute(
--- End diff --
I refactored this a bit and added some pydocs.
---