From d542caa47eae3d7321c8d7bcf17c26e5dce08713 Mon Sep 17 00:00:00 2001 From: Brant Knudson Date: Thu, 2 Jan 2014 18:44:47 -0600 Subject: [PATCH] Don't configure on import The keystone.config package called config.configure() at import- time. This will make it obvious that developers can't use config options at import-time because packages that do that will fail on import. Change-Id: I9306f67609d782e3f49fd43908448daf1287d51c Related-Bug: #1265108 Related-Bug: #1265670 Closes-Bug: #1269785 --- bin/keystone-all | 1 + httpd/keystone.py | 1 + keystone/cli.py | 1 + keystone/config.py | 1 - keystone/tests/core.py | 3 +++ keystone/tests/default_fixtures.py | 14 +++++++++----- keystone/tests/test_v3.py | 2 +- 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/bin/keystone-all b/bin/keystone-all index fe0d9d2513..3be54b8304 100755 --- a/bin/keystone-all +++ b/bin/keystone-all @@ -103,6 +103,7 @@ if __name__ == '__main__': if os.path.exists(dev_conf): config_files = [dev_conf] + config.configure() sql.initialize() CONF(project='keystone', diff --git a/httpd/keystone.py b/httpd/keystone.py index 5ed5aba875..b216a59d45 100644 --- a/httpd/keystone.py +++ b/httpd/keystone.py @@ -36,6 +36,7 @@ from keystone import service CONF = config.CONF +config.configure() sql.initialize() CONF(project='keystone') diff --git a/keystone/cli.py b/keystone/cli.py index 514e0d7094..8e41f2264d 100644 --- a/keystone/cli.py +++ b/keystone/cli.py @@ -212,6 +212,7 @@ command_opt = cfg.SubCommandOpt('command', def main(argv=None, config_files=None): CONF.register_cli_opt(command_opt) + config.configure() sql.initialize() CONF(args=argv[1:], diff --git a/keystone/config.py b/keystone/config.py index aa6df2254b..367c8edddc 100644 --- a/keystone/config.py +++ b/keystone/config.py @@ -22,7 +22,6 @@ from keystone import exception from keystone.openstack.common import log -config.configure() CONF = config.CONF setup_authentication = config.setup_authentication diff --git a/keystone/tests/core.py b/keystone/tests/core.py index d808a93c89..c7344827e1 100644 --- a/keystone/tests/core.py +++ b/keystone/tests/core.py @@ -70,6 +70,9 @@ from keystone import service from keystone.openstack.common import policy as common_policy # noqa +config.configure() + + LOG = log.getLogger(__name__) TESTSDIR = os.path.dirname(os.path.abspath(__file__)) ROOTDIR = os.path.normpath(os.path.join(TESTSDIR, '..', '..')) diff --git a/keystone/tests/default_fixtures.py b/keystone/tests/default_fixtures.py index 98875bd75b..5197dcce7a 100644 --- a/keystone/tests/default_fixtures.py +++ b/keystone/tests/default_fixtures.py @@ -17,14 +17,13 @@ # NOTE(dolph): please try to avoid additional fixtures if possible; test suite # performance may be negatively affected. -from keystone import assignment from keystone import config CONF = config.CONF -DEFAULT_DOMAIN_ID = config.CONF.identity.default_domain_id +DEFAULT_DOMAIN_ID = 'default' TENANTS = [ @@ -104,8 +103,8 @@ ROLES = [ 'id': 'member', 'name': 'Member', }, { - 'id': CONF.member_role_id, - 'name': CONF.member_role_name, + 'id': '9fe2ff9ee4384b1894a90878d3e92bab', + 'name': '_member_', }, { 'id': 'other', 'name': 'Other', @@ -121,4 +120,9 @@ ROLES = [ } ] -DOMAINS = [assignment.calc_default_domain()] +DOMAINS = [{'description': + (u'Owns users and tenants (i.e. projects)' + ' available on Identity API v2.'), + 'enabled': True, + 'id': DEFAULT_DOMAIN_ID, + 'name': u'Default'}] diff --git a/keystone/tests/test_v3.py b/keystone/tests/test_v3.py index de875c3412..3f5031da9e 100644 --- a/keystone/tests/test_v3.py +++ b/keystone/tests/test_v3.py @@ -30,7 +30,7 @@ from keystone.tests import rest CONF = config.CONF -DEFAULT_DOMAIN_ID = CONF.identity.default_domain_id +DEFAULT_DOMAIN_ID = 'default' TIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'