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.
This commit is contained in:
David Shrewsbury 2015-06-10 18:06:11 -04:00 committed by Matt Clay
parent b42a9d56e6
commit fcc1d643f6

View file

@ -89,9 +89,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