Exemple #1
0
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

    '''
    if trust_id:
        proxyclient = k.client_for_proxy_user(username, password, trust_id)
        return client_from_token(proxyclient.auth_token)
    else:
        return swiftclient.Connection(auth_version='2.0',
                                      cacert=CONF.swift.ca_file,
                                      insecure=CONF.swift.api_insecure,
                                      authurl=su.retrieve_auth_url(),
                                      user=username,
                                      key=password,
                                      tenant_name=sh.retrieve_tenant())
Exemple #2
0
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

    '''
    if trust_id:
        proxyauth = k.auth_for_proxy(username, password, trust_id)
        return client_from_token(k.token_from_auth(proxyauth))
    else:
        return swiftclient.Connection(
            auth_version='2.0',
            cacert=CONF.swift.ca_file,
            insecure=CONF.swift.api_insecure,
            authurl=su.retrieve_auth_url(),
            user=username,
            key=password,
            tenant_name=sh.retrieve_tenant(),
            retries=CONF.retries.retries_number,
            retry_on_ratelimit=True,
            starting_backoff=CONF.retries.retry_after,
            max_backoff=CONF.retries.retry_after)
Exemple #3
0
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

    '''
    if trust_id:
        proxyauth = k.auth_for_proxy(username, password, trust_id)
        return client_from_token(k.token_from_auth(proxyauth))
    else:
        return swiftclient.Connection(
            auth_version='2.0',
            cacert=CONF.swift.ca_file,
            insecure=CONF.swift.api_insecure,
            authurl=su.retrieve_auth_url(CONF.keystone.endpoint_type),
            user=username,
            key=password,
            tenant_name=sh.retrieve_tenant(),
            retries=CONF.retries.retries_number,
            retry_on_ratelimit=True,
            starting_backoff=CONF.retries.retry_after,
            max_backoff=CONF.retries.retry_after)
Exemple #4
0
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)
Exemple #5
0
def _get_conn(user, password):
    return swiftclient.Connection(su.retrieve_auth_url(),
                                  user,
                                  password,
                                  tenant_name=swift_helper.retrieve_tenant(),
                                  auth_version="2.0")
Exemple #6
0
def _get_conn(user, password):
    return swiftclient.Connection(su.retrieve_auth_url(),
                                  user,
                                  password,
                                  tenant_name=swift_helper.retrieve_tenant(),
                                  auth_version="2.0")