'Three situations can occur:
1. We have neither a ramdisk nor a kernel, in which case we are a
RAW image and can omit this step
2. We have one or the other, in which case, we should flag as an
error
3. We have both, in which case we safely remove both the kernel
and the ramdisk.'

def _destroy_kernel_ramdisk(self, instance, vm_ref):

    instance_uuid = instance['uuid']
    if ((not instance['kernel_id']) and (not instance['ramdisk_id'])):
        LOG.debug('Using    RAW    or    VHD,    skipping    kernel    and    ramdisk    deletion', instance=instance)
        return
    if (not (instance['kernel_id'] and instance['ramdisk_id'])):
        raise exception.InstanceUnacceptable(instance_id=instance_uuid, reason=_('instance    has    a    kernel    or    ramdisk    but    not    both'))
    (kernel, ramdisk) = vm_utils.lookup_kernel_ramdisk(self._session, vm_ref)
    if (kernel or ramdisk):
        vm_utils.destroy_kernel_ramdisk(self._session, instance, kernel, ramdisk)
        LOG.debug('kernel/ramdisk    files    removed', instance=instance)
