keystone: use os_service_type for service_type defaults
There was TODO in the imported code from ironic, this patch implements it. Change-Id: Idb4b0e12348fa1c2a079cc0c6da28c5938ecbeb5
This commit is contained in:
parent
782b85d57f
commit
f4ba0a71b3
@ -1,3 +1,4 @@
|
||||
# This file mirrors all extra requirements from setup.cfg and must be kept
|
||||
# in sync. It is used both in unit tests and when building docs.
|
||||
keystoneauth1>=4.2.0 # Apache-2.0
|
||||
os-service-types>=1.2.0 # Apache-2.0
|
||||
|
@ -19,6 +19,7 @@ from keystoneauth1 import exceptions as ks_exception
|
||||
from keystoneauth1 import loading as ks_loading
|
||||
from keystoneauth1 import service_token
|
||||
from keystoneauth1 import token_endpoint
|
||||
import os_service_types
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
@ -155,10 +156,14 @@ def register_auth_opts(conf, group, service_type=None):
|
||||
CONF.set_default('auth_type', default='password', group=group)
|
||||
ks_loading.register_adapter_conf_options(conf, group)
|
||||
conf.set_default('valid_interfaces', DEFAULT_VALID_INTERFACES, group=group)
|
||||
# TODO(pas-ha) use os-service-type to try find the service_type by the
|
||||
# config group name assuming it is a project name (e.g. 'glance')
|
||||
if service_type:
|
||||
conf.set_default('service_type', service_type, group=group)
|
||||
else:
|
||||
types = os_service_types.get_service_types()
|
||||
key = 'ironic-inspector' if group == 'inspector' else group
|
||||
service_types = types.service_types_by_project.get(key)
|
||||
if service_types:
|
||||
conf.set_default('service_type', service_types[0], group=group)
|
||||
|
||||
|
||||
def add_auth_opts(options, service_type=None):
|
||||
|
@ -114,3 +114,8 @@ class AuthConfTestCase(base.IronicLibTestCase):
|
||||
'tenant_name', 'project_name', 'trust_id',
|
||||
'domain_id', 'user_domain_id', 'project_domain_id'}
|
||||
self.assertTrue(expected.issubset(names))
|
||||
|
||||
def test_os_service_types_alias(self):
|
||||
keystone.register_auth_opts(self.cfg_fixture.conf, 'barbican')
|
||||
self.assertEqual(self.cfg_fixture.conf.barbican.service_type,
|
||||
'key-manager')
|
||||
|
Loading…
Reference in New Issue
Block a user