Skip to content

Commit 9eb4240

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "compute: Show flavor in 'server list' with API >= 2.47"
2 parents d9ad0b5 + 8e36240 commit 9eb4240

3 files changed

Lines changed: 348 additions & 260 deletions

File tree

openstackclient/compute/v2/server.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,21 +2369,28 @@ def take_action(self, parsed_args):
23692369
columns += ('image_name',)
23702370
column_headers += ('Image',)
23712371

2372-
if parsed_args.long:
2373-
columns += (
2374-
'flavor_name',
2375-
'flavor_id',
2376-
)
2377-
column_headers += (
2378-
'Flavor Name',
2379-
'Flavor ID',
2380-
)
2372+
# microversion 2.47 puts the embedded flavor into the server response
2373+
# body but omits the id, so if not present we just expose the original
2374+
# flavor name in the output
2375+
if compute_client.api_version >= api_versions.APIVersion('2.47'):
2376+
columns += ('flavor_name',)
2377+
column_headers += ('Flavor',)
23812378
else:
2382-
if parsed_args.no_name_lookup:
2383-
columns += ('flavor_id',)
2379+
if parsed_args.long:
2380+
columns += (
2381+
'flavor_name',
2382+
'flavor_id',
2383+
)
2384+
column_headers += (
2385+
'Flavor Name',
2386+
'Flavor ID',
2387+
)
23842388
else:
2385-
columns += ('flavor_name',)
2386-
column_headers += ('Flavor',)
2389+
if parsed_args.no_name_lookup:
2390+
columns += ('flavor_id',)
2391+
else:
2392+
columns += ('flavor_name',)
2393+
column_headers += ('Flavor',)
23872394

23882395
if parsed_args.long:
23892396
columns += (
@@ -2507,18 +2514,13 @@ def take_action(self, parsed_args):
25072514
s.image_name = IMAGE_STRING_FOR_BFV
25082515
s.image_id = IMAGE_STRING_FOR_BFV
25092516

2510-
if 'id' in s.flavor:
2517+
if compute_client.api_version < api_versions.APIVersion('2.47'):
25112518
flavor = flavors.get(s.flavor['id'])
25122519
if flavor:
25132520
s.flavor_name = flavor.name
25142521
s.flavor_id = s.flavor['id']
25152522
else:
2516-
# TODO(mriedem): Fix this for microversion >= 2.47 where the
2517-
# flavor is embedded in the server response without the id.
2518-
# We likely need to drop the Flavor ID column in that case if
2519-
# --long is specified.
2520-
s.flavor_name = ''
2521-
s.flavor_id = ''
2523+
s.flavor_name = s.flavor['original_name']
25222524

25232525
table = (
25242526
column_headers,

0 commit comments

Comments
 (0)