forked from ronald-d-dilley-jr/ceph-s3-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathceph-list-objects.py
executable file
·37 lines (25 loc) · 924 Bytes
/
ceph-list-objects.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /usr/bin/env python3
import os
import sys
from argparse import ArgumentParser
import json
import boto3
with open('credentials.json', 'r') as fd:
credentials = json.loads(fd.read())
def main():
parser = ArgumentParser(description='Creates a bucket')
parser.add_argument('--bucket-name',
dest='bucket_name',
action='store',
required=True,
help='the name of the bucket to create')
args = parser.parse_args()
s3 = boto3.client('s3',
endpoint_url=credentials['endpoint_url'],
aws_access_key_id=credentials['access_key'],
aws_secret_access_key=credentials['secret_key'])
response = s3.list_objects_v2(Bucket=args.bucket_name)
for item in response['Contents']:
print(item['Key'])
if __name__ == '__main__':
main()