Merge "Fix server show for microversion 2.47"
This commit is contained in:
commit
9766eb23e7
openstackclient
releasenotes/notes
@ -148,12 +148,18 @@ def _prep_server_detail(compute_client, image_client, server, refresh=True):
|
|||||||
|
|
||||||
# Convert the flavor blob to a name
|
# Convert the flavor blob to a name
|
||||||
flavor_info = info.get('flavor', {})
|
flavor_info = info.get('flavor', {})
|
||||||
flavor_id = flavor_info.get('id', '')
|
# Microversion 2.47 puts the embedded flavor into the server response
|
||||||
try:
|
# body but omits the id, so if not present we just expose the flavor
|
||||||
flavor = utils.find_resource(compute_client.flavors, flavor_id)
|
# dict in the server output.
|
||||||
info['flavor'] = "%s (%s)" % (flavor.name, flavor_id)
|
if 'id' in flavor_info:
|
||||||
except Exception:
|
flavor_id = flavor_info.get('id', '')
|
||||||
info['flavor'] = flavor_id
|
try:
|
||||||
|
flavor = utils.find_resource(compute_client.flavors, flavor_id)
|
||||||
|
info['flavor'] = "%s (%s)" % (flavor.name, flavor_id)
|
||||||
|
except Exception:
|
||||||
|
info['flavor'] = flavor_id
|
||||||
|
else:
|
||||||
|
info['flavor'] = utils.format_dict(flavor_info)
|
||||||
|
|
||||||
if 'os-extended-volumes:volumes_attached' in info:
|
if 'os-extended-volumes:volumes_attached' in info:
|
||||||
info.update(
|
info.update(
|
||||||
@ -1257,6 +1263,10 @@ class ListServer(command.Lister):
|
|||||||
s.flavor_name = flavor.name
|
s.flavor_name = flavor.name
|
||||||
s.flavor_id = s.flavor['id']
|
s.flavor_id = s.flavor['id']
|
||||||
else:
|
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_name = ''
|
||||||
s.flavor_id = ''
|
s.flavor_id = ''
|
||||||
|
|
||||||
@ -1994,7 +2004,9 @@ class ShelveServer(command.Command):
|
|||||||
|
|
||||||
|
|
||||||
class ShowServer(command.ShowOne):
|
class ShowServer(command.ShowOne):
|
||||||
_description = _("Show server details")
|
_description = _(
|
||||||
|
"Show server details. Specify ``--os-compute-api-version 2.47`` "
|
||||||
|
"or higher to see the embedded flavor information for the server.")
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(ShowServer, self).get_parser(prog_name)
|
parser = super(ShowServer, self).get_parser(prog_name)
|
||||||
|
@ -3217,6 +3217,33 @@ class TestServerShow(TestServer):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, data)
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
|
def test_show_embedded_flavor(self):
|
||||||
|
# Tests using --os-compute-api-version >= 2.47 where the flavor
|
||||||
|
# details are embedded in the server response body excluding the id.
|
||||||
|
arglist = [
|
||||||
|
self.server.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('diagnostics', False),
|
||||||
|
('server', self.server.name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
self.server.info['flavor'] = {
|
||||||
|
'ephemeral': 0,
|
||||||
|
'ram': 512,
|
||||||
|
'original_name': 'm1.tiny',
|
||||||
|
'vcpus': 1,
|
||||||
|
'extra_specs': {},
|
||||||
|
'swap': 0,
|
||||||
|
'disk': 1
|
||||||
|
}
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
# Since the flavor details are in a dict we can't be sure of the
|
||||||
|
# ordering so just assert that one of the keys is in the output.
|
||||||
|
self.assertIn('original_name', data[2])
|
||||||
|
|
||||||
def test_show_diagnostics(self):
|
def test_show_diagnostics(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--diagnostics',
|
'--diagnostics',
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
The ``openstack server show`` command will now properly show the server's
|
||||||
|
flavor information when using ``--os-compute-api-version 2.47`` or higher.
|
||||||
|
See: https://storyboard.openstack.org/#!/story/1751104
|
Loading…
x
Reference in New Issue
Block a user