From 49e74f61e57e242cbc78c6f8256496358e270eb6 Mon Sep 17 00:00:00 2001 From: gord chung Date: Thu, 9 Feb 2017 15:09:56 +0000 Subject: [PATCH] add ceilometer publisher ceilometer is deprecating collector. this adds support to push straight from publishers instead of using direct:// publisher hack. dispatchers also have an extra serialize/deserialize step which can be avoided. Change-Id: I5fa8b862cf19c524f90d34681980cbd062ad9bf1 --- panko/dispatcher/database.py | 4 ++ panko/publisher/__init__.py | 0 panko/publisher/database.py | 40 +++++++++++++++++++ ...eter-panko-publisher-763231cca21cb2ec.yaml | 13 ++++++ setup.cfg | 3 ++ 5 files changed, 60 insertions(+) create mode 100644 panko/publisher/__init__.py create mode 100644 panko/publisher/database.py create mode 100644 releasenotes/notes/ceilometer-panko-publisher-763231cca21cb2ec.yaml diff --git a/panko/dispatcher/database.py b/panko/dispatcher/database.py index 21be0353..226810aa 100644 --- a/panko/dispatcher/database.py +++ b/panko/dispatcher/database.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +import debtcollector from oslo_log import log from oslo_utils import timeutils @@ -38,6 +39,9 @@ class DatabaseDispatcher(object): """ def __init__(self, conf): + debtcollector.deprecate("Panko dispatcher is deprecated." + "Use publisher to push data instead", + version="3.0", removal_version="4.0") # NOTE(jd) The `conf' arg is the Ceilometer conf, but we don't really # need it here. conf = service.prepare_service([]) diff --git a/panko/publisher/__init__.py b/panko/publisher/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/panko/publisher/database.py b/panko/publisher/database.py new file mode 100644 index 00000000..4e33b17b --- /dev/null +++ b/panko/publisher/database.py @@ -0,0 +1,40 @@ +# +# 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. + +from panko import service +from panko import storage + + +class DatabasePublisher(object): + """Publisher class for recording event data into database. + + The publisher class which records each event into a database configured + in Ceilometer configuration file. + + To enable this publisher, the following section needs to be present in + panko.conf file + + [database] + connection = mysql+pymysql://panko:password@127.0.0.1/panko?charset=utf8 + + Then, panko:// should be added to Ceilometer's event_pipeline.yaml + """ + + def __init__(self, parsed_url): + conf = service.prepare_service([]) + self.conn = storage.get_connection_from_config(conf) + + def publish_events(self, events): + if not isinstance(events, list): + events = [events] + self.conn.record_events(events) diff --git a/releasenotes/notes/ceilometer-panko-publisher-763231cca21cb2ec.yaml b/releasenotes/notes/ceilometer-panko-publisher-763231cca21cb2ec.yaml new file mode 100644 index 00000000..1156c488 --- /dev/null +++ b/releasenotes/notes/ceilometer-panko-publisher-763231cca21cb2ec.yaml @@ -0,0 +1,13 @@ +--- +features: + - | + A new ceilometer to panko publisher is created to avoid ceilometer + collector dependency. This streamlines the process of pushing data to Panko +upgrade: + - | + In ceilometer.conf, remove `panko` from event_dispatchers. Add `panko://` + to the publishers in event_pipeline.yaml +deprecations: + - | + The ceilometer to panko dispatcher is now deprecated. The publisher + should be used going foward. diff --git a/setup.cfg b/setup.cfg index 3f0dff39..8b7bd805 100644 --- a/setup.cfg +++ b/setup.cfg @@ -48,6 +48,9 @@ wsgi_scripts = ceilometer.dispatcher.event = panko = panko.dispatcher.database:DatabaseDispatcher +ceilometer.event.publisher = + panko = panko.publisher.database:DatabasePublisher + oslo.config.opts = panko = panko.opts:list_opts