Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # From this point we have a VDI on Xen host;
- # If anything goes wrong, we need to remember its uuid.
- try:
- filename = None
- vdi_uuid = session.get_xenapi().VDI.get_uuid(vdi_ref)
- with_vdi_attached_here(session, vdi_ref, False,
- lambda dev:
- _stream_disk(dev, image_type,
- virtual_size, image_file))
- if image_type in (ImageType.KERNEL, ImageType.RAMDISK):
- # We need to invoke a plugin for copying the
- # content of the VDI into the proper path.
- LOG.debug(_("Copying VDI %s to /boot/guest on dom0"), vdi_ref)
- fn = "copy_kernel_vdi"
- args = {}
- args['vdi-ref'] = vdi_ref
- # Let the plugin copy the correct number of bytes.
- args['image-size'] = str(vdi_size)
- task = session.async_call_plugin('glance', fn, args)
- filename = session.wait_for_task(task, instance_id)
- # Remove the VDI as it is not needed anymore.
- session.get_xenapi().VDI.destroy(vdi_ref)
- LOG.debug(_("Kernel/Ramdisk VDI %s destroyed"), vdi_ref)
- return [dict(vdi_type=ImageType.to_string(image_type),
- vdi_uuid=None,
- file=filename)]
- else:
- return [dict(vdi_type=ImageType.to_string(image_type),
- vdi_uuid=vdi_uuid,
- file=None)]
- except (cls.XenAPI.Failure, IOError, OSError) as e:
- # We look for XenAPI and OS failures.
- LOG.exception(_("instance %s: Failed to fetch glance image"),
- instance_id, exc_info=sys.exc_info())
- e.args = e.args + ([dict(vdi_type=ImageType.
- to_string(image_type),
- vdi_uuid=vdi_uuid,
- file=filename)],)
- raise e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement