OSM MON Installation and Packaging Updates
Signed-off-by: prithiv <prithiv.mohan@intel.com>
diff --git a/core/__init__.py b/core/__init__.py
index e69de29..9a7375e 100644
--- a/core/__init__.py
+++ b/core/__init__.py
@@ -0,0 +1,20 @@
+# Copyright 2017 Intel Research and Development Ireland Limited
+# *************************************************************
+
+# This file is part of OSM Monitoring module
+# All Rights Reserved to Intel Corporation
+
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: prithiv.mohan@intel.com or adrian.hoban@intel.com
diff --git a/core/kafka.service b/core/kafka.service
new file mode 100644
index 0000000..f517811
--- /dev/null
+++ b/core/kafka.service
@@ -0,0 +1,39 @@
+# Copyright 2017 Intel Research and Development Ireland Limited
+# *************************************************************
+
+# This file is part of OSM Monitoring module
+# All Rights Reserved to Intel Corporation
+
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+# For those usages not covered by the Apache License, Version 2.0 please
+# contact: prithiv.mohan@intel.com or adrian.hoban@intel.com
+
+[Unit]
+Description=Apache Kafka server (broker)
+Documentation=http://kafka.apache.org/documentation.html
+Requires=network.target remote-fs.target
+After=network.target remote-fs.target
+
+[Service]
+Type=simple
+PIDFile=/var/run/kafka.pid
+#User=root
+#Group=kafka
+ExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties
+ExecStop=/opt/kafka/bin/kafka-server-stop.sh
+Restart=on-failure
+SyslogIdentifier=kafka
+
+[Install]
+WantedBy=multi-user.target
diff --git a/core/message_bus/consumer.py b/core/message_bus/consumer.py
index 8427076..3995084 100644
--- a/core/message_bus/consumer.py
+++ b/core/message_bus/consumer.py
@@ -73,10 +73,13 @@
logging.config.dictConfig(log_config)
logger = logging.getLogger('kafka')
+if "BROKER_URI" in os.environ:
+ broker = os.getenv("BROKER_URI")
+else:
+ broker = "localhost:9092"
-
-alarm_consumer = KafkaConsumer('alarm_response', 'osm_mon', bootstrap_servers = 'localhost:9092')
-metric_consumer = KafkaConsumer('metric_response', 'osm_mon', bootstrap_servers = 'localhost:9092')
+alarm_consumer = KafkaConsumer('alarm_response', 'osm_mon', bootstrap_servers = broker)
+metric_consumer = KafkaConsumer('metric_response', 'osm_mon', bootstrap_servers = broker)
try:
for message in alarm_consumer:
logger.debug(message)
@@ -84,7 +87,6 @@
logger.debug(message)
except KafkaError:
log.exception()
- pass
alarm_consumer.subscribe('alarm_response')
metric_consumer.subscribe('metric_response')
diff --git a/core/message_bus/producer.py b/core/message_bus/producer.py
index 4956292..f5abce2 100644
--- a/core/message_bus/producer.py
+++ b/core/message_bus/producer.py
@@ -47,13 +47,13 @@
self._topic= topic
- if "ZOOKEEPER_URI" in os.environ:
- broker = os.getenv("ZOOKEEPER_URI")
+ if "BROKER_URI" in os.environ:
+ broker = os.getenv("BROKER_URI")
else:
- broker = "localhost:2181"
+ broker = "localhost:9092"
'''
- If the zookeeper broker URI is not set in the env, by default,
+ If the broker URI is not set in the env, by default,
localhost container is taken as the host because an instance of
is already running.
'''