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 <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-07-01 11:04:35 +01:00
parent 1d95962881
commit edd72883de
6 changed files with 4 additions and 206 deletions

View File

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

View File

@ -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",

View File

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

View File

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

View File

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

View File

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