Use the Connection.baremetal adapter for ironicclient Session

The result of get_session does not respect baremetal-specific options
like baremetal_endpoint_override in clouds.yaml.

Change-Id: Idccf4a0fc055dc9b81705b9e3b632a61a8891cfa
This commit is contained in:
Dmitry Tantsur 2018-11-06 14:46:35 +01:00
parent 192b740d96
commit cea2cda604
2 changed files with 5 additions and 1 deletions

View File

@ -62,8 +62,10 @@ class Provisioner(object):
raise TypeError('Either session or cloud_region must be provided, '
'but not both')
else:
session = cloud_region.get_session()
self.connection = connection.Connection(config=cloud_region)
# NOTE(dtantsur): Connection.baremetal is a keystoneauth Adapter
# for baremetal API.
session = self.connection.baremetal
self._api = _os_api.API(session, self.connection)
self._dry_run = dry_run

View File

@ -50,6 +50,8 @@ class TestInit(testtools.TestCase):
@mock.patch.object(_provisioner.connection, 'Connection', autospec=True)
def test_cloud_region_only(self, mock_conn):
region = mock.Mock()
mock_conn.return_value.baremetal = mock.Mock(spec=['get_endpoint'])
mock_conn.return_value.baremetal.get_endpoint.return_value = 'http://'
_provisioner.Provisioner(cloud_region=region)
mock_conn.assert_called_once_with(config=region)