[#104] s3local: Use default HTTP client instead of requests

`requests` lib is not default, so it can be unavailable.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-11-17 14:33:32 +03:00
parent 48a95bc50b
commit 3574361f2e

View file

@ -2,7 +2,8 @@
import argparse import argparse
import json import json
import requests import http.client
import ssl
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--endpoint', help='Endpoint of the S3 gateway') parser.add_argument('--endpoint', help='Endpoint of the S3 gateway')
@ -16,10 +17,13 @@ def main():
preset = json.loads(preset_text) preset = json.loads(preset_text)
conn = http.client.HTTPSConnection(args.endpoint, context = ssl._create_unverified_context())
containers = [] containers = []
for bucket in preset.get('buckets'): for bucket in preset.get('buckets'):
resp = requests.head(f'{args.endpoint}/{bucket}', verify=False) conn.request("HEAD", f'/{bucket}')
containers.append(resp.headers['X-Container-Id']) response = conn.getresponse()
containers.append(response.getheader('X-Container-Id'))
response.read()
preset['containers'] = containers preset['containers'] = containers
with open(args.preset_file, 'w+') as f: with open(args.preset_file, 'w+') as f: