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):

        conf = get_device_conf_func(device)
        if conf is None:
            raise exception.DeviceNotFound(device=device)

        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:
                # Device is already detached from persistent domain
                # and only transient domain needs update
                self.detach_device(config, persistent=False, live=live)
                # Raise error since the device still existed on the guest
                reason = _("Unable to detach from guest transient domain.")
                raise exception.DeviceDetachFailed(device=device,
                                                   reason=reason)

        return _do_wait_and_retry_detach
Detaches a device from the guest. After the initial detach request,
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/virt/libvirt/guest.py/Guest.detach_device_with_retry