Update rules mode for latest shade

Shade 0.7.0 normalized the security group data that is returned,
when using nova, to look more like neutron security group data.
This adjusts for that change.
This commit is contained in:
David Shrewsbury 2015-06-10 17:31:43 -04:00 committed by Monty Taylor
parent b98e6663e8
commit 8f2e70a1c1

View file

@ -86,13 +86,11 @@ def _security_group_rule(module, nova_client, action='create', **kwargs):
def _get_rule_from_group(module, secgroup):
for rule in secgroup.rules:
if (rule['ip_protocol'] == module.params['protocol'] and
rule['from_port'] == module.params['port_range_min'] and
rule['to_port'] == module.params['port_range_max'] and
(rule['ip_range']['cidr'] if 'cidr' in rule['ip_range']
else None) == (module.params['remote_ip_prefix'] if
'remote_ip_prefix' in module.params else None)):
for rule in secgroup['security_group_rules']:
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
rule['remote_ip_prefix'] == module.params['remote_ip_prefix']):
return rule
return None
@ -136,9 +134,8 @@ def main():
cidr=module.params['remote_ip_prefix']
if 'remote_ip_prefix' in module.params else None,
group_id=module.params['remote_group']
if 'remote_group' in module.params else
None
)
if 'remote_group' in module.params else None
)
changed = True
if module.params['state'] == 'absent' and secgroup: