Skip to content

Instantly share code, notes, and snippets.

@azizmb
Last active January 4, 2016 22:09
Show Gist options
  • Save azizmb/8686059 to your computer and use it in GitHub Desktop.
Save azizmb/8686059 to your computer and use it in GitHub Desktop.
Simple shell which initializes a connection to Rackspace CloudFiles
import argparse
import cloudfiles
from cloudfiles.connection import Connection
AUTH_URLS = ['uk_authurl', 'us_authurl']
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("rcloud_user", help="the rcloud user to use")
parser.add_argument("rcloud_key", help="the rcloud api key to use")
parser.add_argument("-s", "--servicenet", help="whether to use servicenet",
action="store_true")
parser.add_argument("-a", "--authurl", help="which authurl to use",
choices=AUTH_URLS, default=AUTH_URLS[0])
args = parser.parse_args()
con = Connection(
username=args.rcloud_user,
api_key=args.rcloud_key,
authurl=getattr(cloudfiles, args.authurl),
servicenet=args.servicenet
)
print 'Connection object is available as con'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment