From 000aeb9df77dc61df9f597421a10a77c32bd89b0 Mon Sep 17 00:00:00 2001 From: Yusuke Hayashi Date: Sat, 8 Aug 2015 23:12:18 +0900 Subject: [PATCH] Update deprecated version of novaclient Update novaclient v1.1 to v2 because warning messages are shown as below when executing run_test.sh: UserWarning: Module novaclient.v1_1 is deprecated (taken as a basis for novaclient.v2). The preferable way to get client class or object you can find in novaclient.client module. Change-Id: I26602aceadac9a43d4fbaa14791bf6756eef9874 Partial-Bug: #1482873 --- cinder/compute/nova.py | 8 +++++--- cinder/tests/unit/compute/test_nova.py | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cinder/compute/nova.py b/cinder/compute/nova.py index ceacb5014..3508ff5ae 100644 --- a/cinder/compute/nova.py +++ b/cinder/compute/nova.py @@ -20,9 +20,9 @@ Handles all requests to Nova. from novaclient import exceptions as nova_exceptions from novaclient import extension from novaclient import service_catalog -from novaclient.v1_1 import client as nova_client -from novaclient.v1_1.contrib import assisted_volume_snapshots -from novaclient.v1_1.contrib import list_extensions +from novaclient.v2 import client as nova_client +from novaclient.v2.contrib import assisted_volume_snapshots +from novaclient.v2.contrib import list_extensions from oslo_config import cfg from oslo_log import log as logging from requests import exceptions as request_exceptions @@ -180,6 +180,7 @@ class API(base.Base): def create_volume_snapshot(self, context, volume_id, create_info): nova = novaclient(context, admin_endpoint=True, privileged_user=True) + # pylint: disable-msg=E1101 nova.assisted_volume_snapshots.create( volume_id, create_info=create_info) @@ -187,6 +188,7 @@ class API(base.Base): def delete_volume_snapshot(self, context, snapshot_id, delete_info): nova = novaclient(context, admin_endpoint=True, privileged_user=True) + # pylint: disable-msg=E1101 nova.assisted_volume_snapshots.delete( snapshot_id, delete_info=delete_info) diff --git a/cinder/tests/unit/compute/test_nova.py b/cinder/tests/unit/compute/test_nova.py index 4521fdd01..bd3cc5cdf 100644 --- a/cinder/tests/unit/compute/test_nova.py +++ b/cinder/tests/unit/compute/test_nova.py @@ -38,7 +38,7 @@ class NovaClientTestCase(test.TestCase): self.override_config('os_privileged_user_name', 'adminuser') self.override_config('os_privileged_user_password', 'strongpassword') - @mock.patch('novaclient.v1_1.client.Client') + @mock.patch('novaclient.v2.client.Client') def test_nova_client_regular(self, p_client): nova.novaclient(self.ctx) p_client.assert_called_once_with( @@ -47,7 +47,7 @@ class NovaClientTestCase(test.TestCase): insecure=False, endpoint_type='publicURL', cacert=None, timeout=None, extensions=nova.nova_extensions) - @mock.patch('novaclient.v1_1.client.Client') + @mock.patch('novaclient.v2.client.Client') def test_nova_client_admin_endpoint(self, p_client): nova.novaclient(self.ctx, admin_endpoint=True) p_client.assert_called_once_with( @@ -56,7 +56,7 @@ class NovaClientTestCase(test.TestCase): insecure=False, endpoint_type='adminURL', cacert=None, timeout=None, extensions=nova.nova_extensions) - @mock.patch('novaclient.v1_1.client.Client') + @mock.patch('novaclient.v2.client.Client') def test_nova_client_privileged_user(self, p_client): nova.novaclient(self.ctx, privileged_user=True) p_client.assert_called_once_with( @@ -65,7 +65,7 @@ class NovaClientTestCase(test.TestCase): insecure=False, endpoint_type='publicURL', cacert=None, timeout=None, extensions=nova.nova_extensions) - @mock.patch('novaclient.v1_1.client.Client') + @mock.patch('novaclient.v2.client.Client') def test_nova_client_privileged_user_custom_auth_url(self, p_client): self.override_config('os_privileged_user_auth_url', 'http://privatekeystonehost:5000/v2.0') @@ -76,7 +76,7 @@ class NovaClientTestCase(test.TestCase): insecure=False, endpoint_type='publicURL', cacert=None, timeout=None, extensions=nova.nova_extensions) - @mock.patch('novaclient.v1_1.client.Client') + @mock.patch('novaclient.v2.client.Client') def test_nova_client_custom_region(self, p_client): self.override_config('os_region_name', 'farfaraway') nova.novaclient(self.ctx)