Created
August 1, 2013 03:58
-
-
Save jburwell/6128312 to your computer and use it in GitHub Desktop.
Test harness for the s3xen plugin. In order to use it, comment out the XenAPIPlugin imports, make the log method only print the message, and the if block at the bottom pass. Finally, create a symlink in the same directory named s3xen.py to the s3xen script.
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/env python | |
from s3xen import S3Client | |
import traceback | |
S3_CREDENTIALS = { | |
'access_key': '<insert access key here>', | |
'secret_key': '<insert secret key here>', | |
'end_point' : 's3.amazonaws.com', | |
'use_https' : "true" | |
} | |
def put(credentials): | |
s3 = S3Client(credentials['access_key'], credentials['secret_key'], credentials['end_point'], credentials['use_https']) | |
s3.put('jsb-cloudstack-templates', 'test-image.jpg', '/Users/jburwell/tmp/test-image.jpg') | |
def get(credentials): | |
s3 = S3Client(credentials['access_key'], credentials['secret_key'], credentials['end_point'], credentials['use_https']) | |
s3.get('jsb-cloudstack-templates', 'test-image.jpg', '/Users/jburwell/tmp/test-image-get.jpg') | |
def delete(credentials): | |
s3 = S3Client(credentials['access_key'], credentials['secret_key'], credentials['end_point'], credentials['use_https']) | |
s3.delete('jsb-cloudstack-templates', 'test-image.jpg') | |
def main(): | |
try: | |
put(S3_CREDENTIALS) | |
get(S3_CREDENTIALS) | |
delete(S3_CREDENTIALS) | |
except Exception, e: | |
print traceback.print_exc() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment