Skip to content

Commit e410e61

Browse files
committed
Always display direction for security group rules
The --long option is still accepted but is now ignored. Change-Id: I23dd9fa7cff310ee9a62ce32b843b822b93b7548 Story: #2007323
1 parent e07324e commit e410e61

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
@@ -480,7 +480,7 @@ def update_parser_network(self, parser):
480480
action='store_true',
481481
default=False,
482482
help=self.enhance_help_neutron(
483-
_("List additional fields in output"))
483+
_("**Deprecated** This argument is no longer needed"))
484484
)
485485
return parser
486486

@@ -510,26 +510,29 @@ def _get_column_headers(self, parsed_args):
510510
'Ethertype',
511511
'IP Range',
512512
'Port Range',
513+
'Direction',
514+
'Remote Security Group',
513515
)
514-
if parsed_args.long:
515-
column_headers = column_headers + ('Direction',)
516-
column_headers = column_headers + ('Remote Security Group',)
517516
if parsed_args.group is None:
518517
column_headers = column_headers + ('Security Group',)
519518
return column_headers
520519

521520
def take_action_network(self, client, parsed_args):
521+
if parsed_args.long:
522+
self.log.warning(_(
523+
"The --long option has been deprecated and is no longer needed"
524+
))
525+
522526
column_headers = self._get_column_headers(parsed_args)
523527
columns = (
524528
'id',
525529
'protocol',
526530
'ether_type',
527531
'remote_ip_prefix',
528532
'port_range',
533+
'direction',
534+
'remote_group_id',
529535
)
530-
if parsed_args.long:
531-
columns = columns + ('direction',)
532-
columns = columns + ('remote_group_id',)
533536

534537
# Get the security group rules using the requested query.
535538
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)