Fix the idempotent of compute_flavor module

if flavor's swap is not set (or 0),nova returns empty string [0]
rather than 0 when query flavor spec. this behavior will break
the idempotent of the ansible deployment. this ps changes the empty
string to 0 before compare them.
[0]: https://docs.openstack.org/api-ref/compute/?expanded=list-flavors-detail,list-flavors-with-details-detail#list-flavors-with-details

Change-Id: I041cbcc0432051d795e2c3f0e7ac7378e1970008
This commit is contained in:
wuchunyang 2021-04-27 17:38:19 +08:00
parent 8da4e852f0
commit 77acba047b
1 changed files with 2 additions and 0 deletions

View File

@ -220,6 +220,8 @@ def main():
if flavor:
old_extra_specs = flavor['extra_specs']
if flavor['swap'] == "":
flavor['swap'] = 0
for param_key in ['ram', 'vcpus', 'disk', 'ephemeral', 'swap', 'rxtx_factor', 'is_public']:
if module.params[param_key] != flavor[param_key]:
require_update = True