from_conf: fix handling service names with dashes
Services like ironic-inspector are likely to be represented as ironic_inspector in the configuration, so fall back to underscores if the variant with dashes is not found. Change-Id: I765a0722aa718ab8e430c3f8fc31c192091e9ca1
This commit is contained in:
parent
b0501643b9
commit
b94a8ce4a9
|
@ -142,12 +142,16 @@ def from_conf(conf, session=None, **kwargs):
|
|||
for st in stm.all_types_by_service_type:
|
||||
project_name = stm.get_project_name(st)
|
||||
if project_name not in conf:
|
||||
_disable_service(
|
||||
config_dict, st,
|
||||
reason="No section for project '{project}' (service type "
|
||||
"'{service_type}') was present in the config.".format(
|
||||
project=project_name, service_type=st))
|
||||
continue
|
||||
if '-' in project_name:
|
||||
project_name = project_name.replace('-', '_')
|
||||
|
||||
if project_name not in conf:
|
||||
_disable_service(
|
||||
config_dict, st,
|
||||
reason="No section for project '{project}' (service type "
|
||||
"'{service_type}') was present in the config."
|
||||
.format(project=project_name, service_type=st))
|
||||
continue
|
||||
opt_dict = {}
|
||||
# Populate opt_dict with (appropriately processed) Adapter conf opts
|
||||
try:
|
||||
|
|
|
@ -38,6 +38,10 @@ class TestFromConf(base.TestCase):
|
|||
'interface': 'internal',
|
||||
'endpoint_override': 'https://example.org:8888/heat/v2'
|
||||
},
|
||||
# test a service with dashes
|
||||
'ironic_inspector': {
|
||||
'endpoint_override': 'https://example.org:5050',
|
||||
},
|
||||
}
|
||||
|
||||
def _load_ks_cfg_opts(self):
|
||||
|
@ -123,6 +127,31 @@ class TestFromConf(base.TestCase):
|
|||
self.assertEqual(s.name, server_name)
|
||||
self.assert_calls()
|
||||
|
||||
def test_name_with_dashes(self):
|
||||
conn = self._get_conn()
|
||||
|
||||
discovery = {
|
||||
"versions": {
|
||||
"values": [
|
||||
{"status": "stable",
|
||||
"id": "v1",
|
||||
"links": [{
|
||||
"href": "https://example.org:5050/v1",
|
||||
"rel": "self"}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
self.register_uris([
|
||||
dict(method='GET',
|
||||
uri='https://example.org:5050',
|
||||
json=discovery),
|
||||
])
|
||||
|
||||
adap = conn.baremetal_introspection
|
||||
self.assertEqual('baremetal-introspection', adap.service_type)
|
||||
self.assertEqual('public', adap.interface)
|
||||
self.assertEqual('https://example.org:5050', adap.endpoint_override)
|
||||
|
||||
def _test_missing_invalid_permutations(self, expected_reason):
|
||||
# Do special things to self.oslo_config_dict['heat'] before calling
|
||||
# this method.
|
||||
|
|
Loading…
Reference in New Issue