diff options
author | Zuul <zuul@review.opendev.org> | 2020-11-18 13:33:14 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2020-11-18 13:33:14 +0000 |
commit | 53cbf78ab7f20f9acd0906695d54c67f27861d62 (patch) | |
tree | 6711e5baf1b98dbc209bf83bb22caf9e62bf292d /openstack_dashboard | |
parent | 6b702f4a1c799905acabd3e3844e93a619e99f92 (diff) | |
parent | 672c43c43e13cb2e4b1177f77ad322cca60970ec (diff) | |
download | horizon-53cbf78ab7f20f9acd0906695d54c67f27861d62.tar.gz |
Merge "Drop OPENSTACK_NOVA_EXTENSIONS_BLACKLIST finally"
Diffstat (limited to 'openstack_dashboard')
-rw-r--r-- | openstack_dashboard/api/nova.py | 130 | ||||
-rw-r--r-- | openstack_dashboard/api/rest/nova.py | 27 | ||||
-rw-r--r-- | openstack_dashboard/defaults.py | 2 | ||||
-rw-r--r-- | openstack_dashboard/test/unit/api/rest/test_nova.py | 19 | ||||
-rw-r--r-- | openstack_dashboard/test/unit/api/test_nova.py | 9 |
5 files changed, 4 insertions, 183 deletions
diff --git a/openstack_dashboard/api/nova.py b/openstack_dashboard/api/nova.py index ae1875f60..bfdf650cb 100644 --- a/openstack_dashboard/api/nova.py +++ b/openstack_dashboard/api/nova.py @@ -22,7 +22,6 @@ import collections import logging from operator import attrgetter -from django.conf import settings from django.utils.translation import ugettext_lazy as _ from novaclient import api_versions @@ -46,114 +45,6 @@ INSTANCE_ACTIVE_STATE = 'ACTIVE' VOLUME_STATE_AVAILABLE = "available" DEFAULT_QUOTA_NAME = 'default' -# python-novaclient 16.0.0 removed the list_extensions module and the -# GET /extensions API is deprecated since Newton. Furthermore, the ability -# to enable/disable compute API extensions was also removed in Newton. -# Therefore we hard-code the list of extensions here until the -# OPENSTACK_NOVA_EXTENSIONS_BLACKLIST setting is no longer used. -EXTENSIONS = ( - 'AccessIPs', - 'AdminActions', - 'AdminPassword', - 'Agents', - 'Aggregates', - 'AssistedVolumeSnapshots', - 'AttachInterfaces', - 'AvailabilityZone', - 'BareMetalExtStatus', - 'BareMetalNodes', - 'BlockDeviceMapping', - 'BlockDeviceMappingV2Boot', - 'CellCapacities', - 'Cells', - 'Certificates', - 'Cloudpipe', - 'CloudpipeUpdate', - 'ConfigDrive', - 'ConsoleAuthTokens', - 'ConsoleOutput', - 'Consoles', - 'CreateBackup', - 'Createserverext', - 'DeferredDelete', - 'DiskConfig', - 'Evacuate', - 'ExtendedAvailabilityZone', - 'ExtendedEvacuateFindHost', - 'ExtendedFloatingIps', - 'ExtendedHypervisors', - 'ExtendedIps', - 'ExtendedIpsMac', - 'ExtendedNetworks', - 'ExtendedQuotas', - 'ExtendedRescueWithImage', - 'ExtendedServerAttributes', - 'ExtendedServices', - 'ExtendedServicesDelete', - 'ExtendedStatus', - 'ExtendedStatus', - 'ExtendedVolumes', - 'FixedIPs', - 'FlavorAccess', - 'FlavorDisabled', - 'FlavorExtraData', - 'FlavorExtraSpecs', - 'FlavorManage', - 'FlavorRxtx', - 'FlavorSwap', - 'FloatingIpDns', - 'FloatingIpPools', - 'FloatingIps', - 'FloatingIpsBulk', - 'Fping', - 'HideServerAddresses', - 'Hosts', - 'HypervisorStatus', - 'Hypervisors', - 'ImageSize', - 'InstanceActions', - 'Keypairs', - 'LockServer', - 'MigrateServer', - 'Migrations', - 'Multinic', - 'MultipleCreate', - 'NetworkAssociationSupport', - 'Networks', - 'OSInstanceUsageAuditLog', - 'OSTenantNetworks', - 'PauseServer', - 'Personality', - 'PreserveEphemeralOnRebuild', - 'QuotaClasses', - 'Quotas', - 'Rescue', - 'SchedulerHints', - 'SecurityGroupDefaultRules', - 'SecurityGroups', - 'ServerDiagnostics', - 'ServerExternalEvents', - 'ServerGroupQuotas', - 'ServerGroups', - 'ServerListMultiStatus', - 'ServerPassword', - 'ServerSortKeys', - 'ServerStartStop', - 'ServerUsage', - 'Services', - 'Shelve', - 'SimpleTenantUsage', - 'SuspendServer', - 'UsedLimits', - 'UsedLimitsForAdmin', - 'UserData', - 'UserQuotas', - 'VirtualInterfaces', - 'VolumeAttachmentUpdate', - 'Volumes' -) - - get_microversion = _nova.get_microversion server_get = _nova.server_get Server = _nova.Server @@ -1125,27 +1016,6 @@ def interface_detach(request, server, port_id): @profiler.trace -@memoized.memoized -def list_extensions(request): - """List all nova extension names, except the ones in the blacklist.""" - blacklist = set(settings.OPENSTACK_NOVA_EXTENSIONS_BLACKLIST) - return tuple( - extension for extension in EXTENSIONS if extension not in blacklist - ) - - -@profiler.trace -@memoized.memoized -def extension_supported(extension_name, request): - """Determine if nova supports a given extension name. - - Example values for the extension_name include AdminActions, ConsoleOutput, - etc. - """ - return extension_name in list_extensions(request) - - -@profiler.trace def can_set_server_password(): return utils.get_dict_config('OPENSTACK_HYPERVISOR_FEATURES', 'can_set_password') diff --git a/openstack_dashboard/api/rest/nova.py b/openstack_dashboard/api/rest/nova.py index 2fe5bb48b..7be6683b6 100644 --- a/openstack_dashboard/api/rest/nova.py +++ b/openstack_dashboard/api/rest/nova.py @@ -120,11 +120,9 @@ class Services(generic.View): def get(self, request): """Get a list of nova services. - Will return HTTP 501 status code if the service_list extension is - not supported. + Will return HTTP 501 status code if the compute service is enabled. """ - if (api.base.is_service_enabled(request, 'compute') and - api.nova.extension_supported('Services', request)): + if api.base.is_service_enabled(request, 'compute'): result = api.nova.service_list(request) return {'items': [u.to_dict() for u in result]} raise rest_utils.AjaxError(501, '') @@ -347,7 +345,7 @@ class Servers(generic.View): :param name: The new server name. :param source_id: The ID of the image to use. :param flavor_id: The ID of the flavor to use. - :param key_name: (optional extension) name of previously created + :param key_name: (optional) name of previously created keypair to inject into the instance. :param user_data: user data to pass to be exposed by the metadata server this can be a file type object as well or a @@ -502,25 +500,6 @@ class ServerMetadata(generic.View): @urls.register -class Extensions(generic.View): - """API for nova extensions.""" - url_regex = r'nova/extensions/$' - - @rest_utils.ajax() - def get(self, request): - """Get a list of extensions. - - The listing result is an object with property "items". Each item is - an object with property "name". - - Example GET: - http://localhost/api/nova/extensions - """ - result = api.nova.list_extensions(request) - return {'items': [{'name': e} for e in result]} - - -@urls.register class Flavors(generic.View): """API for nova flavors.""" url_regex = r'nova/flavors/$' diff --git a/openstack_dashboard/defaults.py b/openstack_dashboard/defaults.py index a324dcac5..6b151ae71 100644 --- a/openstack_dashboard/defaults.py +++ b/openstack_dashboard/defaults.py @@ -461,8 +461,6 @@ OPENSTACK_NEUTRON_NETWORK = { # a performance issue in the project instance table in large deployments. OPENSTACK_INSTANCE_RETRIEVE_IP_ADDRESSES = True -OPENSTACK_NOVA_EXTENSIONS_BLACKLIST = [] - # This setting controls whether SimpleTenantUsage nova API is used in the usage # overview. According to feedbacks to the horizon team, the usage of # SimpleTenantUsage can cause performance issues in the nova API in larger diff --git a/openstack_dashboard/test/unit/api/rest/test_nova.py b/openstack_dashboard/test/unit/api/rest/test_nova.py index 63156d040..43feb9712 100644 --- a/openstack_dashboard/test/unit/api/rest/test_nova.py +++ b/openstack_dashboard/test/unit/api/rest/test_nova.py @@ -484,19 +484,6 @@ class NovaRestTestCase(test.TestCase): ) # - # Extensions - # - @test.create_mocks({api.nova: ['list_extensions']}) - def test_extension_list(self): - request = self.mock_rest_request() - self.mock_list_extensions.return_value = ['foo', 'bar'] - response = nova.Extensions().get(request) - self.assertStatusCode(response, 200) - self.assertEqual({"items": [{"name": "foo"}, {"name": "bar"}]}, - response.json) - self.mock_list_extensions.assert_called_once_with(request) - - # # Flavors # @@ -892,8 +879,7 @@ class NovaRestTestCase(test.TestCase): # @test.create_mocks({api.base: ['is_service_enabled'], - api.nova: ['service_list', - 'extension_supported']}) + api.nova: ['service_list']}) def test_services_get(self): request = self.mock_rest_request(GET={}) self.mock_service_list.return_value = [ @@ -901,7 +887,6 @@ class NovaRestTestCase(test.TestCase): mock.Mock(**{'to_dict.return_value': {'id': '2'}}) ] self.mock_is_service_enabled.return_value = True - self.mock_extension_supported.return_value = True response = nova.Services().get(request) @@ -911,8 +896,6 @@ class NovaRestTestCase(test.TestCase): self.mock_service_list.assert_called_once_with(request) self.mock_is_service_enabled.assert_called_once_with(request, 'compute') - self.mock_extension_supported.assert_called_once_with( - 'Services', request) @mock.patch.object(api.base, 'is_service_enabled') def test_services_get_disabled(self, mock_is_service_enabled): diff --git a/openstack_dashboard/test/unit/api/test_nova.py b/openstack_dashboard/test/unit/api/test_nova.py index f20f2f6ff..cce6fb02d 100644 --- a/openstack_dashboard/test/unit/api/test_nova.py +++ b/openstack_dashboard/test/unit/api/test_nova.py @@ -70,15 +70,6 @@ class ComputeApiTests(test.APIMockTestCase): # To handle upgrade_api mock_novaclient.api_version = api_versions.APIVersion(version) - @override_settings(OPENSTACK_NOVA_EXTENSIONS_BLACKLIST=['ConsoleOutput']) - def test_extension_supported(self): - self.assertTrue(api.nova.extension_supported( - 'Evacuate', mock.sentinel.request)) - self.assertFalse(api.nova.extension_supported( - 'ConsoleOutput', mock.sentinel.request)) - self.assertFalse(api.nova.extension_supported( - 'DoesNotExist', mock.sentinel.request)) - @mock.patch.object(api._nova, 'novaclient') def test_server_reboot(self, mock_novaclient): server = self.servers.first() |