From da7572a5ff9f54dbab4f8328632c562a2816a4fb Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Fri, 8 Jun 2018 14:43:41 -0400 Subject: Fix server show for microversion 2.47 Compute API version 2.47 embeds the server's internal flavor in the response. The original flavor id is not preserved since it could have changed if the flavor was deleted and re-created after the server was created, which was the dreaded Horizon "Edit Flavor" issue. So the flavor dict in the server response is a dict of information about the flavor representing the server "right now" excluding the id. The original flavor name is shown though along with the ram/disk/vcpu etc information. The server list command has a similar issue which will be fixed in a follow up change. Change-Id: I1a92999758006d02567c542b6be8902a049899cc Task: 13864 Story: 1751104 --- .../tests/unit/compute/v2/test_server.py | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'openstackclient/tests/unit') diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py index 61c81132..a53c6c81 100644 --- a/openstackclient/tests/unit/compute/v2/test_server.py +++ b/openstackclient/tests/unit/compute/v2/test_server.py @@ -3217,6 +3217,33 @@ class TestServerShow(TestServer): self.assertEqual(self.columns, columns) 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): arglist = [ '--diagnostics', -- cgit v1.2.1