From 46e673f9fb40cae06e984a031daf336e64b41dca Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 17 Jul 2013 16:39:05 +0200 Subject: [PATCH] hbase: do not register table_prefix as a global option Rather use a per-connection option. Change-Id: I53e26f72d9a7fb0e2778402801a71c2682883452 --- ceilometer/storage/impl_hbase.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/ceilometer/storage/impl_hbase.py b/ceilometer/storage/impl_hbase.py index e2b0ad8a0..e6d0ad1e1 100644 --- a/ceilometer/storage/impl_hbase.py +++ b/ceilometer/storage/impl_hbase.py @@ -19,7 +19,6 @@ """HBase storage backend """ from sets import Set -from urlparse import urlparse import json import hashlib import copy @@ -27,10 +26,11 @@ import datetime import happybase import os import re -from oslo.config import cfg +import urlparse from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils +from ceilometer.openstack.common import network_utils from ceilometer.storage import base from ceilometer.storage import models @@ -63,17 +63,10 @@ class HBaseStorage(base.StorageEngine): } """ - OPTIONS = [ - cfg.StrOpt('table_prefix', - default=None, - help='Database table prefix', - ), - ] - def register_opts(self, conf): """Register any configuration options used by this engine. """ - conf.register_opts(self.OPTIONS) + pass @staticmethod def get_connection(conf): @@ -96,7 +89,6 @@ class Connection(base.Connection): def __init__(self, conf): """Hbase Connection Initialization.""" opts = self._parse_connection_url(conf.database.connection) - opts['table_prefix'] = conf.table_prefix if opts['host'] == '__test__': url = os.environ.get('CEILOMETER_TEST_HBASE_URL') @@ -159,7 +151,9 @@ class Connection(base.Connection): database name, so we are not looking for these in the url. """ opts = {} - result = urlparse(url) + result = network_utils.urlsplit(url) + opts['table_prefix'] = urlparse.parse_qs( + result.query).get('table_prefix', [None])[0] opts['dbtype'] = result.scheme if ':' in result.netloc: opts['host'], port = result.netloc.split(':')