Bump to Nova v2.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 Cinder. [1] https://review.openstack.org/#/c/311653/ Change-Id: Iadd3363265be6c5a8ed46704a712da6c15e2b046 Closes-bug: #1588171
This commit is contained in:
parent
cfbb5bde4d
commit
c614308563
cinder
@ -18,6 +18,7 @@ Handles all requests to Nova.
|
||||
|
||||
import keystoneauth1.loading
|
||||
import keystoneauth1.session
|
||||
from novaclient import api_versions
|
||||
from novaclient import client as nova_client
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
from novaclient import service_catalog
|
||||
@ -60,9 +61,10 @@ CONF.register_opts(nova_opts)
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
# TODO(e0ne): Make Nova version configurable in Mitaka.
|
||||
NOVA_API_VERSION = 2
|
||||
NOVA_API_VERSION = "2.1"
|
||||
|
||||
nova_extensions = [ext for ext in nova_client.discover_extensions(2)
|
||||
nova_extensions = [ext for ext in
|
||||
nova_client.discover_extensions(NOVA_API_VERSION)
|
||||
if ext.name in ("assisted_volume_snapshots",
|
||||
"list_extensions")]
|
||||
|
||||
@ -144,7 +146,7 @@ def novaclient(context, admin_endpoint=False, privileged_user=False,
|
||||
project_name=context.project_name)
|
||||
keystone_session = keystoneauth1.session.Session(auth=auth)
|
||||
|
||||
c = nova_client.Client(NOVA_API_VERSION,
|
||||
c = nova_client.Client(api_versions.APIVersion(NOVA_API_VERSION),
|
||||
session=keystone_session,
|
||||
insecure=CONF.nova_api_insecure,
|
||||
timeout=timeout,
|
||||
|
@ -38,60 +38,65 @@ class NovaClientTestCase(test.TestCase):
|
||||
self.override_config('os_privileged_user_name', 'adminuser')
|
||||
self.override_config('os_privileged_user_password', 'strongpassword')
|
||||
|
||||
@mock.patch('novaclient.api_versions.APIVersion')
|
||||
@mock.patch('novaclient.client.Client')
|
||||
@mock.patch('keystoneauth1.loading.get_plugin_loader')
|
||||
@mock.patch('keystoneauth1.session.Session')
|
||||
def test_nova_client_regular(self, p_session, p_plugin_loader, p_client):
|
||||
def test_nova_client_regular(self, p_session, p_plugin_loader, p_client,
|
||||
p_api_version):
|
||||
nova.novaclient(self.ctx)
|
||||
p_plugin_loader.return_value.load_from_options.assert_called_once_with(
|
||||
auth_url='http://novahost:8774/v2/e3f0833dc08b4cea',
|
||||
password='token', project_name=None, username='regularuser'
|
||||
)
|
||||
|
||||
p_client.assert_called_once_with(
|
||||
nova.NOVA_API_VERSION,
|
||||
p_api_version(nova.NOVA_API_VERSION),
|
||||
session=p_session.return_value, region_name=None,
|
||||
insecure=False, endpoint_type='publicURL', cacert=None,
|
||||
timeout=None, extensions=nova.nova_extensions)
|
||||
|
||||
@mock.patch('novaclient.api_versions.APIVersion')
|
||||
@mock.patch('novaclient.client.Client')
|
||||
@mock.patch('keystoneauth1.loading.get_plugin_loader')
|
||||
@mock.patch('keystoneauth1.session.Session')
|
||||
def test_nova_client_admin_endpoint(self, p_session, p_plugin_loader,
|
||||
p_client):
|
||||
p_client, p_api_version):
|
||||
nova.novaclient(self.ctx, admin_endpoint=True)
|
||||
p_plugin_loader.return_value.load_from_options.assert_called_once_with(
|
||||
auth_url='http://novaadmhost:4778/v2/e3f0833dc08b4cea',
|
||||
password='token', project_name=None, username='regularuser'
|
||||
)
|
||||
p_client.assert_called_once_with(
|
||||
nova.NOVA_API_VERSION,
|
||||
p_api_version(nova.NOVA_API_VERSION),
|
||||
session=p_session.return_value, region_name=None,
|
||||
insecure=False, endpoint_type='adminURL', cacert=None,
|
||||
timeout=None, extensions=nova.nova_extensions)
|
||||
|
||||
@mock.patch('novaclient.api_versions.APIVersion')
|
||||
@mock.patch('novaclient.client.Client')
|
||||
@mock.patch('keystoneauth1.loading.get_plugin_loader')
|
||||
@mock.patch('keystoneauth1.session.Session')
|
||||
def test_nova_client_privileged_user(self, p_session, p_plugin_loader,
|
||||
p_client):
|
||||
p_client, p_api_version):
|
||||
nova.novaclient(self.ctx, privileged_user=True)
|
||||
p_plugin_loader.return_value.load_from_options.assert_called_once_with(
|
||||
auth_url='http://keystonehost:5000/v2.0',
|
||||
password='strongpassword', project_name=None, username='adminuser'
|
||||
)
|
||||
p_client.assert_called_once_with(
|
||||
nova.NOVA_API_VERSION,
|
||||
p_api_version(nova.NOVA_API_VERSION),
|
||||
session=p_session.return_value, region_name=None,
|
||||
insecure=False, endpoint_type='publicURL', cacert=None,
|
||||
timeout=None, extensions=nova.nova_extensions)
|
||||
|
||||
@mock.patch('novaclient.api_versions.APIVersion')
|
||||
@mock.patch('novaclient.client.Client')
|
||||
@mock.patch('keystoneauth1.loading.get_plugin_loader')
|
||||
@mock.patch('keystoneauth1.session.Session')
|
||||
def test_nova_client_privileged_user_custom_auth_url(self, p_session,
|
||||
p_plugin_loader,
|
||||
p_client):
|
||||
p_client,
|
||||
p_api_version):
|
||||
self.override_config('os_privileged_user_auth_url',
|
||||
'http://privatekeystonehost:5000/v2.0')
|
||||
nova.novaclient(self.ctx, privileged_user=True)
|
||||
@ -100,16 +105,17 @@ class NovaClientTestCase(test.TestCase):
|
||||
password='strongpassword', project_name=None, username='adminuser'
|
||||
)
|
||||
p_client.assert_called_once_with(
|
||||
nova.NOVA_API_VERSION,
|
||||
p_api_version(nova.NOVA_API_VERSION),
|
||||
session=p_session.return_value, region_name=None,
|
||||
insecure=False, endpoint_type='publicURL', cacert=None,
|
||||
timeout=None, extensions=nova.nova_extensions)
|
||||
|
||||
@mock.patch('novaclient.api_versions.APIVersion')
|
||||
@mock.patch('novaclient.client.Client')
|
||||
@mock.patch('keystoneauth1.loading.get_plugin_loader')
|
||||
@mock.patch('keystoneauth1.session.Session')
|
||||
def test_nova_client_custom_region(self, p_session, p_plugin_loader,
|
||||
p_client):
|
||||
p_client, p_api_version):
|
||||
self.override_config('os_region_name', 'farfaraway')
|
||||
nova.novaclient(self.ctx)
|
||||
p_plugin_loader.return_value.load_from_options.assert_called_once_with(
|
||||
@ -117,7 +123,7 @@ class NovaClientTestCase(test.TestCase):
|
||||
password='token', project_name=None, username='regularuser'
|
||||
)
|
||||
p_client.assert_called_once_with(
|
||||
nova.NOVA_API_VERSION,
|
||||
p_api_version(nova.NOVA_API_VERSION),
|
||||
session=p_session.return_value, region_name='farfaraway',
|
||||
insecure=False, endpoint_type='publicURL', cacert=None,
|
||||
timeout=None, extensions=nova.nova_extensions)
|
||||
|
Loading…
x
Reference in New Issue
Block a user