From e439b2e9ce2d97791e59698303c86ca2f0feccab Mon Sep 17 00:00:00 2001 From: Steve Linabery Date: Wed, 8 Jun 2016 08:35:41 -0500 Subject: [PATCH] Relocates cli options registration from bootstrap to server This fixes an issue (see rhbz#1333884) where using the tempest CLI results in the error 'Could not load 'zaqar_tests': arguments already parsed: cannot register CLI option'. Moving the cli options registration to cmd.server resolves this problem. Change-Id: I56779da783261c6eba07a7d9286d1615dcff3598 --- zaqar/bootstrap.py | 16 ---------------- zaqar/cmd/server.py | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/zaqar/bootstrap.py b/zaqar/bootstrap.py index 89d812e88..fd31d8970 100644 --- a/zaqar/bootstrap.py +++ b/zaqar/bootstrap.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from oslo_config import cfg from oslo_log import log from stevedore import driver @@ -33,19 +32,6 @@ from zaqar.i18n import _LE LOG = log.getLogger(__name__) -_CLI_OPTIONS = ( - configs._ADMIN_MODE_OPT, - cfg.BoolOpt('daemon', default=False, - help='Run Zaqar server in the background.'), -) - -# NOTE (Obulpathi): Register daemon command line option for -# zaqar-server -CONF = cfg.CONF -CONF.register_cli_opts(_CLI_OPTIONS) -log.register_options(CONF) - - class Bootstrap(object): """Defines the Zaqar bootstrapper. @@ -61,8 +47,6 @@ class Bootstrap(object): self.driver_conf = self.conf[configs._DRIVER_GROUP] - log.setup(conf, 'zaqar') - @decorators.lazy_property(write=False) def api(self): LOG.debug(u'Loading API handler') diff --git a/zaqar/cmd/server.py b/zaqar/cmd/server.py index ff5812a66..b9c7b3114 100644 --- a/zaqar/cmd/server.py +++ b/zaqar/cmd/server.py @@ -15,9 +15,18 @@ import os from oslo_config import cfg +from oslo_log import log from zaqar import bootstrap from zaqar.common import cli +from zaqar.common import configs + +# NOTE(eggmaster): define command line options for zaqar-server +_CLI_OPTIONS = ( + configs._ADMIN_MODE_OPT, + cfg.BoolOpt('daemon', default=False, + help='Run Zaqar server in the background.'), +) @cli.runnable @@ -26,13 +35,18 @@ def run(): # to pick up common options from openstack.common.log, since # that module uses the global CONF instance exclusively. conf = cfg.CONF + conf(project='zaqar', prog='zaqar-server') + # NOTE(eggmaster): register command line options for zaqar-server + conf.register_cli_opts(_CLI_OPTIONS) + log.register_options(conf) + log.setup(conf, 'zaqar') + # NOTE(jeffrey4l): Overwrite the default vaule for # logging_context_format_string. Add project_id into it. conf.set_default('logging_context_format_string', '%(asctime)s.%(msecs)03d %(process)d %(levelname)s' ' %(name)s [%(request_id)s %(user_identity)s]' ' [project_id:%(project_id)s] %(message)s') - conf(project='zaqar', prog='zaqar-queues') server = bootstrap.Bootstrap(conf)