From 3cef55907b1c7fe273a9972f82a512a6ce2286bd Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Tue, 3 Sep 2019 10:58:59 -0400 Subject: [PATCH] nova: use EndpointNotFound from keystoneauth1 I16e0b6e55a9c9da04c4582f9be672018d37bf368 in python-novaclient 15.0.0 removed the EndpointNotFound class which breaks the cinder unit test "test_novaclient_exceptions". That test was added with change Iea3ff0405ef8cf9c5222a489d85f9d135ebd3652 in Ocata after novaclient 7.0.0 removed its service catalog code. The cinder novaclient module code was updated in I55613793c8f525a36ac74636f47d7ab76f5c7e39 (Pike) and Ie27f3b528dbfaa57fe354a84a93787e1618182a3 (Pike) to remove the hacked service catalog code but still checks the service catalog for an identity endpoint if cinder isn't configured with an auth_url for talking to nova. That code was raising novaclient.EndpointNotFound which is now gone, so this change swaps it to use EndpointNotFound from the keystoneauth1 library instead. Needed by: https://review.opendev.org/679295/ Change-Id: I4b03beba0f847d779b6f3031be7ac68925cc79f4 Closes-Bug: #1842440 --- cinder/compute/nova.py | 3 ++- cinder/tests/unit/compute/test_nova.py | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cinder/compute/nova.py b/cinder/compute/nova.py index 13c0a51c349..1afd9ecc919 100644 --- a/cinder/compute/nova.py +++ b/cinder/compute/nova.py @@ -16,6 +16,7 @@ Handles all requests to Nova. """ +from keystoneauth1 import exceptions as ks_exc from keystoneauth1 import identity from keystoneauth1 import loading as ks_loading from novaclient import api_versions @@ -77,7 +78,7 @@ def _get_identity_endpoint_from_sc(context): if (not CONF[NOVA_GROUP].region_name or endpoint.get('region') == CONF[NOVA_GROUP].region_name): return endpoint.get(CONF[NOVA_GROUP].interface + 'URL') - raise nova_exceptions.EndpointNotFound() + raise ks_exc.EndpointNotFound() def novaclient(context, privileged_user=False, timeout=None, api_version=None): diff --git a/cinder/tests/unit/compute/test_nova.py b/cinder/tests/unit/compute/test_nova.py index 89239cd41e1..03b31cdb470 100644 --- a/cinder/tests/unit/compute/test_nova.py +++ b/cinder/tests/unit/compute/test_nova.py @@ -13,6 +13,7 @@ # under the License. import ddt +from keystoneauth1 import exceptions as ks_exc import mock from cinder.compute import nova @@ -171,11 +172,10 @@ class NovaClientTestCase(test.TestCase): global_request_id=self.ctx.request_id, timeout=None, extensions=nova.nova_extensions) - def test_novaclient_exceptions(self): - # This is to prevent regression if exceptions are - # removed from novaclient since the service catalog - # code does not have thorough tests. - self.assertTrue(hasattr(nova_exceptions, 'EndpointNotFound')) + def test_get_identity_endpoint_from_sc_endpoint_not_found(self): + ctxt = context.get_admin_context() + self.assertRaises(ks_exc.EndpointNotFound, + nova._get_identity_endpoint_from_sc, ctxt) class FakeNovaClient(object):