From 18178ce0acd357005b531c5f8684e3baec38b158 Mon Sep 17 00:00:00 2001 From: huangtianhua Date: Fri, 23 Dec 2016 17:22:05 +0800 Subject: [PATCH] Make sure heat works with novaclient 7.0.0 This changes: 1. use 'endpoint_type' instead of 'interface' while init novaclient, because novaclient has deprecated the name 'interface', still use 'endpoint_type', details see: https://github.com/openstack/python-novaclient/blob/master/novaclient/client.py#L312-L327 2. novaclient has deleted HttpClient staff, change FakeClient for nova tests to use SessionClient instead. Change-Id: I5519b8fbf9983cc371bbc260e888c1dcbcd35af1 Closes-Bug: #1652224 --- heat/engine/clients/os/nova.py | 2 +- heat/tests/openstack/nova/fakes.py | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/heat/engine/clients/os/nova.py b/heat/engine/clients/os/nova.py index 7ebfdf8f62..ea9b8fbbb1 100644 --- a/heat/engine/clients/os/nova.py +++ b/heat/engine/clients/os/nova.py @@ -80,7 +80,7 @@ class NovaClientPlugin(client_plugin.ClientPlugin): args = { 'session': self.context.keystone_session, 'extensions': extensions, - 'interface': endpoint_type, + 'endpoint_type': endpoint_type, 'service_type': self.COMPUTE, 'region_name': self._get_region_name(), 'http_log_debug': self._get_client_option(CLIENT_NAME, diff --git a/heat/tests/openstack/nova/fakes.py b/heat/tests/openstack/nova/fakes.py index 8c42ed74e5..0934dffc89 100644 --- a/heat/tests/openstack/nova/fakes.py +++ b/heat/tests/openstack/nova/fakes.py @@ -39,19 +39,17 @@ def fake_exception(status_code=404, message=None, details=None): class FakeClient(fakes.FakeClient, Client): def __init__(self, *args, **kwargs): - super(FakeClient, self).__init__('username', 'password', 'project_id', - 'auth_url', direct_use=False) - self.client = FakeHTTPClient(**kwargs) + super(FakeClient, self).__init__(direct_use=False) + self.client = FakeSessionClient(session=mock.Mock(), **kwargs) -class FakeHTTPClient(base_client.HTTPClient): +class FakeSessionClient(base_client.SessionClient): - def __init__(self, **kwargs): - super(FakeHTTPClient, self).__init__('username', 'password', - 'project_id', 'auth_url') + def __init__(self, *args, **kwargs): + super(FakeSessionClient, self).__init__(*args, **kwargs) self.callstack = [] - def _cs_request(self, url, method, **kwargs): + def request(self, url, method, **kwargs): # Check that certain things are called correctly if method in ['GET', 'DELETE']: assert 'body' not in kwargs