

def detach_device_with_retry(self, get_device_conf_func, device, persistent, live, max_retry_count=7, inc_sleep_time=2, max_sleep_time=30):
    'Detaches a device from the guest. After the initial detach request,\n        a function is returned which can be used to ensure the device is\n        successfully removed from the guest domain (retrying the removal as\n        necessary).\n\n        :param get_device_conf_func: function which takes device as a parameter\n                                     and returns the configuration for device\n        :param device: device to detach\n        :param persistent: bool to indicate whether the change is\n                           persistent or not\n        :param live: bool to indicate whether it affects the guest in running\n                     state\n        :param max_retry_count: number of times the returned function will\n                                retry a detach before failing\n        :param inc_sleep_time: incremental time to sleep in seconds between\n                               detach retries\n        :param max_sleep_time: max sleep time in seconds beyond which the sleep\n                               time will not be incremented using param\n                               inc_sleep_time. On reaching this threshold,\n                               max_sleep_time will be used as the sleep time.\n        '
    conf = get_device_conf_func(device)
    if (conf is None):
        raise exception.DeviceNotFound(device=persistent)
    self.detach_device(conf, persistent, live)

    @loopingcall.RetryDecorator(max_retry_count=max_retry_count, inc_sleep_time=inc_sleep_time, max_sleep_time=max_sleep_time, exceptions=exception.DeviceDetachFailed)
    def _do_wait_and_retry_detach():
        config = get_device_conf_func(device)
        if (config is not None):
            self.detach_device(config, persistent=False, live=live)
            reason = _('Unable to detach from guest transient domain.')
            raise exception.DeviceDetachFailed(device=device, reason=reason)
    return _do_wait_and_retry_detach

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/virt/libvirt/guest.py Guest.detach_device_with_retry/VarMisuse@55/468 `device`->`persistent`