From edd72883de8fc3efa3c49343a652312fc53a5d78 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 1 Jul 2024 11:04:35 +0100 Subject: [PATCH] cloud: Remove check for nova extensions All Nova extensions are enabled in API v2.1, which is the only API version we support now. There's no reason to query for these things. Change-Id: Ib12b2f4fe53182e047d6264de850178909b8fd5d Signed-off-by: Stephen Finucane --- openstack/cloud/_compute.py | 7 - openstack/cloud/_floating_ip.py | 6 - openstack/cloud/meta.py | 10 +- .../functional/cloud/test_floating_ip_pool.py | 7 - openstack/tests/unit/cloud/test_compute.py | 123 ------------------ .../tests/unit/cloud/test_floating_ip_pool.py | 57 -------- 6 files changed, 4 insertions(+), 206 deletions(-) diff --git a/openstack/cloud/_compute.py b/openstack/cloud/_compute.py index c77d5bb73..c70ff4af7 100644 --- a/openstack/cloud/_compute.py +++ b/openstack/cloud/_compute.py @@ -115,13 +115,6 @@ class ComputeCloudMixin: ) ) - def _nova_extensions(self): - extensions = {e.alias for e in self.compute.extensions()} - return extensions - - def _has_nova_extension(self, extension_name): - return extension_name in self._nova_extensions() - def search_keypairs(self, name_or_id=None, filters=None): """Search keypairs. diff --git a/openstack/cloud/_floating_ip.py b/openstack/cloud/_floating_ip.py index 15725cdae..8e82f90ec 100644 --- a/openstack/cloud/_floating_ip.py +++ b/openstack/cloud/_floating_ip.py @@ -15,7 +15,6 @@ import time import warnings from openstack.cloud import _utils -from openstack.cloud import exc from openstack.cloud import meta from openstack import exceptions from openstack.network.v2._proxy import Proxy @@ -161,11 +160,6 @@ class FloatingIPCloudMixin: :returns: A list of floating IP pool objects """ - if not self._has_nova_extension('os-floating-ip-pools'): - raise exc.OpenStackCloudUnavailableExtension( - 'Floating IP pools extension is not available on target cloud' - ) - data = proxy._json_response( self.compute.get('os-floating-ip-pools'), error_message="Error fetching floating IP pool list", diff --git a/openstack/cloud/meta.py b/openstack/cloud/meta.py index 5b1571ab0..245b4e7c7 100644 --- a/openstack/cloud/meta.py +++ b/openstack/cloud/meta.py @@ -39,9 +39,8 @@ def find_nova_interfaces( # ext_tag is specified, but this interface has no tag # We could actually return right away as this means that # this cloud doesn't support OS-EXT-IPS. Nevertheless, - # it would be better to perform an explicit check. e.g.: - # cloud._has_nova_extension('OS-EXT-IPS') - # But this needs cloud to be passed to this function. + # it would be better to perform an explicit check + # but this needs cloud to be passed to this function. continue elif interface_spec['OS-EXT-IPS:type'] != ext_tag: # Type doesn't match, continue with next one @@ -52,9 +51,8 @@ def find_nova_interfaces( # mac_addr is specified, but this interface has no mac_addr # We could actually return right away as this means that # this cloud doesn't support OS-EXT-IPS-MAC. Nevertheless, - # it would be better to perform an explicit check. e.g.: - # cloud._has_nova_extension('OS-EXT-IPS-MAC') - # But this needs cloud to be passed to this function. + # it would be better to perform an explicit check + # but this needs cloud to be passed to this function. continue elif interface_spec['OS-EXT-IPS-MAC:mac_addr'] != mac_addr: # MAC doesn't match, continue with next one diff --git a/openstack/tests/functional/cloud/test_floating_ip_pool.py b/openstack/tests/functional/cloud/test_floating_ip_pool.py index c963aa7b0..2d0161c70 100644 --- a/openstack/tests/functional/cloud/test_floating_ip_pool.py +++ b/openstack/tests/functional/cloud/test_floating_ip_pool.py @@ -32,13 +32,6 @@ from openstack.tests.functional import base class TestFloatingIPPool(base.BaseFunctionalTest): - def setUp(self): - super().setUp() - - if not self.user_cloud._has_nova_extension('os-floating-ip-pools'): - # Skipping this test is floating-ip-pool extension is not - # available on the testing cloud - self.skip('Floating IP pools extension is not available') def test_list_floating_ip_pools(self): pools = self.user_cloud.list_floating_ip_pools() diff --git a/openstack/tests/unit/cloud/test_compute.py b/openstack/tests/unit/cloud/test_compute.py index b4c3d0340..2c06ecc85 100644 --- a/openstack/tests/unit/cloud/test_compute.py +++ b/openstack/tests/unit/cloud/test_compute.py @@ -17,129 +17,6 @@ from openstack.tests import fakes from openstack.tests.unit import base -class TestNovaExtensions(base.TestCase): - def test__nova_extensions(self): - body = [ - { - "updated": "2014-12-03T00:00:00Z", - "name": "Multinic", - "links": [], - "namespace": "http://openstack.org/compute/ext/fake_xml", - "alias": "NMN", - "description": "Multiple network support.", - }, - { - "updated": "2014-12-03T00:00:00Z", - "name": "DiskConfig", - "links": [], - "namespace": "http://openstack.org/compute/ext/fake_xml", - "alias": "OS-DCF", - "description": "Disk Management Extension.", - }, - ] - self.register_uris( - [ - dict( - method='GET', - uri='{endpoint}/extensions'.format( - endpoint=fakes.COMPUTE_ENDPOINT - ), - json=dict(extensions=body), - ) - ] - ) - extensions = self.cloud._nova_extensions() - self.assertEqual({'NMN', 'OS-DCF'}, extensions) - - self.assert_calls() - - def test__nova_extensions_fails(self): - self.register_uris( - [ - dict( - method='GET', - uri='{endpoint}/extensions'.format( - endpoint=fakes.COMPUTE_ENDPOINT - ), - status_code=404, - ), - ] - ) - self.assertRaises( - exceptions.NotFoundException, self.cloud._nova_extensions - ) - - self.assert_calls() - - def test__has_nova_extension(self): - body = [ - { - "updated": "2014-12-03T00:00:00Z", - "name": "Multinic", - "links": [], - "namespace": "http://openstack.org/compute/ext/fake_xml", - "alias": "NMN", - "description": "Multiple network support.", - }, - { - "updated": "2014-12-03T00:00:00Z", - "name": "DiskConfig", - "links": [], - "namespace": "http://openstack.org/compute/ext/fake_xml", - "alias": "OS-DCF", - "description": "Disk Management Extension.", - }, - ] - self.register_uris( - [ - dict( - method='GET', - uri='{endpoint}/extensions'.format( - endpoint=fakes.COMPUTE_ENDPOINT - ), - json=dict(extensions=body), - ) - ] - ) - self.assertTrue(self.cloud._has_nova_extension('NMN')) - - self.assert_calls() - - def test__has_nova_extension_missing(self): - body = [ - { - "updated": "2014-12-03T00:00:00Z", - "name": "Multinic", - "links": [], - "namespace": "http://openstack.org/compute/ext/fake_xml", - "alias": "NMN", - "description": "Multiple network support.", - }, - { - "updated": "2014-12-03T00:00:00Z", - "name": "DiskConfig", - "links": [], - "namespace": "http://openstack.org/compute/ext/fake_xml", - "alias": "OS-DCF", - "description": "Disk Management Extension.", - }, - ] - self.register_uris( - [ - dict( - method='GET', - uri='{endpoint}/extensions'.format( - endpoint=fakes.COMPUTE_ENDPOINT - ), - json=dict(extensions=body), - ) - ] - ) - self.assertFalse(self.cloud._has_nova_extension('invalid')) - - self.assert_calls() - - class TestServers(base.TestCase): def test_get_server(self): server1 = fakes.make_fake_server('123', 'mickey') diff --git a/openstack/tests/unit/cloud/test_floating_ip_pool.py b/openstack/tests/unit/cloud/test_floating_ip_pool.py index bfa5645aa..ee3d55eae 100644 --- a/openstack/tests/unit/cloud/test_floating_ip_pool.py +++ b/openstack/tests/unit/cloud/test_floating_ip_pool.py @@ -19,7 +19,6 @@ test_floating_ip_pool Test floating IP pool resource (managed by nova) """ -from openstack import exceptions from openstack.tests import fakes from openstack.tests.unit import base @@ -30,24 +29,6 @@ class TestFloatingIPPool(base.TestCase): def test_list_floating_ip_pools(self): self.register_uris( [ - dict( - method='GET', - uri='{endpoint}/extensions'.format( - endpoint=fakes.COMPUTE_ENDPOINT - ), - json={ - 'extensions': [ - { - 'alias': 'os-floating-ip-pools', - 'updated': '2014-12-03T00:00:00Z', - 'name': 'FloatingIpPools', - 'links': [], - 'namespace': 'http://docs.openstack.org/compute/ext/fake_xml', # noqa: E501 - 'description': 'Floating IPs support.', - } - ] - }, - ), dict( method='GET', uri='{endpoint}/os-floating-ip-pools'.format( @@ -63,41 +44,3 @@ class TestFloatingIPPool(base.TestCase): self.assertCountEqual(floating_ip_pools, self.pools) self.assert_calls() - - def test_list_floating_ip_pools_exception(self): - self.register_uris( - [ - dict( - method='GET', - uri='{endpoint}/extensions'.format( - endpoint=fakes.COMPUTE_ENDPOINT - ), - json={ - 'extensions': [ - { - 'alias': 'os-floating-ip-pools', - 'updated': '2014-12-03T00:00:00Z', - 'name': 'FloatingIpPools', - 'links': [], - 'namespace': 'http://docs.openstack.org/compute/ext/fake_xml', # noqa: E501 - 'description': 'Floating IPs support.', - } - ] - }, - ), - dict( - method='GET', - uri='{endpoint}/os-floating-ip-pools'.format( - endpoint=fakes.COMPUTE_ENDPOINT - ), - status_code=404, - ), - ] - ) - - self.assertRaises( - exceptions.SDKException, - self.cloud.list_floating_ip_pools, - ) - - self.assert_calls()