def force_persistent_boot(task, device, persistent):
    """Set persistent boot device to driver_internal_info

    If persistent is True set 'persistent_boot_device' field to the
    boot device and reset persistent to False, else set
    'is_next_boot_persistent' to False.

    :param task: Task object.
    :param device: Boot device.
    :param persistent: Whether next boot is persistent or not.
    """
    node = task.node
    driver_internal_info = node.driver_internal_info
    if persistent:
        driver_internal_info.pop('is_next_boot_persistent', None)
        driver_internal_info['persistent_boot_device'] = device
    else:
        driver_internal_info['is_next_boot_persistent'] = False
    node.driver_internal_info = driver_internal_info
    node.save()
