Python boto code for using S3 APIs with Ceph RadosGW
Environment
- Red Hat Ceph Storage 1.3
- RadosGW
- Python Boto
Issue
- Python boto code for using S3 APIs with Ceph RadosGW
- Boto code for upload, delete, download and list files/data.
Resolution
- Please follow Content from ceph.com is not included.s3-python link.
Diagnostic Steps
- Python boto code for uploading a file "linux-3.17.4.tar.xz" in to a bucket.
import boto
import boto.s3.connection
import boto.s3
AWS_ACCESS_KEY_ID = '8IXSVYVE8XN7UYKD1V38'
AWS_SECRET_ACCESS_KEY = '7bAd1Zv0MMxbfECWYT1pKikfs0FxOZurxc8SSG0x'
bucket_name = AWS_ACCESS_KEY_ID.lower() + '-dump'
conn = boto.connect_s3(
aws_access_key_id = AWS_ACCESS_KEY_ID,
aws_secret_access_key = AWS_SECRET_ACCESS_KEY,
host = 'rgw1.redhat.com',
is_secure=False,
calling_format = boto.s3.connection.OrdinaryCallingFormat(),
)
bucket = conn.create_bucket(bucket_name,
location=boto.s3.connection.Location.DEFAULT)
testfile = "linux-3.17.4.tar.xz"
print 'Uploading %s to Amazon S3 bucket %s' % \
(testfile, bucket_name)
import sys
def percent_cb(complete, total):
sys.stdout.write('.')
sys.stdout.flush()
from boto.s3.key import Key
k = Key(bucket)
k.key = 'my test file'
k.set_contents_from_filename(testfile,
cb=percent_cb, num_cb=10)
Disclaimer : This is just a test code please check with python developers before using it in production.
SBR
Product(s)
Category
Tags
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.