Fix compatibility with novaclient 7.0.0

Recent update of upper-constraints for novaclient 7.0.0 in [1]
breaked magnum.
This patch makes magnum code compatible with latest release.

Also, passed endpoint_override while class Initialization to
remove warning [2]:-

[1] https://review.openstack.org/#/c/414170/

[2] Property `management_url` is deprecated for SessionClient.
It should be set via `endpoint_override` variable while class
initialization.

Change-Id: Idc0e501c23b77ed5b4e9e9e7a6a7b6af7c7bca75
Closes-Bug: #1658058
Closes-Bug: #1658005
This commit is contained in:
yatin 2017-01-20 16:59:30 +05:30
parent 0c0438b5f1
commit 203ce78b7a
2 changed files with 13 additions and 6 deletions

View File

@ -165,9 +165,10 @@ class OpenStackClients(object):
'insecure': self._get_client_option('nova', 'insecure')
}
session = self.keystone().session
self._nova = novaclient.Client(novaclient_version,
auth_token=self.auth_token, **args)
self._nova.client.management_url = endpoint
session=session,
endpoint_override=endpoint, **args)
return self._nova
@exception.wrap_keystone_exception

View File

@ -232,21 +232,27 @@ class ClientsTest(base.BaseTestCase):
self.assertEqual(barbican, barbican_cached)
@mock.patch.object(novaclient, 'Client')
@mock.patch.object(clients.OpenStackClients, 'keystone')
@mock.patch.object(clients.OpenStackClients, 'url_for')
@mock.patch.object(clients.OpenStackClients, 'auth_url')
def _test_clients_nova(self, expected_region_name, mock_auth, mock_url,
mock_call):
mock_keystone, mock_call):
mock_auth.__get__ = mock.Mock(return_value="keystone_url")
con = mock.MagicMock()
con.auth_token = "3bcc3d3a03f44e3d8377f9247b0ad155"
keystone = mock.MagicMock()
keystone.session = mock.MagicMock()
mock_keystone.return_value = keystone
con.auth_url = "keystone_url"
mock_url.return_value = "url_from_keystone"
obj = clients.OpenStackClients(con)
obj._nova = None
obj.nova()
expected_kwargs = {'session': keystone.session,
'endpoint_override': mock_url.return_value,
'cacert': None,
'insecure': False}
mock_call.assert_called_once_with(CONF.nova_client.api_version,
auth_token=con.auth_token,
cacert=None, insecure=False)
**expected_kwargs)
mock_url.assert_called_once_with(service_type='compute',
interface='publicURL',
region_name=expected_region_name)