From e0976af072badf78b335fea606b1efb2c24cc32a Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Thu, 13 Apr 2017 15:13:15 -0400 Subject: [PATCH] Allow bootstrapping against clusters and unify host options The current settings inside freezer-manage reflect on using host and port which are no longer used. In addition, there seems to be no splitting of the values in freezer-manage which means that it would create a problem when trying to install against a list of hosts as the ElasticSearch driver will refuse to accept the list. This patch unifies all references of to 'hosts' and changes the option to use ListOpt which is comma seperated values in the configuration file which are then split into an array by oslo.config, which avoids having to split things inside freezer. Closes-Bug: #1681931 Change-Id: I613d0672ec2b186cd0d6365e795b35d9cff26dcd --- freezer_api/cmd/manage.py | 15 +++------------ freezer_api/storage/elastic.py | 8 +++----- freezer_api/storage/elasticv2.py | 8 +++----- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/freezer_api/cmd/manage.py b/freezer_api/cmd/manage.py index 46f19687..0c1df324 100644 --- a/freezer_api/cmd/manage.py +++ b/freezer_api/cmd/manage.py @@ -30,7 +30,6 @@ from freezer_api.storage import driver CONF = cfg.CONF LOG = log.getLogger(__name__) -DEFAULT_ES_SERVER_PORT = 9200 DEFAULT_INDEX = 'freezer' DEFAULT_REPLICAS = 0 @@ -51,17 +50,9 @@ def parse_config(mapping_choices): title='DB Options', handler=add_db_opts ), - cfg.HostAddressOpt('host', - default='127.0.0.1', - dest='host', - help='The DB host address[:port], ' - 'default "127.0.0.1"'), - cfg.PortOpt('port', - default=9200, - dest='port', - help='The DB server port (default: {0})'. - format(DEFAULT_ES_SERVER_PORT) - ), + cfg.ListOpt('hosts', + default=['http://127.0.0.1:9200'], + help='specify the storage hosts'), cfg.StrOpt('mapping', dest='select_mapping', default='', diff --git a/freezer_api/storage/elastic.py b/freezer_api/storage/elastic.py index 8d6edb6d..574f219a 100644 --- a/freezer_api/storage/elastic.py +++ b/freezer_api/storage/elastic.py @@ -281,10 +281,9 @@ class SessionTypeManager(TypeManager): class ElasticSearchEngine(object): _OPTS = [ - cfg.StrOpt('hosts', - default='http://localhost:9200', - deprecated_name='endpoint', - help='specify the storage hosts'), + cfg.ListOpt('hosts', + default=['http://127.0.0.1:9200'], + help='specify the storage hosts'), cfg.StrOpt('index', default='freezer', help='specify the name of the elasticsearch index'), @@ -323,7 +322,6 @@ class ElasticSearchEngine(object): # register elasticsearch opts CONF.register_opts(self._OPTS, group=backend) self.conf = dict(CONF.get(backend)) - self.conf['hosts'] = self.conf['hosts'].split(',') self.backend = backend self._validate_opts() self.init(**self.conf) diff --git a/freezer_api/storage/elasticv2.py b/freezer_api/storage/elasticv2.py index d62720c9..eadb6c2c 100644 --- a/freezer_api/storage/elasticv2.py +++ b/freezer_api/storage/elasticv2.py @@ -320,10 +320,9 @@ class SessionTypeManagerV2(TypeManagerV2): class ElasticSearchEngineV2(object): _OPTS = [ - cfg.StrOpt('hosts', - default='http://localhost:9200', - deprecated_name='endpoint', - help='specify the storage hosts'), + cfg.ListOpt('hosts', + default=['http://127.0.0.1:9200'], + help='specify the storage hosts'), cfg.StrOpt('index', default='freezer', help='specify the name of the elasticsearch index'), @@ -362,7 +361,6 @@ class ElasticSearchEngineV2(object): # register elasticsearch opts CONF.register_opts(self._OPTS, group=backend) self.conf = dict(CONF.get(backend)) - self.conf['hosts'] = self.conf['hosts'].split(',') self.backend = backend self._validate_opts() self.init(**self.conf)