summaryrefslogtreecommitdiff
path: root/openstackclient/network
diff options
context:
space:
mode:
authorNam Nguyen Hoai <namnh@vn.fujitsu.com>2016-08-17 13:40:52 +0700
committerHa Van Tu <tuhv@vn.fujitsu.com>2016-10-14 02:59:07 +0000
commit291b66e983dd4652839be0dd765616b65fd4c54b (patch)
tree01a6425e9b1d8fb48baf1eebf7e84406a812f98d /openstackclient/network
parent43d1646058a5faa917f2e7ed073c710180da8bd3 (diff)
downloadpython-openstackclient-291b66e983dd4652839be0dd765616b65fd4c54b.tar.gz
Add direction and protocol options to os security group rule list cmd
This patch added direction options (--ingress, --egress) and protocol option (--protocol) to filter rules by os security group rule list command. Change-Id: I56ace3f97eb927fd2a868f728c7347a29d028b67 Closes-Bug: #1613533 Partially-Implements: blueprint network-commands-options
Diffstat (limited to 'openstackclient/network')
-rw-r--r--openstackclient/network/v2/security_group_rule.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/openstackclient/network/v2/security_group_rule.py b/openstackclient/network/v2/security_group_rule.py
index e3be44ec..3b9055df 100644
--- a/openstackclient/network/v2/security_group_rule.py
+++ b/openstackclient/network/v2/security_group_rule.py
@@ -380,6 +380,28 @@ class ListSecurityGroupRule(common.NetworkAndComputeLister):
help=argparse.SUPPRESS
)
parser.add_argument(
+ '--protocol',
+ metavar='<protocol>',
+ type=_convert_to_lowercase,
+ help=_("List rules by the IP protocol ("
+ "ah, dhcp, egp, esp, gre, icmp, igmp, "
+ "ipv6-encap, ipv6-frag, ipv6-icmp, ipv6-nonxt, "
+ "ipv6-opts, ipv6-route, ospf, pgm, rsvp, sctp, tcp, "
+ "udp, udplite, vrrp and integer representations [0-255])."
+ )
+ )
+ direction_group = parser.add_mutually_exclusive_group()
+ direction_group.add_argument(
+ '--ingress',
+ action='store_true',
+ help=_("List rules applied to incoming network traffic")
+ )
+ direction_group.add_argument(
+ '--egress',
+ action='store_true',
+ help=_("List rules applied to outgoing network traffic")
+ )
+ parser.add_argument(
'--long',
action='store_true',
default=False,
@@ -443,6 +465,14 @@ class ListSecurityGroupRule(common.NetworkAndComputeLister):
query = {'security_group_id': security_group_id}
else:
columns = columns + ('security_group_id',)
+
+ if parsed_args.ingress:
+ query['direction'] = 'ingress'
+ if parsed_args.egress:
+ query['direction'] = 'egress'
+ if parsed_args.protocol is not None:
+ query['protocol'] = parsed_args.protocol
+
rules = list(client.security_group_rules(**query))
# Reformat the rules to display a port range instead