def _hard_reboot(self, context, instance, network_info, block_device_info=None):
    'Reboot a virtual machine, given an instance reference.\n\n        Performs a Libvirt reset (if supported) on the domain.\n\n        If Libvirt reset is unavailable this method actually destroys and\n        re-creates the domain to ensure the reboot happens, as the guest\n        OS cannot ignore this action.\n\n        If xml is set, it uses the passed in xml in place of the xml from the\n        existing domain.\n        '
    self._destroy(instance)
    system_meta = utils.instance_sys_meta(instance)
    image_meta = utils.get_image_from_system_metadata(system_meta)
    if (not image_meta):
        image_ref = instance.get('image_ref')
        image_meta = compute_utils.get_image_metadata(context, self._image_api, image_ref, instance)
    disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type, instance, block_device_info, image_meta)
    xml = self._get_guest_xml(context, instance, network_info, disk_info, image_meta=image_meta, block_device_info=block_device_info, write_to_disk=True)
    disk_info_json = self._get_instance_disk_info(instance['name'], xml, block_device_info)
    instance_dir = libvirt_utils.get_instance_path(instance)
    self._create_images_and_backing(context, instance, instance_dir, disk_info_json)
    self._create_domain_and_network(context, xml, instance, network_info, block_device_info, reboot=True, vifs_already_plugged=True)
    self._prepare_pci_devices_for_use(pci_manager.get_instance_pci_devs(instance))

    def _wait_for_reboot():
        'Called at an interval until the VM is running again.'
        state = self.get_info(instance)['state']
        if (state == power_state.RUNNING):
            LOG.info(_LI('Instance rebooted successfully.'), instance=instance)
            raise loopingcall.LoopingCallDone()
    timer = loopingcall.FixedIntervalLoopingCall(_wait_for_reboot)
    timer.start(interval=0.5).wait()
Reboot a virtual machine, given an instance reference.

Performs a Libvirt reset (if supported) on the domain.

If Libvirt reset is unavailable this method actually destroys and
re-creates the domain to ensure the reboot happens, as the guest
OS cannot ignore this action.

If xml is set, it uses the passed in xml in place of the xml from the
existing domain.
def _hard_reboot(self, context, instance, network_info, block_device_info=None):
    'Reboot a virtual machine, given an instance reference.\n\n        Performs a Libvirt reset (if supported) on the domain.\n\n        If Libvirt reset is unavailable this method actually destroys and\n        re-creates the domain to ensure the reboot happens, as the guest\n        OS cannot ignore this action.\n\n        If xml is set, it uses the passed in xml in place of the xml from the\n        existing domain.\n        '
    self._destroy(instance)
    system_meta = utils.instance_sys_meta(instance)
    image_meta = utils.get_image_from_system_metadata(system_meta)
    if (not image_meta):
        image_ref = instance.get('image_ref')
        image_meta = compute_utils.get_image_metadata(context, self._image_api, image_ref, instance)
    disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type, instance, block_device_info, image_meta)
    xml = self._get_guest_xml(context, instance, network_info, disk_info, image_meta=image_meta, block_device_info=block_device_info, write_to_disk=True)
    disk_info_json = self._get_instance_disk_info(instance['name'], xml, block_device_info)
    instance_dir = libvirt_utils.get_instance_path(instance)
    self._create_images_and_backing(context, instance, instance_dir, disk_info_json)
    self._create_domain_and_network(context, xml, instance, network_info, block_device_info, reboot=True, vifs_already_plugged=True)
    self._prepare_pci_devices_for_use(pci_manager.get_instance_pci_devs(instance))

    def _wait_for_reboot():
        'Called at an interval until the VM is running again.'
        state = self.get_info(instance)['state']
        if (state == power_state.RUNNING):
            LOG.info(_LI('Instance rebooted successfully.'), instance=instance)
            raise loopingcall.LoopingCallDone()
    timer = loopingcall.FixedIntervalLoopingCall(_wait_for_reboot)
    timer.start(interval=0.5).wait()