Skip to content

Commit 18f4b75

Browse files
committed
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
1 parent 750df24 commit 18f4b75

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

doc/source/topics/settings.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,18 @@ http://tinyurl.com/anticlickjack
10761076
``False`` to exclude the frame-busting code and allow iframe embedding.
10771077

10781078

1079+
``OPENSTACK_NOVA_EXTENSIONS_BLACKLIST``
1080+
---------------------------------------
1081+
1082+
.. versionadded:: 8.0.0(Liberty)
1083+
1084+
Default: ``[]``
1085+
1086+
Ignore all listed Nova extensions, and behave as if they were unsupported.
1087+
Can be used to selectively disable certain costly extensions for performance
1088+
reasons.
1089+
1090+
10791091
Django Settings (Partial)
10801092
=========================
10811093

openstack_dashboard/api/nova.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,15 @@ def interface_detach(request, server, port_id):
935935

936936
@memoized
937937
def list_extensions(request):
938-
return nova_list_extensions.ListExtManager(novaclient(request)).show_all()
938+
"""List all nova extensions, except the ones in the blacklist."""
939+
940+
blacklist = set(getattr(settings,
941+
'OPENSTACK_NOVA_EXTENSIONS_BLACKLIST', []))
942+
return [
943+
extension for extension in
944+
nova_list_extensions.ListExtManager(novaclient(request)).show_all()
945+
if extension.name not in blacklist
946+
]
939947

940948

941949
@memoized

openstack_dashboard/test/api_tests/nova_rest_tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,14 @@ def test_server_get_single(self, nc):
156156
# Extensions
157157
#
158158
@mock.patch.object(nova.api, 'nova')
159+
@mock.patch.object(settings,
160+
'OPENSTACK_NOVA_EXTENSIONS_BLACKLIST', ['baz'])
159161
def _test_extension_list(self, nc):
160162
request = self.mock_rest_request()
161163
nc.list_extensions.return_value = [
162164
mock.Mock(**{'to_dict.return_value': {'name': 'foo'}}),
163165
mock.Mock(**{'to_dict.return_value': {'name': 'bar'}}),
166+
mock.Mock(**{'to_dict.return_value': {'name': 'baz'}}),
164167
]
165168
response = nova.Extensions().get(request)
166169
self.assertStatusCode(response, 200)

0 commit comments

Comments
 (0)