Make Hyper-V to work with glance v2 api

This code makes hyper-v driver version agnostic
and allows to work with both apis, depending
on what version is considered as 'current'

partially implements bp use-glance-v2-api

Change-Id: I689faca79a7158357da75bd19aa0e2b58eb5a304
This commit is contained in:
Mike Fedosin
2016-06-02 19:49:35 +03:00
committed by Sudipta Biswas
parent 383a0c9cbb
commit 70cd68ad70
2 changed files with 6 additions and 6 deletions

View File

@@ -41,8 +41,7 @@ class SnapshotOpsTestCase(test_base.HyperVBaseTestCase):
def test_save_glance_image(self, mock_get_remote_image_service):
image_metadata = {"is_public": False,
"disk_format": "vhd",
"container_format": "bare",
"properties": {}}
"container_format": "bare"}
glance_image_service = mock.MagicMock()
mock_get_remote_image_service.return_value = (glance_image_service,
mock.sentinel.IMAGE_ID)
@@ -55,7 +54,8 @@ class SnapshotOpsTestCase(test_base.HyperVBaseTestCase):
mock.sentinel.PATH, 'rb')
glance_image_service.update.assert_called_once_with(
self.context, mock.sentinel.IMAGE_ID, image_metadata,
self._snapshotops._pathutils.open().__enter__())
self._snapshotops._pathutils.open().__enter__(),
purge_props=False)
@mock.patch('nova.virt.hyperv.snapshotops.SnapshotOps._save_glance_image')
def _test_snapshot(self, mock_save_glance_image, base_disk_path):

View File

@@ -43,10 +43,10 @@ class SnapshotOps(object):
image_id) = glance.get_remote_image_service(context, image_id)
image_metadata = {"is_public": False,
"disk_format": "vhd",
"container_format": "bare",
"properties": {}}
"container_format": "bare"}
with self._pathutils.open(image_vhd_path, 'rb') as f:
glance_image_service.update(context, image_id, image_metadata, f)
glance_image_service.update(context, image_id, image_metadata, f,
purge_props=False)
def snapshot(self, context, instance, image_id, update_task_state):
# While the snapshot operation is not synchronized within the manager,