Recongnize None and -1 port equivalency

shade 0.7.0 represents disabled min/max ports as None (in the
neutron style) rather than -1. Recognize this as the same as -1.
reviewable/pr18780/r1
David Shrewsbury 9 years ago committed by Monty Taylor
parent 5758b4ebdc
commit 5b6c6cac20

@ -87,9 +87,12 @@ def _security_group_rule(module, nova_client, action='create', **kwargs):
def _get_rule_from_group(module, secgroup):
for rule in secgroup['security_group_rules']:
# No port, or -1, will be returned as None
port_range_min = rule['port_range_min'] or -1
port_range_max = rule['port_range_max'] or -1
if (rule['protocol'] == module.params['protocol'] and
rule['port_range_min'] == module.params['port_range_min'] and
rule['port_range_max'] == module.params['port_range_max'] and
port_range_min == module.params['port_range_min'] and
port_range_max == module.params['port_range_max'] and
rule['remote_ip_prefix'] == module.params['remote_ip_prefix']):
return rule
return None

Loading…
Cancel
Save