From 300503e45911446a0ee77c6450d378070c18026d Mon Sep 17 00:00:00 2001 From: Gerry Buteau Date: Mon, 26 Jun 2017 16:42:18 -0400 Subject: [PATCH] Fix security group choice field population The network abstraction layer has been removed from horizon/openstack_dashboard API. See: https://review.openstack.org/#/c/466645/ https://review.openstack.org/#/q/topic:bp/drop-nova-network Use neutron API to populate the list of existing security groups instead. Closes-Bug: 1697688 Change-Id: I57b92974db3f510f69e7e552d53cefa28a53d9ad --- muranodashboard/dynamic_ui/fields.py | 4 ++-- muranodashboard/tests/unit/dynamic_ui/test_fields.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/muranodashboard/dynamic_ui/fields.py b/muranodashboard/dynamic_ui/fields.py index bd6d1a44a..2e6fc6dd1 100644 --- a/muranodashboard/dynamic_ui/fields.py +++ b/muranodashboard/dynamic_ui/fields.py @@ -30,7 +30,7 @@ from horizon import forms as hz_forms from horizon import messages from openstack_dashboard.api import cinder from openstack_dashboard.api import glance -from openstack_dashboard.api import network +from openstack_dashboard.api import neutron from openstack_dashboard.api import nova from oslo_log import log as logging from oslo_log import versionutils @@ -428,7 +428,7 @@ class SecurityGroupChoiceField(DynamicChoiceField): # TODO(pbourke): remove sorted when supported natively in Horizon # (https://bugs.launchpad.net/horizon/+bug/1692972) for secgroup in sorted( - network.security_group_list(request), + neutron.security_group_list(request), key=lambda e: e.name_or_id): if not secgroup.name_or_id.startswith('murano--'): self.choices.append((secgroup.name_or_id, secgroup.name_or_id)) diff --git a/muranodashboard/tests/unit/dynamic_ui/test_fields.py b/muranodashboard/tests/unit/dynamic_ui/test_fields.py index 6cc3bf186..ed4db45eb 100644 --- a/muranodashboard/tests/unit/dynamic_ui/test_fields.py +++ b/muranodashboard/tests/unit/dynamic_ui/test_fields.py @@ -583,9 +583,9 @@ class TestSecurityGroupChoiceField(testtools.TestCase): self.request = {'request': mock.Mock()} self.addCleanup(mock.patch.stopall) - @mock.patch.object(fields, 'network') - def test_update(self, mock_network): - mock_network.security_group_list.return_value = [ + @mock.patch.object(fields, 'neutron') + def test_update(self, mock_neutron): + mock_neutron.security_group_list.return_value = [ mock.Mock(name_or_id='foo'), mock.Mock(name_or_id='bar') ]