xk6-frostfs/scenarios/preset/resolve_containers_in_preset.py
Alejandro Lopez de6747fc0f [#14] Add s3 local loader
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
2023-04-13 13:00:38 +00:00

29 lines
No EOL
764 B
Python
Executable file

#!/usr/bin/python3
import argparse
import json
import requests
parser = argparse.ArgumentParser()
parser.add_argument('--endpoint', help='Endpoint of the S3 gateway')
parser.add_argument('--preset_file', help='JSON file path with s3 preset')
args = parser.parse_args()
def main():
with open(args.preset_file) as f:
preset_text = f.read()
preset = json.loads(preset_text)
containers = []
for bucket in preset.get('buckets'):
resp = requests.head(f'{args.endpoint}/{bucket}', verify=False)
containers.append(resp.headers['X-Container-Id'])
preset['containers'] = containers
with open(args.preset_file, 'w+') as f:
json.dump(preset, f, ensure_ascii=False, indent=2)
if __name__ == "__main__":
main()