compute: Fix flavor create --id auto

This was inadvertently broken during the switch from novaclient to SDK.
Fix it for now but also deprecate it since it is an unnecessary alias.

Change-Id: Iaf136d82e00defc86e57ae4ea7e848246f2ade2c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-bug: #2120833
This commit is contained in:
Stephen Finucane
2025-08-18 11:56:18 +01:00
parent d90e18b08c
commit 5feaa952ad
3 changed files with 21 additions and 2 deletions

View File

@@ -156,12 +156,25 @@ class CreateFlavor(command.ShowOne):
msg = _("--project is only allowed with --private")
raise exceptions.CommandError(msg)
flavor_id = parsed_args.id
if parsed_args.id == 'auto':
# novaclient aliased 'auto' to mean "generate a UUID for me": we
# do the same to avoid breaking existing users
flavor_id = None
msg = _(
"Passing '--id auto' is deprecated. Nova will automatically "
"assign a UUID-like ID if no ID is provided. Omit the '--id' "
"parameter instead."
)
self.log.warning(msg)
args = {
'name': parsed_args.name,
'ram': parsed_args.ram,
'vcpus': parsed_args.vcpus,
'disk': parsed_args.disk,
'id': parsed_args.id,
'id': flavor_id,
'ephemeral': parsed_args.ephemeral,
'swap': parsed_args.swap,
'rxtx_factor': parsed_args.rxtx_factor,

View File

@@ -245,7 +245,7 @@ class TestFlavorCreate(TestFlavor):
'ram': self.flavor.ram,
'vcpus': self.flavor.vcpus,
'disk': self.flavor.disk,
'id': 'auto',
'id': None,
'ephemeral': self.flavor.ephemeral,
'swap': self.flavor.swap,
'rxtx_factor': self.flavor.rxtx_factor,

View File

@@ -0,0 +1,6 @@
---
deprecations:
- |
The ``--id auto`` alias for the ``flavor create`` command is deprecated
for removal. Omit the option entirely to ensure the server creates the
ID for you.