Pass on region when we don't have a valid ironic endpoint

If for some reason we don't have a valid endpoint to provide the
Ironic client, we should at the very least provide the information
it needs to make an informed decision.

Change-Id: I31fa1c6fb0b224fbb02f9ebf68abc6a3728e9389
Partial-Bug: #1825583
This commit is contained in:
Erik Olof Gunnar Andersson 2019-04-22 21:12:07 -07:00
parent 13278be9f2
commit 6eaa6db0ee
2 changed files with 6 additions and 0 deletions

View File

@ -42,6 +42,7 @@ class IronicClientWrapperTestCase(test.NoDBTestCase):
self.ironicclient = client_wrapper.IronicClientWrapper()
# Do not waste time sleeping
cfg.CONF.set_override('api_retry_interval', 0, 'ironic')
cfg.CONF.set_override('region_name', 'RegionOne', 'ironic')
get_ksa_adapter_p = mock.patch('nova.utils.get_ksa_adapter')
self.addCleanup(get_ksa_adapter_p.stop)
self.get_ksa_adapter = get_ksa_adapter_p.start()
@ -115,6 +116,7 @@ class IronicClientWrapperTestCase(test.NoDBTestCase):
'retry_interval': CONF.ironic.api_retry_interval,
'os_ironic_api_version': ['1.46', '1.38'],
'endpoint': None,
'region_name': CONF.ironic.region_name,
'interface': ['internal', 'public']}
mock_ir_cli.assert_called_once_with(1, **expected)

View File

@ -131,6 +131,10 @@ class IronicClientWrapper(object):
if ironic_url is None:
LOG.warning("Could not discover ironic_url via keystoneauth1: "
"Adapter.get_endpoint %s", ironic_url_none_reason)
# NOTE(eandersson): We pass in region here to make sure
# that the Ironic client can make an educated decision when
# we don't have a valid endpoint to pass on.
kwargs['region_name'] = ironic_conf.region_name
try:
cli = ironic.client.get_client(IRONIC_API_VERSION[0],