[#104] s3local: Use default HTTP client instead of requests
All checks were successful
All checks were successful
`requests` lib is not default, so it can be unavailable. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
48a95bc50b
commit
3574361f2e
1 changed files with 7 additions and 3 deletions
|
@ -2,7 +2,8 @@
|
|||
|
||||
import argparse
|
||||
import json
|
||||
import requests
|
||||
import http.client
|
||||
import ssl
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--endpoint', help='Endpoint of the S3 gateway')
|
||||
|
@ -16,10 +17,13 @@ def main():
|
|||
|
||||
preset = json.loads(preset_text)
|
||||
|
||||
conn = http.client.HTTPSConnection(args.endpoint, context = ssl._create_unverified_context())
|
||||
containers = []
|
||||
for bucket in preset.get('buckets'):
|
||||
resp = requests.head(f'{args.endpoint}/{bucket}', verify=False)
|
||||
containers.append(resp.headers['X-Container-Id'])
|
||||
conn.request("HEAD", f'/{bucket}')
|
||||
response = conn.getresponse()
|
||||
containers.append(response.getheader('X-Container-Id'))
|
||||
response.read()
|
||||
|
||||
preset['containers'] = containers
|
||||
with open(args.preset_file, 'w+') as f:
|
||||
|
|
Loading…
Reference in a new issue