summaryrefslogtreecommitdiff
path: root/nova
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-03-13 12:08:39 +0000
committerGerrit Code Review <review@openstack.org>2019-03-13 12:08:39 +0000
commit2529ddfbe7940e90548175d6e2032383c38cda8f (patch)
treeb67f1e3b1a0736296e9e9c965d88f0b8a96a0c87 /nova
parent141eb3e814e41b8d0587ccd01fb6c615618d2d20 (diff)
parente082bdc166cb8215576801e0c89ef1fe771681ed (diff)
downloadnova-2529ddfbe7940e90548175d6e2032383c38cda8f.tar.gz
Merge "pass endpoint interface to Ironic client"
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/unit/virt/ironic/test_client_wrapper.py29
-rw-r--r--nova/virt/ironic/client_wrapper.py6
2 files changed, 32 insertions, 3 deletions
diff --git a/nova/tests/unit/virt/ironic/test_client_wrapper.py b/nova/tests/unit/virt/ironic/test_client_wrapper.py
index c235211e98..3364b49e0e 100644
--- a/nova/tests/unit/virt/ironic/test_client_wrapper.py
+++ b/nova/tests/unit/virt/ironic/test_client_wrapper.py
@@ -88,7 +88,8 @@ class IronicClientWrapperTestCase(test.NoDBTestCase):
'retry_interval': CONF.ironic.api_retry_interval,
'os_ironic_api_version': ['1.46', '1.38'],
'endpoint':
- self.get_ksa_adapter.return_value.get_endpoint.return_value}
+ self.get_ksa_adapter.return_value.get_endpoint.return_value,
+ 'interface': ['internal', 'public']}
mock_ir_cli.assert_called_once_with(1, **expected)
@mock.patch.object(keystoneauth1.session, 'Session')
@@ -113,7 +114,8 @@ class IronicClientWrapperTestCase(test.NoDBTestCase):
'max_retries': CONF.ironic.api_max_retries,
'retry_interval': CONF.ironic.api_retry_interval,
'os_ironic_api_version': ['1.46', '1.38'],
- 'endpoint': None}
+ 'endpoint': None,
+ 'interface': ['internal', 'public']}
mock_ir_cli.assert_called_once_with(1, **expected)
@mock.patch.object(keystoneauth1.session, 'Session')
@@ -131,7 +133,28 @@ class IronicClientWrapperTestCase(test.NoDBTestCase):
'max_retries': CONF.ironic.api_max_retries,
'retry_interval': CONF.ironic.api_retry_interval,
'os_ironic_api_version': ['1.46', '1.38'],
- 'endpoint': endpoint}
+ 'endpoint': endpoint,
+ 'interface': ['internal', 'public']}
+ mock_ir_cli.assert_called_once_with(1, **expected)
+
+ @mock.patch.object(keystoneauth1.session, 'Session')
+ @mock.patch.object(ironic_client, 'get_client')
+ def test__get_client_and_valid_interfaces(self, mock_ir_cli, mock_session):
+ """Endpoint discovery via legacy api_endpoint conf option."""
+ mock_session.return_value = 'session'
+ endpoint = 'https://baremetal.example.com/endpoint'
+ self.flags(api_endpoint=endpoint, group='ironic')
+ self.flags(valid_interfaces='admin', group='ironic')
+ ironicclient = client_wrapper.IronicClientWrapper()
+ # dummy call to have _get_client() called
+ ironicclient.call("node.list")
+ self.get_ksa_adapter.assert_not_called()
+ expected = {'session': 'session',
+ 'max_retries': CONF.ironic.api_max_retries,
+ 'retry_interval': CONF.ironic.api_retry_interval,
+ 'os_ironic_api_version': ['1.46', '1.38'],
+ 'endpoint': endpoint,
+ 'interface': ['admin']}
mock_ir_cli.assert_called_once_with(1, **expected)
@mock.patch.object(client_wrapper.IronicClientWrapper, '_multi_getattr')
diff --git a/nova/virt/ironic/client_wrapper.py b/nova/virt/ironic/client_wrapper.py
index 1bccbdff24..d0eb1e5e40 100644
--- a/nova/virt/ironic/client_wrapper.py
+++ b/nova/virt/ironic/client_wrapper.py
@@ -99,6 +99,12 @@ class IronicClientWrapper(object):
kwargs['os_ironic_api_version'] = [
'%d.%d' % IRONIC_API_VERSION, '%d.%d' % PRIOR_IRONIC_API_VERSION]
+ ironic_conf = CONF[IRONIC_GROUP.name]
+ # valid_interfaces is a list. ironicclient passes this kwarg through to
+ # ksa, which is set up to handle 'interface' as either a list or a
+ # single value.
+ kwargs['interface'] = ironic_conf.valid_interfaces
+
# NOTE(clenimar/efried): by default, the endpoint is taken from the
# service catalog. Use `endpoint_override` if you want to override it.
if CONF.ironic.api_endpoint: