diff --git a/cinder/compute/nova.py b/cinder/compute/nova.py index 600e823d528..1c8aebde4d4 100644 --- a/cinder/compute/nova.py +++ b/cinder/compute/nova.py @@ -62,7 +62,8 @@ LOG = logging.getLogger(__name__) NOVA_API_VERSION = 2 nova_extensions = [ext for ext in nova_client.discover_extensions(2) - if ext.name == "assisted_volume_snapshots"] + if ext.name in ("assisted_volume_snapshots", + "list_extensions")] def novaclient(context, admin_endpoint=False, privileged_user=False, @@ -158,7 +159,7 @@ class API(base.Base): def has_extension(self, context, extension, timeout=None): try: - nova_exts = nova_client.discover_extensions(NOVA_API_VERSION) + nova_exts = novaclient(context).list_extensions.show_all() except request_exceptions.Timeout: raise exception.APITimeout(service='Nova') return extension in [e.name for e in nova_exts] diff --git a/cinder/tests/unit/scheduler/fakes.py b/cinder/tests/unit/scheduler/fakes.py index 58b77437482..071eb64e679 100644 --- a/cinder/tests/unit/scheduler/fakes.py +++ b/cinder/tests/unit/scheduler/fakes.py @@ -139,7 +139,7 @@ class FakeNovaClient(object): def __init__(self, ext_srv_attr=True): self.servers = FakeNovaClient.ServerManager() - self.discover_extensions = FakeNovaClient.ListExtManager( + self.list_extensions = FakeNovaClient.ListExtManager( ext_srv_attr=ext_srv_attr) diff --git a/cinder/tests/unit/scheduler/test_host_filters.py b/cinder/tests/unit/scheduler/test_host_filters.py index 659119dff87..ea1dbac30d1 100644 --- a/cinder/tests/unit/scheduler/test_host_filters.py +++ b/cinder/tests/unit/scheduler/test_host_filters.py @@ -907,7 +907,7 @@ class InstanceLocalityFilterTestCase(HostFiltersTestCase): def test_same_host(self, _mock_novaclient, fake_extensions): _mock_novaclient.return_value = fakes.FakeNovaClient() fake_extensions.return_value = ( - fakes.FakeNovaClient().discover_extensions.show_all()) + fakes.FakeNovaClient().list_extensions.show_all()) filt_cls = self.class_map['InstanceLocalityFilter']() host = fakes.FakeHostState('host1', {}) uuid = nova.novaclient().servers.create('host1') @@ -921,7 +921,7 @@ class InstanceLocalityFilterTestCase(HostFiltersTestCase): def test_different_host(self, _mock_novaclient, fake_extensions): _mock_novaclient.return_value = fakes.FakeNovaClient() fake_extensions.return_value = ( - fakes.FakeNovaClient().discover_extensions.show_all()) + fakes.FakeNovaClient().list_extensions.show_all()) filt_cls = self.class_map['InstanceLocalityFilter']() host = fakes.FakeHostState('host1', {}) uuid = nova.novaclient().servers.create('host2') @@ -978,7 +978,7 @@ class InstanceLocalityFilterTestCase(HostFiltersTestCase): # Simulate a HTTP timeout _mock_request.side_effect = request_exceptions.Timeout fake_extensions.return_value = ( - fakes.FakeNovaClient().discover_extensions.show_all()) + fakes.FakeNovaClient().list_extensions.show_all()) filt_cls = self.class_map['InstanceLocalityFilter']() host = fakes.FakeHostState('host1', {})