Fix the incorrect log message when creating images
When using "nova image-create my_server_id name" to create an image, the glance api log image id is incorrect in the method create(). Change-Id: I938279526ed5adf5b95ec5f67e78c6465f890898 Closes-bug: #1263647
This commit is contained in:
committed by
Gerrit Code Review
parent
016204e8c4
commit
c1c72d1694
@@ -392,9 +392,10 @@ class Controller(object):
|
||||
try:
|
||||
image_data = _normalize_image_location_for_db(image_data)
|
||||
image_data = self.db_api.image_create(req.context, image_data)
|
||||
msg = _("Successfully created image %(id)s") % {'id': image_id}
|
||||
image_data = dict(image=make_image_dict(image_data))
|
||||
msg = _("Successfully created image %(id)s") % image_data['image']
|
||||
LOG.info(msg)
|
||||
return dict(image=make_image_dict(image_data))
|
||||
return image_data
|
||||
except exception.Duplicate:
|
||||
msg = _("Image with identifier %s already exists!") % image_id
|
||||
LOG.error(msg)
|
||||
|
||||
@@ -1279,6 +1279,22 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
||||
self.get_api_response_ext(400, content_type='json', method='POST',
|
||||
body=jsonutils.dumps(dict(image=fixture)))
|
||||
|
||||
def test_create_image_with_image_id_in_log(self):
|
||||
"""Tests correct image id in log message when creating image"""
|
||||
fixture = self.get_minimal_fixture(
|
||||
id='0564c64c-3545-4e34-abfb-9d18e5f2f2f9')
|
||||
self.log_image_id = False
|
||||
|
||||
def fake_log_info(msg):
|
||||
if 'Successfully created image ' \
|
||||
'0564c64c-3545-4e34-abfb-9d18e5f2f2f9' in msg:
|
||||
self.log_image_id = True
|
||||
self.stubs.Set(rserver.images.LOG, 'info', fake_log_info)
|
||||
|
||||
self.get_api_response_ext(200, content_type='json', method='POST',
|
||||
body=jsonutils.dumps(dict(image=fixture)))
|
||||
self.assertTrue(self.log_image_id)
|
||||
|
||||
def test_update_image(self):
|
||||
"""Tests that the /images PUT registry API updates the image"""
|
||||
fixture = {'name': 'fake public image #2',
|
||||
|
||||
Reference in New Issue
Block a user