diff options
| author | Zuul <zuul@review.opendev.org> | 2022-07-06 12:11:35 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2022-07-06 12:11:35 +0000 |
| commit | 324d4b0bf5d965ced4b985d73e8331e2383086cc (patch) | |
| tree | 55f864ac3e77550eb3f526edcbb7bc5fcabbd085 /openstackclient/compute | |
| parent | 2e7af9fd1621cb91a678b500ecc222576614b6e6 (diff) | |
| parent | 63e15ff405c46821d64676900edf020973c280de (diff) | |
| download | python-openstackclient-324d4b0bf5d965ced4b985d73e8331e2383086cc.tar.gz | |
Merge "compute: Show flavor in 'server list' with API >= 2.47" into stable/train
Diffstat (limited to 'openstackclient/compute')
| -rw-r--r-- | openstackclient/compute/v2/server.py | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index d93322c8..2b68a5cf 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -1415,21 +1415,28 @@ class ListServer(command.Lister): columns += ('image_name',) column_headers += ('Image',) - if parsed_args.long: - columns += ( - 'flavor_name', - 'flavor_id', - ) - column_headers += ( - 'Flavor Name', - 'Flavor ID', - ) + # microversion 2.47 puts the embedded flavor into the server response + # body but omits the id, so if not present we just expose the original + # flavor name in the output + if compute_client.api_version >= api_versions.APIVersion('2.47'): + columns += ('flavor_name',) + column_headers += ('Flavor',) else: - if parsed_args.no_name_lookup: - columns += ('flavor_id',) + if parsed_args.long: + columns += ( + 'flavor_name', + 'flavor_id', + ) + column_headers += ( + 'Flavor Name', + 'Flavor ID', + ) else: - columns += ('flavor_name',) - column_headers += ('Flavor',) + if parsed_args.no_name_lookup: + columns += ('flavor_id',) + else: + columns += ('flavor_name',) + column_headers += ('Flavor',) if parsed_args.long: columns += ( @@ -1532,18 +1539,13 @@ class ListServer(command.Lister): s.image_name = '' s.image_id = '' - if 'id' in s.flavor: + if compute_client.api_version < api_versions.APIVersion('2.47'): flavor = flavors.get(s.flavor['id']) if flavor: s.flavor_name = flavor.name s.flavor_id = s.flavor['id'] else: - # TODO(mriedem): Fix this for microversion >= 2.47 where the - # flavor is embedded in the server response without the id. - # We likely need to drop the Flavor ID column in that case if - # --long is specified. - s.flavor_name = '' - s.flavor_id = '' + s.flavor_name = s.flavor['original_name'] table = (column_headers, (utils.get_item_properties( |
