From a07dccebe0575bdb45fdcfa7b343ad81095bf558 Mon Sep 17 00:00:00 2001 From: huangtianhua Date: Thu, 2 Jun 2016 14:39:13 +0800 Subject: [PATCH] Migrate to nova api version 2.1 The Nova v2 API code has been completely removed from Nova by change[1]. Although Nova still supports v2 compatible API with the legacy endpoint, it is better to switch to use Nova v2.1 in Heat. This change sets version='2.1' when init novaclient instance, then we can use novaclient v2 and will use nova api v2.1. [1] https://review.openstack.org/#/c/311653/ Change-Id: I428abb4ca05847da8ffc2da7157aa5c34263a205 Closes-Bug: #1588155 Partial-Bug: #1588171 --- heat/engine/clients/os/nova.py | 6 +++--- heat/tests/clients/test_nova_client.py | 2 +- heat/tests/openstack/nova/fakes.py | 4 ++-- heat_integrationtests/common/clients.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/heat/engine/clients/os/nova.py b/heat/engine/clients/os/nova.py index 9d60c1c498..4d63335a40 100644 --- a/heat/engine/clients/os/nova.py +++ b/heat/engine/clients/os/nova.py @@ -40,7 +40,7 @@ from heat.engine import constraints LOG = logging.getLogger(__name__) -NOVACLIENT_VERSION = "2" +NOVA_API_VERSION = "2.1" CLIENT_NAME = 'nova' @@ -65,7 +65,7 @@ class NovaClientPlugin(client_plugin.ClientPlugin): endpoint_type = self._get_client_option(CLIENT_NAME, 'endpoint_type') management_url = self.url_for(service_type=self.COMPUTE, endpoint_type=endpoint_type) - extensions = nc.discover_extensions(NOVACLIENT_VERSION) + extensions = nc.discover_extensions(NOVA_API_VERSION) args = { 'project_id': self.context.tenant_id, @@ -82,7 +82,7 @@ class NovaClientPlugin(client_plugin.ClientPlugin): 'insecure': self._get_client_option(CLIENT_NAME, 'insecure') } - client = nc.Client(NOVACLIENT_VERSION, **args) + client = nc.Client(NOVA_API_VERSION, **args) client.client.set_management_url(management_url) diff --git a/heat/tests/clients/test_nova_client.py b/heat/tests/clients/test_nova_client.py index 42604f1703..8786febcff 100644 --- a/heat/tests/clients/test_nova_client.py +++ b/heat/tests/clients/test_nova_client.py @@ -49,7 +49,7 @@ class NovaClientPluginTest(NovaClientPluginTestCase): ext_mock = self.patchobject(nc, 'discover_extensions') plugin = context.clients.client_plugin('nova') client = plugin.client() - ext_mock.assert_called_once_with('2') + ext_mock.assert_called_once_with('2.1') self.assertIsNotNone(client.servers) def test_get_ip(self): diff --git a/heat/tests/openstack/nova/fakes.py b/heat/tests/openstack/nova/fakes.py index bbd76ed08c..8192654634 100644 --- a/heat/tests/openstack/nova/fakes.py +++ b/heat/tests/openstack/nova/fakes.py @@ -24,9 +24,9 @@ from six.moves.urllib import parse as urlparse from heat.tests import fakes -NOVACLIENT_VERSION = "2" +NOVA_API_VERSION = "2.1" -Client = base_client.Client(NOVACLIENT_VERSION).__class__ +Client = base_client.Client(NOVA_API_VERSION).__class__ def fake_exception(status_code=404, message=None, details=None): diff --git a/heat_integrationtests/common/clients.py b/heat_integrationtests/common/clients.py index 7a674bf583..e7a3f311be 100644 --- a/heat_integrationtests/common/clients.py +++ b/heat_integrationtests/common/clients.py @@ -64,7 +64,7 @@ class ClientManager(object): CINDERCLIENT_VERSION = '2' HEATCLIENT_VERSION = '1' - NOVACLIENT_VERSION = '2' + NOVA_API_VERSION = '2.1' CEILOMETER_VERSION = '2' def __init__(self, conf): @@ -142,7 +142,7 @@ class ClientManager(object): # Create our default Nova client to use in testing return nova_client.Client( - self.NOVACLIENT_VERSION, + self.NOVA_API_VERSION, *client_args, service_type='compute', endpoint_type='publicURL',