Matteo Scandolo | eb0d11c | 2017-08-08 13:05:26 -0700 | [diff] [blame^] | 1 | |
| 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 | |
rdudyala | b086cf3 | 2016-08-11 00:07:45 -0400 | [diff] [blame] | 17 | import kafka |
| 18 | import kafka_broker |
| 19 | from oslo_utils import netutils |
| 20 | import logging |
| 21 | |
| 22 | def 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 | |
| 33 | ceilometer_client="kafka://10.11.10.1:9092?topic=test" |
| 34 | logging.basicConfig(format='%(asctime)s %(filename)s %(levelname)s %(message)s',filename='kafka_client.log',level=logging.INFO) |
| 35 | parse_target=netutils.urlsplit(ceilometer_client) |
| 36 | read_notification_from_ceilometer_over_kafka(parse_target) |