def download_binaries(): "Parse config and download dse binaries (local)" # TODO since this is done locally on the cperf tool server, is there any possible concurrency # issue .. Or maybe we should simply keep a cache on each host? (Comment to remove) filename = os.path.join(dse_cache, dse_tarball) dse_url = config['dse_url'] username = config['dse_username'] if 'dse_username' in config else None password = config['dse_password'] if 'dse_password' in config else None url = urljoin(dse_url, dse_tarball) # Fetch the SHA of the tarball: download_file_contents returns the request.text of the url. # the sha file has the format '874c11f7634974fb41006d30199b55b59fd124db ?./dse-5.0.0-bin.tar.gz' # so we split on the space and then check that the sha hexidecimal is 40 characters correct_sha = download_file_contents(url+'.sha', username, password).split(" ")[0] assert(len(correct_sha) == 40), 'Failed to download sha file: {}'.format(correct_sha) if os.path.exists(filename): logger.info("Already in cache: {}".format(filename)) real_sha = digest_file(filename) if real_sha != correct_sha: logger.info("Invalid SHA for '{}'. It will be removed".format(filename)) os.remove(filename) else: return # Fetch the tarball: request = download_file(url, filename, username, password) real_sha = digest_file(filename) # Verify the SHA of the tarball: if real_sha != correct_sha: raise AssertionError( ('SHA of DSE tarball was not verified. should have been: ' '{correct_sha} but saw {real_sha}').format(correct_sha=correct_sha, real_sha=real_sha))
def download_binaries(): "Parse config and download dse binaries (local)" # TODO since this is done locally on the cperf tool server, is there any possible concurrency # issue .. Or maybe we should simply keep a cache on each host? (Comment to remove) filename = os.path.join(dse_cache, dse_tarball) dse_url = config['dse_url'] username = config['dse_username'] if 'dse_username' in config else None password = config['dse_password'] if 'dse_password' in config else None url = urljoin(dse_url, dse_tarball) # Fetch the SHA of the tarball: correct_sha = download_file_contents(url+'.sha', username, password).split(" ")[0] assert(len(correct_sha) == 64, 'Failed to download sha file: {}'.format(correct_sha)) if os.path.exists(filename): print("Already in cache: {}".format(filename)) real_sha = digest_file(filename) if real_sha != correct_sha: print("Invalid SHA for '{}'. It will be removed".format(filename)) os.remove(filename) else: return # Fetch the tarball: request = download_file(url, filename, username, password) real_sha = digest_file(filename) # Verify the SHA of the tarball: if real_sha != correct_sha: raise AssertionError( ('SHA of DSE tarball was not verified. should have been: ' '{correct_sha} but saw {real_sha}').format(correct_sha=correct_sha, real_sha=real_sha))
def download_binaries(): "Parse config and download dse binaries (local)" # TODO since this is done locally on the cperf tool server, is there any possible concurrency # issue .. Or maybe we should simply keep a cache on each host? (Comment to remove) filename = os.path.join(dse_cache_local, dse_tarball) dse_url = config['dse_url'] username = config['dse_username'] if 'dse_username' in config else None password = config['dse_password'] if 'dse_password' in config else None url = urljoin(dse_url, dse_tarball) # Fetch the SHA of the tarball: download_file_contents returns the request.text of the url. # the sha file has the format '874c11f7634974fb41006d30199b55b59fd124db ?./dse-5.0.0-bin.tar.gz' # so we split on the space and then check that the sha hexidecimal is 40 characters correct_sha = download_file_contents(url + '.sha', username, password).split(" ")[0] assert (len(correct_sha) == 40 ), 'Failed to download sha file: {}'.format(correct_sha) if os.path.exists(filename): logger.info("Already in cache: {}".format(filename)) real_sha = digest_file(filename) if real_sha != correct_sha: logger.info( "Invalid SHA for '{}'. It will be removed".format(filename)) os.remove(filename) else: return # Fetch the tarball: request = download_file(url, filename, username, password) real_sha = digest_file(filename) # Verify the SHA of the tarball: if real_sha != correct_sha: raise AssertionError( ('SHA of DSE tarball was not verified. should have been: ' '{correct_sha} but saw {real_sha}').format( correct_sha=correct_sha, real_sha=real_sha))
def download_binaries(): "Parse config and download dse binaries (local)" # TODO since this is done locally on the cperf tool server, is there any possible concurrency # issue .. Or maybe we should simply keep a cache on each host? (Comment to remove) filename = os.path.join(dse_cache, dse_tarball) dse_url = config['dse_url'] username = config['dse_username'] if 'dse_username' in config else None password = config['dse_password'] if 'dse_password' in config else None url = urljoin(dse_url, dse_tarball) # Fetch the SHA of the tarball: correct_sha = download_file_contents(url + '.sha', username, password).split(" ")[0] assert (len(correct_sha) == 64, 'Failed to download sha file: {}'.format(correct_sha)) if os.path.exists(filename): print("Already in cache: {}".format(filename)) real_sha = digest_file(filename) if real_sha != correct_sha: print("Invalid SHA for '{}'. It will be removed".format(filename)) os.remove(filename) else: return # Fetch the tarball: request = download_file(url, filename, username, password) real_sha = digest_file(filename) # Verify the SHA of the tarball: if real_sha != correct_sha: raise AssertionError( ('SHA of DSE tarball was not verified. should have been: ' '{correct_sha} but saw {real_sha}').format( correct_sha=correct_sha, real_sha=real_sha))