-
Notifications
You must be signed in to change notification settings - Fork 28
/
ceph-create-folder.py
executable file
·44 lines (31 loc) · 1.16 KB
/
ceph-create-folder.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
38
39
40
41
42
43
44
#! /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')
parser.add_argument('--key-name',
dest='key_name',
action='store',
required=True,
help='the objects key name name')
args = parser.parse_args()
s3 = boto3.resource('s3',
endpoint_url=credentials['endpoint_url'],
aws_access_key_id=credentials['access_key'],
aws_secret_access_key=credentials['secret_key'])
bucket = s3.Bucket(args.bucket_name)
bucket.put_object(Bucket=args.bucket_name,
Key=args.key_name,
Body='')
if __name__ == '__main__':
main()