From e6706f252642e52dd9de556b92edb769afa57868 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Thu, 23 Jul 2015 15:08:52 -0500 Subject: Properly handle port arguments for ICMP The Compute API requires 'from_port' and 'to_port' to be -1 for ICMP security group rules. It happily accepts them empty or None but the resulting rules do not work. So we force the values for ICMP rules. Closes-bug: #1477629 Change-Id: Iba57211014caca16be7c9a28d15d4db2a6c51b8d --- openstackclient/compute/v2/security_group.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'openstackclient/compute') diff --git a/openstackclient/compute/v2/security_group.py b/openstackclient/compute/v2/security_group.py index 3dc9bae0..25c2ed3f 100644 --- a/openstackclient/compute/v2/security_group.py +++ b/openstackclient/compute/v2/security_group.py @@ -50,10 +50,10 @@ def _xform_security_group_rule(sgroup): info['ip_range'] = info['ip_range']['cidr'] else: info['ip_range'] = '' - if info['ip_protocol'] == 'icmp': - info['port_range'] = '' - elif info['ip_protocol'] is None: + if info['ip_protocol'] is None: info['ip_protocol'] = '' + elif info['ip_protocol'].lower() == 'icmp': + info['port_range'] = '' return info @@ -307,7 +307,10 @@ class CreateSecurityGroupRule(show.ShowOne): compute_client.security_groups, parsed_args.group, ) - from_port, to_port = parsed_args.dst_port + if parsed_args.proto.lower() == 'icmp': + from_port, to_port = -1, -1 + else: + from_port, to_port = parsed_args.dst_port data = compute_client.security_group_rules.create( group.id, parsed_args.proto, -- cgit v1.2.1