Always display direction for security group rules
The --long option is still accepted but is now ignored. Change-Id: I23dd9fa7cff310ee9a62ce32b843b822b93b7548 Story: #2007323
This commit is contained in:
parent
e07324e30f
commit
e410e61d20
@ -480,7 +480,7 @@ class ListSecurityGroupRule(common.NetworkAndComputeLister):
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
default=False,
|
default=False,
|
||||||
help=self.enhance_help_neutron(
|
help=self.enhance_help_neutron(
|
||||||
_("List additional fields in output"))
|
_("**Deprecated** This argument is no longer needed"))
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
@ -510,15 +510,19 @@ class ListSecurityGroupRule(common.NetworkAndComputeLister):
|
|||||||
'Ethertype',
|
'Ethertype',
|
||||||
'IP Range',
|
'IP Range',
|
||||||
'Port Range',
|
'Port Range',
|
||||||
|
'Direction',
|
||||||
|
'Remote Security Group',
|
||||||
)
|
)
|
||||||
if parsed_args.long:
|
|
||||||
column_headers = column_headers + ('Direction',)
|
|
||||||
column_headers = column_headers + ('Remote Security Group',)
|
|
||||||
if parsed_args.group is None:
|
if parsed_args.group is None:
|
||||||
column_headers = column_headers + ('Security Group',)
|
column_headers = column_headers + ('Security Group',)
|
||||||
return column_headers
|
return column_headers
|
||||||
|
|
||||||
def take_action_network(self, client, parsed_args):
|
def take_action_network(self, client, parsed_args):
|
||||||
|
if parsed_args.long:
|
||||||
|
self.log.warning(_(
|
||||||
|
"The --long option has been deprecated and is no longer needed"
|
||||||
|
))
|
||||||
|
|
||||||
column_headers = self._get_column_headers(parsed_args)
|
column_headers = self._get_column_headers(parsed_args)
|
||||||
columns = (
|
columns = (
|
||||||
'id',
|
'id',
|
||||||
@ -526,10 +530,9 @@ class ListSecurityGroupRule(common.NetworkAndComputeLister):
|
|||||||
'ether_type',
|
'ether_type',
|
||||||
'remote_ip_prefix',
|
'remote_ip_prefix',
|
||||||
'port_range',
|
'port_range',
|
||||||
|
'direction',
|
||||||
|
'remote_group_id',
|
||||||
)
|
)
|
||||||
if parsed_args.long:
|
|
||||||
columns = columns + ('direction',)
|
|
||||||
columns = columns + ('remote_group_id',)
|
|
||||||
|
|
||||||
# Get the security group rules using the requested query.
|
# Get the security group rules using the requested query.
|
||||||
query = {}
|
query = {}
|
||||||
|
@ -362,6 +362,7 @@ class TestListSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
|
|||||||
'Ethertype',
|
'Ethertype',
|
||||||
'IP Range',
|
'IP Range',
|
||||||
'Port Range',
|
'Port Range',
|
||||||
|
'Direction',
|
||||||
'Remote Security Group',
|
'Remote Security Group',
|
||||||
)
|
)
|
||||||
expected_columns_no_group = \
|
expected_columns_no_group = \
|
||||||
|
@ -870,7 +870,7 @@ class TestListSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
_security_group_rules = [_security_group_rule_tcp,
|
_security_group_rules = [_security_group_rule_tcp,
|
||||||
_security_group_rule_icmp]
|
_security_group_rule_icmp]
|
||||||
|
|
||||||
expected_columns_with_group_and_long = (
|
expected_columns_with_group = (
|
||||||
'ID',
|
'ID',
|
||||||
'IP Protocol',
|
'IP Protocol',
|
||||||
'Ethertype',
|
'Ethertype',
|
||||||
@ -885,14 +885,15 @@ class TestListSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
'Ethertype',
|
'Ethertype',
|
||||||
'IP Range',
|
'IP Range',
|
||||||
'Port Range',
|
'Port Range',
|
||||||
|
'Direction',
|
||||||
'Remote Security Group',
|
'Remote Security Group',
|
||||||
'Security Group',
|
'Security Group',
|
||||||
)
|
)
|
||||||
|
|
||||||
expected_data_with_group_and_long = []
|
expected_data_with_group = []
|
||||||
expected_data_no_group = []
|
expected_data_no_group = []
|
||||||
for _security_group_rule in _security_group_rules:
|
for _security_group_rule in _security_group_rules:
|
||||||
expected_data_with_group_and_long.append((
|
expected_data_with_group.append((
|
||||||
_security_group_rule.id,
|
_security_group_rule.id,
|
||||||
_security_group_rule.protocol,
|
_security_group_rule.protocol,
|
||||||
_security_group_rule.ether_type,
|
_security_group_rule.ether_type,
|
||||||
@ -909,6 +910,7 @@ class TestListSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
_security_group_rule.remote_ip_prefix,
|
_security_group_rule.remote_ip_prefix,
|
||||||
security_group_rule._format_network_port_range(
|
security_group_rule._format_network_port_range(
|
||||||
_security_group_rule),
|
_security_group_rule),
|
||||||
|
_security_group_rule.direction,
|
||||||
_security_group_rule.remote_group_id,
|
_security_group_rule.remote_group_id,
|
||||||
_security_group_rule.security_group_id,
|
_security_group_rule.security_group_id,
|
||||||
))
|
))
|
||||||
@ -935,14 +937,12 @@ class TestListSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
self.assertEqual(self.expected_columns_no_group, columns)
|
self.assertEqual(self.expected_columns_no_group, columns)
|
||||||
self.assertEqual(self.expected_data_no_group, list(data))
|
self.assertEqual(self.expected_data_no_group, list(data))
|
||||||
|
|
||||||
def test_list_with_group_and_long(self):
|
def test_list_with_group(self):
|
||||||
self._security_group_rule_tcp.port_range_min = 80
|
self._security_group_rule_tcp.port_range_min = 80
|
||||||
arglist = [
|
arglist = [
|
||||||
'--long',
|
|
||||||
self._security_group.id,
|
self._security_group.id,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('long', True),
|
|
||||||
('group', self._security_group.id),
|
('group', self._security_group.id),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@ -952,8 +952,8 @@ class TestListSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
self.network.security_group_rules.assert_called_once_with(**{
|
self.network.security_group_rules.assert_called_once_with(**{
|
||||||
'security_group_id': self._security_group.id,
|
'security_group_id': self._security_group.id,
|
||||||
})
|
})
|
||||||
self.assertEqual(self.expected_columns_with_group_and_long, columns)
|
self.assertEqual(self.expected_columns_with_group, columns)
|
||||||
self.assertEqual(self.expected_data_with_group_and_long, list(data))
|
self.assertEqual(self.expected_data_with_group, list(data))
|
||||||
|
|
||||||
def test_list_with_ignored_options(self):
|
def test_list_with_ignored_options(self):
|
||||||
self._security_group_rule_tcp.port_range_min = 80
|
self._security_group_rule_tcp.port_range_min = 80
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
By default listing security group rules now shows the direction.
|
||||||
|
The ``--long`` argument is now redundant and is now ignored as it
|
||||||
|
was only used to display the direction.
|
||||||
|
deprecations:
|
||||||
|
- |
|
||||||
|
Deprecate the ``--long`` option for the ``security group list``
|
||||||
|
command. This is no longer needed to display all columns.
|
Loading…
Reference in New Issue
Block a user