Created
July 13, 2018 17:26
-
-
Save blemmenes/cd8254c18aed9aad4c4dbf9a18bc0187 to your computer and use it in GitHub Desktop.
Simple script to get usage info for testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import requests | |
import json | |
import argparse | |
from awsauth import S3Auth | |
def parse_args(): | |
parser = argparse.ArgumentParser( | |
description='RADOSGW address S3 access_key and secret_key' | |
) | |
parser.add_argument( | |
'-H', '--host', | |
required=False, | |
help='Server URL for the RADOSGW api' | |
) | |
parser.add_argument( | |
'-a', '--access_key', | |
required=False, | |
help='S3 access key' | |
) | |
parser.add_argument( | |
'-s', '--secret_key', | |
required=False, | |
help='S3 secrest key' | |
) | |
parser.add_argument( | |
'-u', '--uid', | |
required=False, | |
help='RADOSGW UID' | |
) | |
return parser.parse_args() | |
args = parse_args() | |
server = args.host | |
aws_key = args.access_key | |
secret = args.secret_key | |
uid = args.uid | |
url = 'https://%s/admin/usage?format=json&show-summary=False&uid=%s' % (server, uid) | |
response = requests.get(url, auth=S3Auth(aws_key, secret, server)) | |
#print response | |
print json.dumps(response.json(), sort_keys=True, indent=4, separators=(',', ':')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment