cloudscale_volume: fail fast on volume type change (#52231)

* cloudscale_volume: fail fast on volume type change

Currently a volume gets resized before the type change check. With this
change, we check early and ensure we fail before any changes made.

* fix too many blank lines
pull/52511/head
René Moser 6 years ago committed by John R Barker
parent fcb6f136cd
commit a1ec74334a

@ -261,18 +261,18 @@ def main():
volume.delete()
if module.params['state'] == 'present':
for param, conv in (('server_uuids', set), ('size_gb', int)):
if module.params[param] is None:
continue
if conv(volume.info[param]) != conv(module.params[param]):
volume.update(param)
if (module.params['type'] is not None
and volume.info['type'] != module.params['type']):
module.fail_json(
msg='Cannot change type of an existing volume.',
)
for param, conv in (('server_uuids', set), ('size_gb', int)):
if module.params[param] is None:
continue
if conv(volume.info[param]) != conv(module.params[param]):
volume.update(param)
module.exit_json(changed=volume.changed, **volume.info)

Loading…
Cancel
Save