def sync_account(self): """Sync a single account with url/tok to dest_url/dest_tok.""" orig_storage_cnx = self.get_cloudfiles_auth_orig() dest_auth_url = get_config('auth', 'keystone_dest') cfg = get_config('auth', 'keystone_dest_credentials') (orig_user, orig_password, orig_tenant) = cfg.split(':') dest_storage_url = get_config('auth', 'dest_storage_url') # we assume orig and dest passwd are the same obv synchronized. dst_st_url, dest_token = self.get_swift_auth( dest_auth_url, orig_tenant, orig_user, orig_password) dest_storage_cnx = swiftclient.http_connection(dest_storage_url) try: orig_containers = orig_storage_cnx.cloudfiles.get_all_containers() dest_account_headers, dest_containers = ( swiftclient.get_account(None, dest_token, http_conn=dest_storage_cnx, full_listing=True)) except(swiftclient.client.ClientException), e: logging.info("error getting account: %s" % ( e.http_reason)) return
def __init__(self): self.concurrency = int(utils.get_config( "concurrency", "sync_swift_client_concurrency")) self.sync_object = cloudfilesswiftsync.objects.sync_object self.delete_object = cloudfilesswiftsync.objects.delete_object cfg = get_config('database_logging', 'postgres_connection_string') (db,user,host,password) = cfg.split(':') self.postges_connection = psycopg2.connect('{0} {1} {2} {3}'.format(db,user,host,password))
def get_cloudfiles_auth_orig(self): """Get cloudfiles cnx from config.""" cfg = get_config('auth', 'cloudfiles_origin_credentials') (username, apikey, region) = cfg.split(':') pyrax.set_setting('identity_type', 'rackspace') pyrax.set_credentials(username=username,api_key=apikey,region=region) return pyrax