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
This commit is contained in:
Yusuke Hayashi 2015-08-08 23:12:18 +09:00
parent 5a47eecd0e
commit 000aeb9df7
2 changed files with 10 additions and 8 deletions

View File

@ -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)

View File

@ -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)