summaryrefslogtreecommitdiff
path: root/openstackclient/network
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-11-10 18:08:53 +0000
committerGerrit Code Review <review@openstack.org>2016-11-10 18:08:53 +0000
commitc89d441008aa59d0d2809970e49ea56bc1989e46 (patch)
tree7244fc699cf681033b76ffb07ae15fb6a1d6a38e /openstackclient/network
parent55ddaf7bbe6c4a27c24cd25f6e186047b62e34a9 (diff)
parent291b66e983dd4652839be0dd765616b65fd4c54b (diff)
downloadpython-openstackclient-c89d441008aa59d0d2809970e49ea56bc1989e46.tar.gz
Merge "Add direction and protocol options to os security group rule list cmd"
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 0f3bad3d..928abfd1 100644
--- a/openstackclient/network/v2/security_group_rule.py
+++ b/openstackclient/network/v2/security_group_rule.py
@@ -388,6 +388,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,
@@ -451,6 +473,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