Merge "Don't register cli opts on import"

This commit is contained in:
Zuul 2020-04-07 17:14:58 +00:00 committed by Gerrit Code Review
commit 78863cf7ee
3 changed files with 8 additions and 18 deletions

View File

@ -735,9 +735,7 @@ cfg.CONF.register_opts(controller_worker_opts, group='controller_worker')
cfg.CONF.register_opts(keepalived_vrrp_opts, group='keepalived_vrrp')
cfg.CONF.register_opts(task_flow_opts, group='task_flow')
cfg.CONF.register_opts(house_keeping_opts, group='house_keeping')
cfg.CONF.register_cli_opts(core_cli_opts)
cfg.CONF.register_opts(certificate_opts, group='certificates')
cfg.CONF.register_cli_opts(healthmanager_opts, group='health_manager')
cfg.CONF.register_opts(nova_opts, group='nova')
cfg.CONF.register_opts(cinder_opts, group='cinder')
cfg.CONF.register_opts(glance_opts, group='glance')
@ -757,13 +755,18 @@ _SQL_CONNECTION_DEFAULT = 'sqlite://'
db_options.set_defaults(cfg.CONF, connection=_SQL_CONNECTION_DEFAULT,
max_pool_size=10, max_overflow=20, pool_timeout=10)
logging.register_options(cfg.CONF)
ks_loading.register_auth_conf_options(cfg.CONF, constants.SERVICE_AUTH)
ks_loading.register_session_conf_options(cfg.CONF, constants.SERVICE_AUTH)
def register_cli_opts():
cfg.CONF.register_cli_opts(core_cli_opts)
cfg.CONF.register_cli_opts(healthmanager_opts, group='health_manager')
logging.register_options(cfg.CONF)
def init(args, **kwargs):
register_cli_opts()
cfg.CONF(args=args, project='octavia',
version='%%prog %s' % version.version_info.release_string(),
**kwargs)

View File

@ -11,15 +11,11 @@
# under the License.
"""Policy Engine For Octavia."""
import sys
from oslo_config import cfg
from oslo_log import log as logging
from oslo_policy import policy as oslo_policy
from oslo_utils import excutils
from octavia.common import config
from octavia.common import exceptions
from octavia import policies
@ -153,14 +149,4 @@ class IsAdminCheck(oslo_policy.Check):
# This is used for the oslopolicy-policy-generator tool
def get_no_context_enforcer():
# oslo.config needs access to the --config-dir and --config-file
# command line args
filtered_args = ['--config-dir', '--config-file']
# Start at 1 because cfg.CONF expects the equivalent of sys.argv[1:]
conf_args = [arg for idx, arg in enumerate(sys.argv[1:])
if (arg in filtered_args or
sys.argv[idx] in filtered_args)]
config.init(conf_args)
return Policy()

View File

@ -30,6 +30,7 @@ class TestCase(testtools.TestCase):
def setUp(self):
super(TestCase, self).setUp()
config.register_cli_opts()
self.addCleanup(mock.patch.stopall)
self.addCleanup(self.clean_caches)