From b00f8a603a698c069caaa8e87f73d219a310f0ff Mon Sep 17 00:00:00 2001 From: Ying Zuo Date: Mon, 10 Jul 2017 19:35:17 -0700 Subject: [PATCH] Fix missing volume name on launch instance modal The Volume object passed back from cinder doesn't have the name for volumes created with an instance. It should be passed in to api.cinder.Volume to get the name properly. Change-Id: I2a812c898f601c741f232419f96bf93f3965bf81 Closes-bug: #1702966 --- openstack_dashboard/api/rest/cinder.py | 2 +- openstack_dashboard/test/api_tests/cinder_rest_tests.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/openstack_dashboard/api/rest/cinder.py b/openstack_dashboard/api/rest/cinder.py index 53cc3f4890..850fe5ecdd 100644 --- a/openstack_dashboard/api/rest/cinder.py +++ b/openstack_dashboard/api/rest/cinder.py @@ -68,7 +68,7 @@ class Volumes(generic.View): search_opts=search_opts, **kwargs ) return { - 'items': [u.to_dict() for u in result], + 'items': [api.cinder.Volume(u).to_dict() for u in result], 'has_more_data': has_more, 'has_prev_data': has_prev } diff --git a/openstack_dashboard/test/api_tests/cinder_rest_tests.py b/openstack_dashboard/test/api_tests/cinder_rest_tests.py index 097d99488a..a5759991b3 100644 --- a/openstack_dashboard/test/api_tests/cinder_rest_tests.py +++ b/openstack_dashboard/test/api_tests/cinder_rest_tests.py @@ -44,14 +44,16 @@ class CinderRestTestCase(test.TestCase): request = self.mock_rest_request(GET={'all_projects': 'true'}) else: request = self.mock_rest_request(**{'GET': filters}) + cc.volume_list_paged.return_value = [ - mock.Mock(**{'to_dict.return_value': {'id': 'one'}}), - mock.Mock(**{'to_dict.return_value': {'id': 'two'}}), + mock.Mock(**{'to_dict.return_value': {'id': 'test123'}}), ], False, False + cc.Volume.return_value = mock.Mock( + **{'to_dict.return_value': {"id": "test123"}}) response = cinder.Volumes().get(request) self.assertStatusCode(response, 200) self.assertEqual(response.json, - {"items": [{"id": "one"}, {"id": "two"}], + {"items": [{"id": "test123"}], "has_more_data": False, "has_prev_data": False}) if all: