Browse Source

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
Dmitry Tantsur 5 months ago
parent
commit
cea2cda604
2 changed files with 5 additions and 1 deletions
  1. 3
    1
      metalsmith/_provisioner.py
  2. 2
    0
      metalsmith/test/test_provisioner.py

+ 3
- 1
metalsmith/_provisioner.py View File

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

+ 2
- 0
metalsmith/test/test_provisioner.py View File

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

Loading…
Cancel
Save