Merge "PowerVM snapshot cleanup"

This commit is contained in:
Zuul 2018-05-31 20:46:51 +00:00 committed by Gerrit Code Review
commit a7994ec355
3 changed files with 10 additions and 13 deletions

View File

@ -21,25 +21,20 @@ from nova import test
from nova.virt.powervm import image
if six.PY2:
_BUILTIN = '__builtin__'
else:
_BUILTIN = 'builtins'
class TestImage(test.TestCase):
@mock.patch('nova.utils.temporary_chown', autospec=True)
@mock.patch(_BUILTIN + '.open', autospec=True)
@mock.patch('nova.image.api.API', autospec=True)
def test_stream_blockdev_to_glance(self, mock_api, mock_open, mock_chown):
mock_open.return_value.__enter__.return_value = 'mock_stream'
image.stream_blockdev_to_glance('context', mock_api, 'image_id',
'metadata', '/dev/disk')
def test_stream_blockdev_to_glance(self, mock_api, mock_chown):
mock_open = mock.mock_open()
with mock.patch.object(six.moves.builtins, 'open', new=mock_open):
image.stream_blockdev_to_glance('context', mock_api, 'image_id',
'metadata', '/dev/disk')
mock_chown.assert_called_with('/dev/disk')
mock_open.assert_called_with('/dev/disk', 'rb')
mock_api.update.assert_called_with('context', 'image_id', 'metadata',
'mock_stream')
mock_open.return_value)
@mock.patch('nova.image.api.API', autospec=True)
def test_generate_snapshot_metadata(self, mock_api):

View File

@ -43,9 +43,11 @@ def generate_snapshot_metadata(context, image_api, image_id, instance):
:param image_api: Handle to the glance image API.
:param image_id: UUID of the prepared glance image.
:param instance: The Nova instance whose disk is to be snapshotted.
:return: A dict of metadata suitable for image_api.upload.
:return: A dict of metadata suitable for image_api.update.
"""
image = image_api.get(context, image_id)
# TODO(esberglu): Update this to v2 metadata
metadata = {
'name': image['name'],
'is_public': False,

View File

@ -292,7 +292,7 @@ class DeleteVOpt(task.Task):
class InstanceDiskToMgmt(task.Task):
"""The task to connect an instance's disk to the management partition."
"""The task to connect an instance's disk to the management partition.
This task will connect the instance's disk to the management partition and
discover it. We do these two pieces together because their reversion