Download disk device of HttpNfcLease.info.deviceUrl
    list of devices
    :param headers: Request headers
    :type cookies: dict
    :param cookies: Request cookies (session)
    :type cookies: dict
    :param temp_target_disk: file name to write
    :type temp_target_disk: str
    :param device_url: deviceUrl.url
    :type device_url: str
    :param lease_updater:
    :type lease_updater: LeaseProgressUpdater
    :param total_bytes_written: Bytes written so far
    :type total_bytes_to_write: long
    :param total_bytes_to_write: VM unshared storage
    :type total_bytes_to_write: long
    :return:

def download_device(headers, cookies, temp_target_disk,
                    device_url, lease_updater,
                    total_bytes_written, total_bytes_to_write):
    """ Download disk device of HttpNfcLease.info.deviceUrl
    list of devices
    :param headers: Request headers
    :type cookies: dict
    :param cookies: Request cookies (session)
    :type cookies: dict
    :param temp_target_disk: file name to write
    :type temp_target_disk: str
    :param device_url: deviceUrl.url
    :type device_url: str
    :param lease_updater:
    :type lease_updater: LeaseProgressUpdater
    :param total_bytes_written: Bytes written so far
    :type total_bytes_to_write: long
    :param total_bytes_to_write: VM unshared storage
    :type total_bytes_to_write: long
    :return:
    """
    with open(temp_target_disk, 'wb') as handle:
        response = requests.get(device_url, stream=True,
                                headers=headers,
                                cookies=cookies, verify=False)
        # response other than 200
        if not response.ok:
            response.raise_for_status()
        # keeping track of progress
        current_bytes_written = 0
        written_pct = 0
        print "Exporting from vCenter..."
        print ""
        last_time = 0
        for block in response.iter_content(chunk_size=1073741824):
            # filter out keep-alive new chunks
            if block:
                handle.write(block)
                handle.flush()
                os.fsync(handle.fileno())

            prev_pct = written_pct
            # Percent is unreliable as i can't find a way to know the size of the disk compressed
            current_bytes_written += len(block)
            # written_pct_float = (float(current_bytes_written + total_bytes_written) / float(total_bytes_to_write) * 100)
            # written_pct = int(written_pct_float)
            # Only do the bytes to gb conversion every 5 seconds
            if int(time.time()) > last_time + 3:
                dl_in_mb = (total_bytes_written + current_bytes_written) /1024 /1024
                last_time = int(time.time())

            print ("\r {} Mb Downloaded ".format(dl_in_mb)),

        #    if written_pct > prev_pct:
        #       lease_updater.progressPercent = int(written_pct)

    return current_bytes_written