From 711b9c9405c55ca8bb5649e2b56202845356e049 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Mon, 2 Mar 2020 16:40:15 +0000 Subject: Add "fields" parameter to ListSecurityGroup query This new query parameter will allow to send a query sending the "fields" parameter. This "fields" parameter contains the needed API fields, translated into OVO fields in Neutron server, that require to be retrieved from the DB. As commented in the related bug, the OSC "list" command only prints five parameters, none of them the security group rules. In systems with a reasonable amount of security groups, skipping the unnecessary rule load can save a lot of time. Depends-On: https://review.opendev.org/#/c/710820/ Change-Id: I16f48e292997d029d68f66365db949b9f4b5a0c8 Closes-Bug: #1865223 --- .../unit/network/v2/test_security_group_network.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'openstackclient/tests') diff --git a/openstackclient/tests/unit/network/v2/test_security_group_network.py b/openstackclient/tests/unit/network/v2/test_security_group_network.py index 14d57514..67908fa8 100644 --- a/openstackclient/tests/unit/network/v2/test_security_group_network.py +++ b/openstackclient/tests/unit/network/v2/test_security_group_network.py @@ -285,7 +285,8 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork): columns, data = self.cmd.take_action(parsed_args) - self.network.security_groups.assert_called_once_with() + self.network.security_groups.assert_called_once_with( + fields=security_group.ListSecurityGroup.FIELDS_TO_RETRIEVE) self.assertEqual(self.columns, columns) self.assertListItemEqual(self.data, list(data)) @@ -300,7 +301,8 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork): columns, data = self.cmd.take_action(parsed_args) - self.network.security_groups.assert_called_once_with() + self.network.security_groups.assert_called_once_with( + fields=security_group.ListSecurityGroup.FIELDS_TO_RETRIEVE) self.assertEqual(self.columns, columns) self.assertListItemEqual(self.data, list(data)) @@ -316,7 +318,9 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork): parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) - filters = {'tenant_id': project.id, 'project_id': project.id} + filters = { + 'tenant_id': project.id, 'project_id': project.id, + 'fields': security_group.ListSecurityGroup.FIELDS_TO_RETRIEVE} self.network.security_groups.assert_called_once_with(**filters) self.assertEqual(self.columns, columns) @@ -336,7 +340,9 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork): parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) - filters = {'tenant_id': project.id, 'project_id': project.id} + filters = { + 'tenant_id': project.id, 'project_id': project.id, + 'fields': security_group.ListSecurityGroup.FIELDS_TO_RETRIEVE} self.network.security_groups.assert_called_once_with(**filters) self.assertEqual(self.columns, columns) @@ -362,7 +368,8 @@ class TestListSecurityGroupNetwork(TestSecurityGroupNetwork): **{'tags': 'red,blue', 'any_tags': 'red,green', 'not_tags': 'orange,yellow', - 'not_any_tags': 'black,white'} + 'not_any_tags': 'black,white', + 'fields': security_group.ListSecurityGroup.FIELDS_TO_RETRIEVE} ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) -- cgit v1.2.1