Skip to content

Commit

Permalink
Add OPENSTACK_NOVA_EXTENSIONS_BLACKLIST option to settings
Browse files Browse the repository at this point in the history
This lets us disable any Nova extension we like, not just the
simple tenant usage.

Closes-bug: #1474241
Change-Id: I21840054225cd59cc62fd4f070172a2847173b14
  • Loading branch information
deshipu committed Jul 16, 2015
1 parent 750df24 commit 18f4b75
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
12 changes: 12 additions & 0 deletions doc/source/topics/settings.rst
Expand Up @@ -1076,6 +1076,18 @@ http://tinyurl.com/anticlickjack
``False`` to exclude the frame-busting code and allow iframe embedding.


``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)
=========================

Expand Down
10 changes: 9 additions & 1 deletion openstack_dashboard/api/nova.py
Expand Up @@ -935,7 +935,15 @@ def interface_detach(request, server, port_id):

@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
Expand Down
3 changes: 3 additions & 0 deletions openstack_dashboard/test/api_tests/nova_rest_tests.py
Expand Up @@ -156,11 +156,14 @@ def test_server_get_single(self, nc):
# 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)
Expand Down

0 comments on commit 18f4b75

Please sign in to comment.