Save image data after setting the data

The image's locations are missing when image's are imported using tasks
because the ImportToStore task is not saving the image metadata after
the import. This patch fixes that.

Change-Id: I43dec450d5fc4bee2131d78dbe3c2b2373c3f739
Closes-bug: #1453068
This commit is contained in:
Flavio Percoco 2015-05-08 11:44:14 +02:00 committed by Flavio Percoco
parent d77fd685ea
commit 4efb56aae9
2 changed files with 8 additions and 0 deletions

View File

@ -283,6 +283,10 @@ class _ImportToStore(task.Task):
image_import.set_image_data(image, file_path or self.uri, None)
# NOTE(flaper87): We need to save the image again after the locations
# have been set in the image.
self.image_repo.save(image)
class _SaveImage(task.Task):

View File

@ -112,6 +112,10 @@ class TestImportTask(test_utils.BaseTestCase):
"%s.tasks_import" % image_path)
self.assertFalse(os.path.exists(tmp_image_path))
self.assertTrue(os.path.exists(image_path))
self.assertEqual(1, len(list(self.image.locations)))
self.assertEqual("file://%s/%s" % (self.test_dir,
self.image.image_id),
self.image.locations[0]['url'])
def test_import_flow_missing_work_dir(self):
self.config(engine_mode='serial', group='taskflow_executor')