Skip to content

Commit 5feaa95

Browse files
committed
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
1 parent d90e18b commit 5feaa95

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

openstackclient/compute/v2/flavor.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,25 @@ def take_action(self, parsed_args):
156156
msg = _("--project is only allowed with --private")
157157
raise exceptions.CommandError(msg)
158158

159+
flavor_id = parsed_args.id
160+
if parsed_args.id == 'auto':
161+
# novaclient aliased 'auto' to mean "generate a UUID for me": we
162+
# do the same to avoid breaking existing users
163+
flavor_id = None
164+
165+
msg = _(
166+
"Passing '--id auto' is deprecated. Nova will automatically "
167+
"assign a UUID-like ID if no ID is provided. Omit the '--id' "
168+
"parameter instead."
169+
)
170+
self.log.warning(msg)
171+
159172
args = {
160173
'name': parsed_args.name,
161174
'ram': parsed_args.ram,
162175
'vcpus': parsed_args.vcpus,
163176
'disk': parsed_args.disk,
164-
'id': parsed_args.id,
177+
'id': flavor_id,
165178
'ephemeral': parsed_args.ephemeral,
166179
'swap': parsed_args.swap,
167180
'rxtx_factor': parsed_args.rxtx_factor,

openstackclient/tests/unit/compute/v2/test_flavor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def test_flavor_create_other_options(self):
245245
'ram': self.flavor.ram,
246246
'vcpus': self.flavor.vcpus,
247247
'disk': self.flavor.disk,
248-
'id': 'auto',
248+
'id': None,
249249
'ephemeral': self.flavor.ephemeral,
250250
'swap': self.flavor.swap,
251251
'rxtx_factor': self.flavor.rxtx_factor,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
deprecations:
3+
- |
4+
The ``--id auto`` alias for the ``flavor create`` command is deprecated
5+
for removal. Omit the option entirely to ensure the server creates the
6+
ID for you.

0 commit comments

Comments
 (0)