Add OPENSTACK_NOVA_EXTENSIONS_BLACKLIST option to settings

This lets us disable any Nova extension we like, not just the
simple tenant usage.

Closes-bug: #1474241
Change-Id: I21840054225cd59cc62fd4f070172a2847173b14
(cherry picked from commit 18f4b752b8)
This commit is contained in:
Radomir Dopieralski 2015-07-15 09:34:59 +02:00 committed by Lin Hua Cheng
parent f7f8d7d1a3
commit 0f9d94e30f
3 changed files with 24 additions and 1 deletions

View File

@ -1030,6 +1030,18 @@ provided see: ``"/horizon/openstack_dashboard/static/themes/webroot"``
Alias /dashboard/media %HORIZON_DIR%/openstack_dashboard/static
``OPENSTACK_NOVA_EXTENSIONS_BLACKLIST``
---------------------------------------
.. versionadded:: 8.0.0(Liberty)
Default: ``[]``
Ignore all listed Nova extensions, and behave as if they were unsupported.
Can be used to selectively disable certain costly extensions for performance
reasons.
Django Settings (Partial)
=========================

View File

@ -919,7 +919,15 @@ def remove_host_from_aggregate(request, aggregate_id, host):
@memoized
def list_extensions(request):
return nova_list_extensions.ListExtManager(novaclient(request)).show_all()
"""List all nova extensions, except the ones in the blacklist."""
blacklist = set(getattr(settings,
'OPENSTACK_NOVA_EXTENSIONS_BLACKLIST', []))
return [
extension for extension in
nova_list_extensions.ListExtManager(novaclient(request)).show_all()
if extension.name not in blacklist
]
@memoized

View File

@ -156,11 +156,14 @@ class NovaRestTestCase(test.TestCase):
# Extensions
#
@mock.patch.object(nova.api, 'nova')
@mock.patch.object(settings,
'OPENSTACK_NOVA_EXTENSIONS_BLACKLIST', ['baz'])
def _test_extension_list(self, nc):
request = self.mock_rest_request()
nc.list_extensions.return_value = [
mock.Mock(**{'to_dict.return_value': {'name': 'foo'}}),
mock.Mock(**{'to_dict.return_value': {'name': 'bar'}}),
mock.Mock(**{'to_dict.return_value': {'name': 'baz'}}),
]
response = nova.Extensions().get(request)
self.assertStatusCode(response, 200)