From 5345f4f8016ffb81678c821e9adf03a12657425f Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 17 Jul 2013 16:47:27 +0200 Subject: [PATCH] storage: remove per-driver options Fixes: bug #1195538 Change-Id: Iac6ace9a2402237543ed35be7f4fcee91ff3e036 Signed-off-by: Julien Danjou --- ceilometer/api/v1/app.py | 2 -- ceilometer/storage/__init__.py | 11 +------- ceilometer/storage/base.py | 4 --- ceilometer/storage/impl_hbase.py | 5 ---- ceilometer/storage/impl_log.py | 4 --- ceilometer/storage/impl_mongodb.py | 4 --- ceilometer/storage/impl_sqlalchemy.py | 6 ----- tests/storage/test_register_opts.py | 39 --------------------------- tools/show_data.py | 1 - 9 files changed, 1 insertion(+), 75 deletions(-) delete mode 100644 tests/storage/test_register_opts.py diff --git a/ceilometer/api/v1/app.py b/ceilometer/api/v1/app.py index 4f211368..76d64892 100644 --- a/ceilometer/api/v1/app.py +++ b/ceilometer/api/v1/app.py @@ -31,8 +31,6 @@ from ceilometer import storage # how to serialize more complex objects. flask.helpers.json = jsonutils -storage.register_opts(cfg.CONF) - def make_app(conf, enable_acl=True, attach_storage=True, sources_file='sources.json'): diff --git a/ceilometer/storage/__init__.py b/ceilometer/storage/__init__.py index 952f3888..9322f6aa 100644 --- a/ceilometer/storage/__init__.py +++ b/ceilometer/storage/__init__.py @@ -58,12 +58,6 @@ cfg.CONF.import_opt('connection', group='database') -def register_opts(conf): - """Register any options for the storage system.""" - p = get_engine(conf) - p.register_opts(conf) - - def get_engine(conf): """Load the configured engine and return an instance.""" if conf.database_connection: @@ -80,10 +74,7 @@ def get_engine(conf): def get_connection(conf): """Return an open connection to the database.""" - engine = get_engine(conf) - engine.register_opts(conf) - db = engine.get_connection(conf) - return db + return get_engine(conf).get_connection(conf) class SampleFilter(object): diff --git a/ceilometer/storage/base.py b/ceilometer/storage/base.py index 87670d47..e036fc6c 100644 --- a/ceilometer/storage/base.py +++ b/ceilometer/storage/base.py @@ -50,10 +50,6 @@ class StorageEngine(object): __metaclass__ = abc.ABCMeta - @abc.abstractmethod - def register_opts(self, conf): - """Register any configuration options used by this engine.""" - @abc.abstractmethod def get_connection(self, conf): """Return a Connection instance based on the configuration settings.""" diff --git a/ceilometer/storage/impl_hbase.py b/ceilometer/storage/impl_hbase.py index e6d0ad1e..a0636e76 100644 --- a/ceilometer/storage/impl_hbase.py +++ b/ceilometer/storage/impl_hbase.py @@ -63,11 +63,6 @@ class HBaseStorage(base.StorageEngine): } """ - def register_opts(self, conf): - """Register any configuration options used by this engine. - """ - pass - @staticmethod def get_connection(conf): """Return a Connection instance based on the configuration settings. diff --git a/ceilometer/storage/impl_log.py b/ceilometer/storage/impl_log.py index ae3155f0..040f1fa3 100644 --- a/ceilometer/storage/impl_log.py +++ b/ceilometer/storage/impl_log.py @@ -28,10 +28,6 @@ class LogStorage(base.StorageEngine): """Log the data """ - def register_opts(self, conf): - """Register any configuration options used by this engine. - """ - def get_connection(self, conf): """Return a Connection instance based on the configuration settings. """ diff --git a/ceilometer/storage/impl_mongodb.py b/ceilometer/storage/impl_mongodb.py index 3acfdc65..b8a50ff5 100644 --- a/ceilometer/storage/impl_mongodb.py +++ b/ceilometer/storage/impl_mongodb.py @@ -73,10 +73,6 @@ class MongoDBStorage(base.StorageEngine): } """ - def register_opts(self, conf): - """Register any configuration options used by this engine. - """ - def get_connection(self, conf): """Return a Connection instance based on the configuration settings. """ diff --git a/ceilometer/storage/impl_sqlalchemy.py b/ceilometer/storage/impl_sqlalchemy.py index b233ec66..81469981 100644 --- a/ceilometer/storage/impl_sqlalchemy.py +++ b/ceilometer/storage/impl_sqlalchemy.py @@ -92,12 +92,6 @@ class SQLAlchemyStorage(base.StorageEngine): } """ - OPTIONS = [] - - def register_opts(self, conf): - """Register any configuration options used by this engine.""" - conf.register_opts(self.OPTIONS) - @staticmethod def get_connection(conf): """Return a Connection instance based on the configuration settings. diff --git a/tests/storage/test_register_opts.py b/tests/storage/test_register_opts.py deleted file mode 100644 index da4c606a..00000000 --- a/tests/storage/test_register_opts.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- encoding: utf-8 -*- -# -# Copyright © 2012 New Dream Network, LLC (DreamHost) -# -# Author: Doug Hellmann -# -# 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. -"""Tests for ceilometer/storage/ -""" - -from oslo.config import cfg - -from ceilometer import storage -from ceilometer.storage import base -from ceilometer.tests import base as test_base - - -class RegisterOpts(test_base.TestCase): - - def faux_get_engine(self, conf): - return self._faux_engine - - def test_register_opts(self): - self.stubs.Set(storage, 'get_engine', self.faux_get_engine) - self._faux_engine = self.mox.CreateMock(base.StorageEngine) - self._faux_engine.register_opts(cfg.CONF) - self.mox.ReplayAll() - storage.register_opts(cfg.CONF) - self.mox.VerifyAll() diff --git a/tools/show_data.py b/tools/show_data.py index d3abfc9f..5aba6b87 100755 --- a/tools/show_data.py +++ b/tools/show_data.py @@ -117,7 +117,6 @@ def main(argv): #ceilometer collector by default. default_config_files=['/etc/ceilometer/ceilometer.conf'], ) - storage.register_opts(cfg.CONF) db = storage.get_connection(cfg.CONF) command = extra_args[0] if extra_args else 'help' COMMANDS[command](db, extra_args[1:])