-
Notifications
You must be signed in to change notification settings - Fork 28
/
ceph-upload-file.py
executable file
·48 lines (35 loc) · 1.33 KB
/
ceph-upload-file.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
45
46
47
48
#! /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')
parser.add_argument('--file-name',
dest='file_name',
action='store',
required=True,
help='the file to upload')
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.upload_file(Filename=args.file_name,
Key=args.key_name)
if __name__ == '__main__':
main()