From 6b911ebd218d93bceef35fb2fbb0b066d295ccc9 Mon Sep 17 00:00:00 2001 From: Samuel Kunkel Date: Tue, 15 Nov 2022 16:38:51 +0100 Subject: [PATCH] Allow setting flavor description This will, like all other options changes, recreate the flavor. This matches the workflow allowed by the openstacksdk (if description is not set, it defaults to None). Change-Id: I3d46a3f527f0632f42f6796c0a2701addebde640 --- plugins/modules/compute_flavor.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/modules/compute_flavor.py b/plugins/modules/compute_flavor.py index 22560c02..94bcd31e 100644 --- a/plugins/modules/compute_flavor.py +++ b/plugins/modules/compute_flavor.py @@ -13,6 +13,10 @@ description: - Add or remove compute flavors from OpenStack. - Updating a flavor consists of deleting and (re)creating a flavor. options: + description: + description: + - Description of the flavor. + type: str disk: description: - Size of local disk, in GB. @@ -90,6 +94,7 @@ EXAMPLES = ''' vcpus: 1 disk: 10 ephemeral: 10 + description: "I am flavor mycloud" - name: Delete tiny flavor openstack.cloud.compute_flavor: @@ -190,6 +195,7 @@ from ansible_collections.openstack.cloud.plugins.module_utils.openstack import O class ComputeFlavorModule(OpenStackModule): argument_spec = dict( + description=dict(), disk=dict(type='int'), ephemeral=dict(type='int'), extra_specs=dict(type='dict'), @@ -278,7 +284,7 @@ class ComputeFlavorModule(OpenStackModule): flavor_attributes = dict( (k, self.params[k]) for k in ['ram', 'vcpus', 'disk', 'ephemeral', 'swap', - 'rxtx_factor', 'is_public'] + 'rxtx_factor', 'is_public', 'description'] if k in self.params and self.params[k] is not None and self.params[k] != flavor[k]) @@ -290,7 +296,8 @@ class ComputeFlavorModule(OpenStackModule): def _create(self): kwargs = dict((k, self.params[k]) for k in ['name', 'ram', 'vcpus', 'disk', 'ephemeral', - 'swap', 'rxtx_factor', 'is_public'] + 'swap', 'rxtx_factor', 'is_public', + 'description'] if self.params[k] is not None) # Keep for backward compatibility