Skip to content

Commit 2eeab20

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Always display direction for security group rules"
2 parents 73765da + e410e61 commit 2eeab20

4 files changed

Lines changed: 29 additions & 15 deletions

File tree

openstackclient/network/v2/security_group_rule.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def update_parser_network(self, parser):
474474
action='store_true',
475475
default=False,
476476
help=self.enhance_help_neutron(
477-
_("List additional fields in output"))
477+
_("**Deprecated** This argument is no longer needed"))
478478
)
479479
return parser
480480

@@ -504,26 +504,29 @@ def _get_column_headers(self, parsed_args):
504504
'Ethertype',
505505
'IP Range',
506506
'Port Range',
507+
'Direction',
508+
'Remote Security Group',
507509
)
508-
if parsed_args.long:
509-
column_headers = column_headers + ('Direction',)
510-
column_headers = column_headers + ('Remote Security Group',)
511510
if parsed_args.group is None:
512511
column_headers = column_headers + ('Security Group',)
513512
return column_headers
514513

515514
def take_action_network(self, client, parsed_args):
515+
if parsed_args.long:
516+
self.log.warning(_(
517+
"The --long option has been deprecated and is no longer needed"
518+
))
519+
516520
column_headers = self._get_column_headers(parsed_args)
517521
columns = (
518522
'id',
519523
'protocol',
520524
'ether_type',
521525
'remote_ip_prefix',
522526
'port_range',
527+
'direction',
528+
'remote_group_id',
523529
)
524-
if parsed_args.long:
525-
columns = columns + ('direction',)
526-
columns = columns + ('remote_group_id',)
527530

528531
# Get the security group rules using the requested query.
529532
query = {}

openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ class TestListSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
362362
'Ethertype',
363363
'IP Range',
364364
'Port Range',
365+
'Direction',
365366
'Remote Security Group',
366367
)
367368
expected_columns_no_group = \

openstackclient/tests/unit/network/v2/test_security_group_rule_network.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ class TestListSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
870870
_security_group_rules = [_security_group_rule_tcp,
871871
_security_group_rule_icmp]
872872

873-
expected_columns_with_group_and_long = (
873+
expected_columns_with_group = (
874874
'ID',
875875
'IP Protocol',
876876
'Ethertype',
@@ -885,14 +885,15 @@ class TestListSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
885885
'Ethertype',
886886
'IP Range',
887887
'Port Range',
888+
'Direction',
888889
'Remote Security Group',
889890
'Security Group',
890891
)
891892

892-
expected_data_with_group_and_long = []
893+
expected_data_with_group = []
893894
expected_data_no_group = []
894895
for _security_group_rule in _security_group_rules:
895-
expected_data_with_group_and_long.append((
896+
expected_data_with_group.append((
896897
_security_group_rule.id,
897898
_security_group_rule.protocol,
898899
_security_group_rule.ether_type,
@@ -909,6 +910,7 @@ class TestListSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
909910
_security_group_rule.remote_ip_prefix,
910911
security_group_rule._format_network_port_range(
911912
_security_group_rule),
913+
_security_group_rule.direction,
912914
_security_group_rule.remote_group_id,
913915
_security_group_rule.security_group_id,
914916
))
@@ -935,14 +937,12 @@ def test_list_default(self):
935937
self.assertEqual(self.expected_columns_no_group, columns)
936938
self.assertEqual(self.expected_data_no_group, list(data))
937939

938-
def test_list_with_group_and_long(self):
940+
def test_list_with_group(self):
939941
self._security_group_rule_tcp.port_range_min = 80
940942
arglist = [
941-
'--long',
942943
self._security_group.id,
943944
]
944945
verifylist = [
945-
('long', True),
946946
('group', self._security_group.id),
947947
]
948948
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -952,8 +952,8 @@ def test_list_with_group_and_long(self):
952952
self.network.security_group_rules.assert_called_once_with(**{
953953
'security_group_id': self._security_group.id,
954954
})
955-
self.assertEqual(self.expected_columns_with_group_and_long, columns)
956-
self.assertEqual(self.expected_data_with_group_and_long, list(data))
955+
self.assertEqual(self.expected_columns_with_group, columns)
956+
self.assertEqual(self.expected_data_with_group, list(data))
957957

958958
def test_list_with_ignored_options(self):
959959
self._security_group_rule_tcp.port_range_min = 80
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
features:
3+
- |
4+
By default listing security group rules now shows the direction.
5+
The ``--long`` argument is now redundant and is now ignored as it
6+
was only used to display the direction.
7+
deprecations:
8+
- |
9+
Deprecate the ``--long`` option for the ``security group list``
10+
command. This is no longer needed to display all columns.

0 commit comments

Comments
 (0)