|
|
|
@ -212,6 +212,20 @@ def main():
|
|
|
|
|
module.exit_json(changed=_system_state_change(module, flavor))
|
|
|
|
|
|
|
|
|
|
if state == 'present':
|
|
|
|
|
old_extra_specs = {}
|
|
|
|
|
require_update = False
|
|
|
|
|
|
|
|
|
|
if flavor:
|
|
|
|
|
old_extra_specs = flavor['extra_specs']
|
|
|
|
|
for param_key in ['ram', 'vcpus', 'disk', 'ephemeral', 'swap', 'rxtx_factor', 'is_public']:
|
|
|
|
|
if module.params[param_key] != flavor[param_key]:
|
|
|
|
|
require_update = True
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if flavor and require_update:
|
|
|
|
|
cloud.delete_flavor(name)
|
|
|
|
|
flavor = None
|
|
|
|
|
|
|
|
|
|
if not flavor:
|
|
|
|
|
flavor = cloud.create_flavor(
|
|
|
|
|
name=name,
|
|
|
|
@ -228,11 +242,10 @@ def main():
|
|
|
|
|
else:
|
|
|
|
|
changed = False
|
|
|
|
|
|
|
|
|
|
old_extra_specs = flavor['extra_specs']
|
|
|
|
|
new_extra_specs = dict([(k, str(v)) for k, v in extra_specs.items()])
|
|
|
|
|
unset_keys = set(flavor['extra_specs'].keys()) - set(extra_specs.keys())
|
|
|
|
|
unset_keys = set(old_extra_specs.keys()) - set(extra_specs.keys())
|
|
|
|
|
|
|
|
|
|
if unset_keys:
|
|
|
|
|
if unset_keys and not require_update:
|
|
|
|
|
cloud.unset_flavor_specs(flavor['id'], unset_keys)
|
|
|
|
|
|
|
|
|
|
if old_extra_specs != new_extra_specs:
|
|
|
|
|