Merge "Add register_opts param to PlacementFixture"
This commit is contained in:
commit
c6a23a3037
@ -14,6 +14,8 @@
|
||||
# under the License.
|
||||
from __future__ import absolute_import
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from placement.conf import api
|
||||
from placement.conf import base
|
||||
from placement.conf import database
|
||||
@ -21,7 +23,7 @@ from placement.conf import paths
|
||||
from placement.conf import placement
|
||||
|
||||
|
||||
# To avoid global config, we require an existing ConfigOpts is passed
|
||||
# To avoid global config, we require an existing ConfigOpts to be passed
|
||||
# to register_opts. Then the caller can have some assurance that the
|
||||
# config they are using will maintain some independence.
|
||||
def register_opts(conf):
|
||||
@ -30,3 +32,4 @@ def register_opts(conf):
|
||||
database.register_opts(conf)
|
||||
paths.register_opts(conf)
|
||||
placement.register_opts(conf)
|
||||
logging.register_options(conf)
|
||||
|
@ -42,7 +42,7 @@ class PlacementFixture(fixtures.Fixture):
|
||||
Used by other services, including nova, for functional tests.
|
||||
"""
|
||||
def __init__(self, token='admin', conf_fixture=None, db=True,
|
||||
use_intercept=True):
|
||||
use_intercept=True, register_opts=True):
|
||||
"""Create a Placement Fixture.
|
||||
|
||||
:param token: The value to be used when passing an auth token
|
||||
@ -52,18 +52,21 @@ class PlacementFixture(fixtures.Fixture):
|
||||
:param db: Whether to start the Database fixture.
|
||||
:param use_intercept: If true, install a wsgi-intercept of the
|
||||
placement WSGI app.
|
||||
:param register_opts: If True, register configuration options.
|
||||
"""
|
||||
self.token = token
|
||||
self.db = db
|
||||
self.use_intercept = use_intercept
|
||||
self.conf_fixture = conf_fixture
|
||||
self.register_opts = register_opts
|
||||
|
||||
def setUp(self):
|
||||
super(PlacementFixture, self).setUp()
|
||||
if not self.conf_fixture:
|
||||
config = cfg.ConfigOpts()
|
||||
self.conf_fixture = self.useFixture(config_fixture.Config(config))
|
||||
conf.register_opts(self.conf_fixture.conf)
|
||||
if self.register_opts:
|
||||
conf.register_opts(self.conf_fixture.conf)
|
||||
|
||||
if self.db:
|
||||
self.useFixture(db_fixture.Database(self.conf_fixture,
|
||||
|
@ -71,7 +71,6 @@ def _get_config_files(env=None):
|
||||
def _parse_args(config, argv, default_config_files):
|
||||
# register placement's config options
|
||||
conf.register_opts(config)
|
||||
logging.register_options(config)
|
||||
|
||||
if profiler:
|
||||
profiler.set_defaults(config)
|
||||
|
Loading…
Reference in New Issue
Block a user