blob: 9472579362d93ddd3fdefed779c54777c373cfae [file] [log] [blame]
Matteo Scandoloeb0d11c2017-08-08 13:05:26 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
rdudyalab086cf32016-08-11 00:07:45 -040017import kafka
18import kafka_broker
19from oslo_utils import netutils
20import logging
21
22def read_notification_from_ceilometer_over_kafka(parse_target):
23 logging.info("Kafka target:%s",parse_target)
24 try :
25 kafka_publisher=kafka_broker.KafkaBrokerPublisher(parse_target)
26 for message in kafka_publisher.kafka_consumer:
27 #print message.value
28 logging.info("%s",message.value)
29 #print status
30 except Exception as e:
31 logging.error("Error in Kafka setup:%s ",e.__str__())
32
33ceilometer_client="kafka://10.11.10.1:9092?topic=test"
34logging.basicConfig(format='%(asctime)s %(filename)s %(levelname)s %(message)s',filename='kafka_client.log',level=logging.INFO)
35parse_target=netutils.urlsplit(ceilometer_client)
36read_notification_from_ceilometer_over_kafka(parse_target)