def client_from_token(token): '''return a Swift client authenticated from a token.''' return swiftclient.Connection(auth_version='2.0', cacert=CONF.swift.ca_file, insecure=CONF.swift.api_insecure, preauthurl=su.retrieve_preauth_url(), preauthtoken=token)
def client(username, password, trust_id=None): '''return a Swift client This will return a Swift client for the specified username scoped to the current context project, unless a trust identifier is specified. If a trust identifier is present then the Swift client will be created based on a preauthorized token generated by the username scoped to the trust identifier. :param username: The username for the Swift client :param password: The password associated with the username :param trust_id: A trust identifier for scoping the username (optional) :returns: A Swift client object ''' client_kwargs = dict(auth_version='2.0') if trust_id: proxyclient = k.client_for_proxy_user(username, password, trust_id) client_kwargs.update(preauthurl=su.retrieve_preauth_url(), preauthtoken=proxyclient.auth_token) else: client_kwargs.update(authurl=su.retrieve_auth_url(), user=username, key=password, tenant_name=sh.retrieve_tenant()) return swiftclient.Connection(**client_kwargs)
def _get_conn_for_proxy_user(configs): preauthurl = su.retrieve_preauth_url() proxyclient = k.client_for_proxy_user(configs['proxy_username'], configs['proxy_password'], configs['proxy_trust_id']) return swiftclient.Connection(preauthurl=preauthurl, preauthtoken=proxyclient.auth_token, auth_version='2.0')
def client_from_token(token): '''return a Swift client authenticated from a token.''' return swiftclient.Connection(auth_version='2.0', cacert=CONF.swift.ca_file, insecure=CONF.swift.api_insecure, preauthurl=su.retrieve_preauth_url(), preauthtoken=token, retries=CONF.retries.retries_number, retry_on_ratelimit=True, starting_backoff=CONF.retries.retry_after, max_backoff=CONF.retries.retry_after)