diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2015-07-23 15:08:52 -0500 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2015-09-03 13:06:45 -0500 |
| commit | e6706f252642e52dd9de556b92edb769afa57868 (patch) | |
| tree | 9c30cf185316422cffc6143228fc75302f1bba27 /openstackclient/compute | |
| parent | 9210cac86a2d5d3df9989f40b1fcc605e5f78ed8 (diff) | |
| download | python-openstackclient-e6706f252642e52dd9de556b92edb769afa57868.tar.gz | |
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
Diffstat (limited to 'openstackclient/compute')
| -rw-r--r-- | openstackclient/compute/v2/security_group.py | 11 |
1 files changed, 7 insertions, 4 deletions
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, |
