def upload_vhd(session, num_retries, callback, retry_cb, image_id, sr_path, extra_headers, vdi_uuids='', properties={}): args = { 'image_id': image_id, 'sr_path': sr_path, 'extra_headers': extra_headers, 'vdi_uuids': vdi_uuids, 'properties': properties } try: session.call_plugin_serialized_with_retry('glance.py', 'upload_vhd2', num_retries, callback, retry_cb, **args) except XenAPI.Failure as exc: if (len(exc.details) == 4 and exc.details[3] == 'ImageNotFound'): raise exception.PluginImageNotFound(image_id=image_id) else: raise
def test_upload_image_raises_exception_image_not_found( self, mock_upload, mock_sr_path, mock_extra_header, mock_disk_config): params = self._get_upload_params() mock_upload.return_value = 'fake_upload' mock_sr_path.return_value = 'fake_sr_path' mock_extra_header.return_value = 'fake_extra_header' mock_disk_config.return_value = 'true' image_id = 'fake_image_id' mock_upload.side_effect = xenapi_exception.PluginImageNotFound( image_id=image_id) self.assertRaises(exception.ImageNotFound, self.store.upload_image, self.context, self.session, self.instance, 'fake_image_uuid', ['fake_vdi_uuid']) mock_sr_path.assert_called_once_with(self.session) mock_extra_header.assert_called_once_with(self.context) mock_upload.assert_called_once_with(self.session, 0, mock.ANY, mock.ANY, 'fake_image_uuid', 'fake_sr_path', 'fake_extra_header', **params)