[live-images] Filter non-image results
Only keep results that have known extension. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
1044fb01f8
commit
ab44f3539e
@ -243,8 +243,11 @@ class CreateLiveImageThread(WorkerThread):
|
|||||||
raise RuntimeError("LiveImage task failed: %s. See %s for more details." % (output["task_id"], log_file))
|
raise RuntimeError("LiveImage task failed: %s. See %s for more details." % (output["task_id"], log_file))
|
||||||
|
|
||||||
# copy finished image to isos/
|
# copy finished image to isos/
|
||||||
image_path = koji_wrapper.get_image_path(output["task_id"])
|
image_path = [path for path in koji_wrapper.get_image_path(output["task_id"])
|
||||||
# TODO: assert len == 1
|
if self._is_image(path)]
|
||||||
|
if len(image_path) != 1:
|
||||||
|
raise RuntimeError('Got %d images from task %d, expected 1.'
|
||||||
|
% (len(image_path), output['task_id']))
|
||||||
image_path = image_path[0]
|
image_path = image_path[0]
|
||||||
shutil.copy2(image_path, cmd["iso_path"])
|
shutil.copy2(image_path, cmd["iso_path"])
|
||||||
|
|
||||||
@ -266,6 +269,12 @@ class CreateLiveImageThread(WorkerThread):
|
|||||||
|
|
||||||
self.pool.log_info("[DONE ] %s" % msg)
|
self.pool.log_info("[DONE ] %s" % msg)
|
||||||
|
|
||||||
|
def _is_image(self, path):
|
||||||
|
for ext in ('.iso', '.raw.xz'):
|
||||||
|
if path.endswith(ext):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def _write_manifest(self, iso_path):
|
def _write_manifest(self, iso_path):
|
||||||
"""Generate manifest for ISO at given path.
|
"""Generate manifest for ISO at given path.
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ class TestCreateLiveImageThread(unittest.TestCase):
|
|||||||
'output': 'some output',
|
'output': 'some output',
|
||||||
'task_id': 123
|
'task_id': 123
|
||||||
}
|
}
|
||||||
koji_wrapper.get_image_path.return_value = ['/path/to/image']
|
koji_wrapper.get_image_path.return_value = ['/path/to/image.iso']
|
||||||
|
|
||||||
t = CreateLiveImageThread(pool)
|
t = CreateLiveImageThread(pool)
|
||||||
with mock.patch('time.sleep'):
|
with mock.patch('time.sleep'):
|
||||||
@ -263,7 +263,7 @@ class TestCreateLiveImageThread(unittest.TestCase):
|
|||||||
[mock.call('koji spin-livecd ...', log_file='/a/b/log/log_file')])
|
[mock.call('koji spin-livecd ...', log_file='/a/b/log/log_file')])
|
||||||
self.assertEqual(koji_wrapper.get_image_path.mock_calls, [mock.call(123)])
|
self.assertEqual(koji_wrapper.get_image_path.mock_calls, [mock.call(123)])
|
||||||
self.assertEqual(copy2.mock_calls,
|
self.assertEqual(copy2.mock_calls,
|
||||||
[mock.call('/path/to/image', '/iso_dir/amd64/Client/image-name')])
|
[mock.call('/path/to/image.iso', '/iso_dir/amd64/Client/image-name')])
|
||||||
|
|
||||||
write_manifest_cmd = ' && '.join([
|
write_manifest_cmd = ' && '.join([
|
||||||
'cd /iso_dir/amd64/Client',
|
'cd /iso_dir/amd64/Client',
|
||||||
@ -314,7 +314,7 @@ class TestCreateLiveImageThread(unittest.TestCase):
|
|||||||
'output': 'some output',
|
'output': 'some output',
|
||||||
'task_id': 123
|
'task_id': 123
|
||||||
}
|
}
|
||||||
koji_wrapper.get_image_path.return_value = ['/path/to/image']
|
koji_wrapper.get_image_path.return_value = ['/path/to/image.iso']
|
||||||
|
|
||||||
t = CreateLiveImageThread(pool)
|
t = CreateLiveImageThread(pool)
|
||||||
with mock.patch('time.sleep'):
|
with mock.patch('time.sleep'):
|
||||||
@ -324,7 +324,7 @@ class TestCreateLiveImageThread(unittest.TestCase):
|
|||||||
[mock.call('koji spin-livecd ...', log_file='/a/b/log/log_file')])
|
[mock.call('koji spin-livecd ...', log_file='/a/b/log/log_file')])
|
||||||
self.assertEqual(koji_wrapper.get_image_path.mock_calls, [mock.call(123)])
|
self.assertEqual(koji_wrapper.get_image_path.mock_calls, [mock.call(123)])
|
||||||
self.assertEqual(copy2.mock_calls,
|
self.assertEqual(copy2.mock_calls,
|
||||||
[mock.call('/path/to/image', '/iso_dir/amd64/Client/image-name')])
|
[mock.call('/path/to/image.iso', '/iso_dir/amd64/Client/image-name')])
|
||||||
|
|
||||||
write_manifest_cmd = ' && '.join([
|
write_manifest_cmd = ' && '.join([
|
||||||
'cd /iso_dir/amd64/Client',
|
'cd /iso_dir/amd64/Client',
|
||||||
|
Loading…
Reference in New Issue
Block a user