os-xenapi/os_xenapi/client/host_glance.py
naichuans d674b83624 os-xenapi: Exception Error logs shown in Citrix XenServer CI
There are many errors in the patchs which passed our XenServer CI,
it is because when run tempest, test case will ask nova sevice to
do snapshotting, then delete image before snapshotting done. Then
nova compute service couldn't find the image when do image upload
and raise an exception.
Normally the exception can be consumed by nova service. But the
exception generated by os-xenapi can't be recognized by nova, so
the error logs come out.
Add a exception in os_xenapi/client to mark image not found
exception and convert it to another exception which computer
service can process in nova/virt/xenapi.

Change-Id: I16d199e93f615e4f374d49948dceeb4d1d600aa9
Depends-On: Ibe30a76f278264e0ddd1fc29d533fdeaab0a13a5
Closes-Bug: 1700926
2017-07-10 09:34:50 +00:00

41 lines
1.7 KiB
Python

# Copyright 2017 Citrix Systems
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from os_xenapi.client import exception
from os_xenapi.client import XenAPI
def download_vhd(session, num_retries, callback, retry_cb, image_id, sr_path,
extra_headers, uuid_stack=''):
args = {'image_id': image_id, 'sr_path': sr_path,
'extra_headers': extra_headers, 'uuid_stack': uuid_stack}
return session.call_plugin_serialized_with_retry(
'glance.py', 'download_vhd2', num_retries, callback, retry_cb, **args)
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