def _destroy(self, instance, vm_ref, network_info=None,
                 destroy_disks=True, block_device_info=None):
        """Destroys VM instance by performing:

            1. A shutdown
            2. Destroying associated VDIs.
            3. Destroying kernel and ramdisk files (if necessary).
            4. Destroying that actual VM record.

        """
        if vm_ref is None:
            LOG.warning(_LW("VM is not present, skipping destroy..."),
                        instance=instance)
            # NOTE(alaski): There should not be a block device mapping here,
            # but if there is it very likely means there was an error cleaning
            # it up previously and there is now an orphaned sr/pbd. This will
            # prevent both volume and instance deletes from completing.
            bdms = block_device_info['block_device_mapping'] or []
            if not bdms:
                return
            for bdm in bdms:
                volume_id = bdm['connection_info']['data']['volume_id']
                # Note(bobba): Check for the old-style SR first; if this
                # doesn't find the SR, also look for the new-style from
                # parse_sr_info
                sr_uuid = volume_id % 'FA15E-D15C-%s'
                sr_ref = None
                try:
                    sr_ref = volume_utils.find_sr_by_uuid(self._session,
                                                          sr_uuid)
                    if not sr_ref:
                        connection_data = bdm['connection_info']['data']
                        (sr_uuid, _, _) = volume_utils.parse_sr_info(
                            connection_data)
                        sr_ref = volume_utils.find_sr_by_uuid(self._session,
                                                              sr_uuid)
                except Exception:
                    LOG.exception(_LE('Failed to find an SR for volume %s'),
                                  volume_id, instance=instance)

                try:
                    if sr_ref:
                        volume_utils.forget_sr(self._session, sr_ref)
                    else:
                        LOG.error(_LE('Volume %s is associated with the '
                            'instance but no SR was found for it'), volume_id,
                                instance=instance)
                except Exception:
                    LOG.exception(_LE('Failed to forget the SR for volume %s'),
                            volume_id, instance=instance)
            return

        # NOTE(alaski): Attempt clean shutdown first if there's an attached
        # volume to reduce the risk of corruption.
        if block_device_info and block_device_info['block_device_mapping']:
            if not vm_utils.clean_shutdown_vm(self._session, instance, vm_ref):
                LOG.debug("Clean shutdown did not complete successfully, "
                          "trying hard shutdown.", instance=instance)
                vm_utils.hard_shutdown_vm(self._session, instance, vm_ref)
        else:
            vm_utils.hard_shutdown_vm(self._session, instance, vm_ref)

        if destroy_disks:
            self._volumeops.detach_all(vm_ref)
            self._destroy_vdis(instance, vm_ref)
            self._destroy_kernel_ramdisk(instance, vm_ref)

        self.unplug_vifs(instance, network_info, vm_ref)
        self.firewall_driver.unfilter_instance(
                instance, network_info=network_info)
        vm_utils.destroy_vm(self._session, instance, vm_ref)
dataset/ETHPy150Open openstack/nova/nova/virt/xenapi/vmops.py/VMOps._destroy/swapped operands of `%`