Fix parameter error in image_utils
Ref patch: https://review.openstack.org/#/c/514658/ 1. Fix parameter error of method fetch_to_volume_format that called in fetch_to_raw and fetch_to_vhd. 2. Add new parameter volume_subformat for fetch_to_vhd to keep the same business with [Ref patch]. Change-Id: Id30ffd8a40eca841b5d6461c2f0269a0d9a4d628
This commit is contained in:
parent
afecba3b95
commit
7411eb5aae
|
@ -406,10 +406,11 @@ def fetch_verify_image(context, image_service, image_id, dest,
|
|||
|
||||
|
||||
def fetch_to_vhd(context, image_service,
|
||||
image_id, dest, blocksize,
|
||||
image_id, dest, blocksize, volume_subformat=None,
|
||||
user_id=None, project_id=None, run_as_root=True):
|
||||
fetch_to_volume_format(context, image_service, image_id, dest, 'vpc',
|
||||
blocksize, user_id, project_id,
|
||||
blocksize, volume_subformat=volume_subformat,
|
||||
user_id=user_id, project_id=project_id,
|
||||
run_as_root=run_as_root)
|
||||
|
||||
|
||||
|
@ -417,8 +418,8 @@ def fetch_to_raw(context, image_service,
|
|||
image_id, dest, blocksize,
|
||||
user_id=None, project_id=None, size=None, run_as_root=True):
|
||||
fetch_to_volume_format(context, image_service, image_id, dest, 'raw',
|
||||
blocksize, user_id, project_id, size,
|
||||
run_as_root=run_as_root)
|
||||
blocksize, user_id=user_id, project_id=project_id,
|
||||
size=size, run_as_root=run_as_root)
|
||||
|
||||
|
||||
def fetch_to_volume_format(context, image_service,
|
||||
|
|
|
@ -615,13 +615,18 @@ class TestFetchToVhd(test.TestCase):
|
|||
image_id = mock.sentinel.image_id
|
||||
dest = mock.sentinel.dest
|
||||
blocksize = mock.sentinel.blocksize
|
||||
out_subformat = 'fake_subformat'
|
||||
|
||||
output = image_utils.fetch_to_vhd(ctxt, image_service, image_id,
|
||||
dest, blocksize)
|
||||
dest, blocksize,
|
||||
volume_subformat=out_subformat)
|
||||
self.assertIsNone(output)
|
||||
mock_fetch_to.assert_called_once_with(ctxt, image_service, image_id,
|
||||
dest, 'vpc', blocksize, None,
|
||||
None, run_as_root=True)
|
||||
dest, 'vpc', blocksize,
|
||||
volume_subformat=out_subformat,
|
||||
user_id=None,
|
||||
project_id=None,
|
||||
run_as_root=True)
|
||||
|
||||
@mock.patch('cinder.image.image_utils.check_available_space')
|
||||
@mock.patch('cinder.image.image_utils.fetch_to_volume_format')
|
||||
|
@ -634,15 +639,19 @@ class TestFetchToVhd(test.TestCase):
|
|||
user_id = mock.sentinel.user_id
|
||||
project_id = mock.sentinel.project_id
|
||||
run_as_root = mock.sentinel.run_as_root
|
||||
out_subformat = 'fake_subformat'
|
||||
|
||||
output = image_utils.fetch_to_vhd(ctxt, image_service, image_id,
|
||||
dest, blocksize, user_id=user_id,
|
||||
project_id=project_id,
|
||||
run_as_root=run_as_root)
|
||||
run_as_root=run_as_root,
|
||||
volume_subformat=out_subformat)
|
||||
self.assertIsNone(output)
|
||||
mock_fetch_to.assert_called_once_with(ctxt, image_service, image_id,
|
||||
dest, 'vpc', blocksize, user_id,
|
||||
project_id,
|
||||
dest, 'vpc', blocksize,
|
||||
volume_subformat=out_subformat,
|
||||
user_id=user_id,
|
||||
project_id=project_id,
|
||||
run_as_root=run_as_root)
|
||||
|
||||
|
||||
|
@ -659,8 +668,9 @@ class TestFetchToRaw(test.TestCase):
|
|||
dest, blocksize)
|
||||
self.assertIsNone(output)
|
||||
mock_fetch_to.assert_called_once_with(ctxt, image_service, image_id,
|
||||
dest, 'raw', blocksize, None,
|
||||
None, None, run_as_root=True)
|
||||
dest, 'raw', blocksize,
|
||||
user_id=None, project_id=None,
|
||||
size=None, run_as_root=True)
|
||||
|
||||
@mock.patch('cinder.image.image_utils.check_available_space')
|
||||
@mock.patch('cinder.image.image_utils.fetch_to_volume_format')
|
||||
|
@ -681,8 +691,9 @@ class TestFetchToRaw(test.TestCase):
|
|||
run_as_root=run_as_root)
|
||||
self.assertIsNone(output)
|
||||
mock_fetch_to.assert_called_once_with(ctxt, image_service, image_id,
|
||||
dest, 'raw', blocksize, user_id,
|
||||
project_id, size,
|
||||
dest, 'raw', blocksize,
|
||||
user_id=user_id, size=size,
|
||||
project_id=project_id,
|
||||
run_as_root=run_as_root)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue