コード例 #1
0
ファイル: swift.py プロジェクト: uladz/sahara
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)
コード例 #2
0
ファイル: swift.py プロジェクト: mastermind1981/sahara-1
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)
コード例 #3
0
ファイル: swift.py プロジェクト: suriya2612/sahara
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)
コード例 #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

    '''
    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())
コード例 #5
0
ファイル: swift_helper.py プロジェクト: qinweiwei/sahara
def get_swift_configs():
    configs = x.load_hadoop_xml_defaults('swift/resources/conf-template.xml')
    for conf in configs:
        if conf['name'] == HADOOP_SWIFT_AUTH_URL:
            conf['value'] = su.retrieve_auth_url() + "tokens/"
        if conf['name'] == HADOOP_SWIFT_TENANT:
            conf['value'] = retrieve_tenant()

    result = [cfg for cfg in configs if cfg['value']]
    LOG.info("Swift would be integrated with the following "
             "params: %s", result)
    return result
コード例 #6
0
ファイル: swift_helper.py プロジェクト: snowind/sahara
def get_swift_configs():
    configs = x.load_hadoop_xml_defaults("swift/resources/conf-template.xml")
    for conf in configs:
        if conf["name"] == HADOOP_SWIFT_AUTH_URL:
            conf["value"] = su.retrieve_auth_url() + "tokens/"
        if conf["name"] == HADOOP_SWIFT_TENANT:
            conf["value"] = retrieve_tenant()
        if CONF.os_region_name and conf["name"] == HADOOP_SWIFT_REGION:
            conf["value"] = CONF.os_region_name

    result = [cfg for cfg in configs if cfg["value"]]
    LOG.info(_LI("Swift would be integrated with the following " "params: {result}").format(result=result))
    return result
コード例 #7
0
ファイル: swift_helper.py プロジェクト: madar010/mad
def get_swift_configs():
    configs = x.load_hadoop_xml_defaults('swift/resources/conf-template.xml')
    for conf in configs:
        if conf['name'] == HADOOP_SWIFT_AUTH_URL:
            conf['value'] = su.retrieve_auth_url() + "auth/tokens/"
        if conf['name'] == HADOOP_SWIFT_TENANT:
            conf['value'] = retrieve_tenant()
        if CONF.os_region_name and conf['name'] == HADOOP_SWIFT_REGION:
            conf['value'] = CONF.os_region_name

    result = [cfg for cfg in configs if cfg['value']]
    LOG.info("Swift would be integrated with the following "
             "params: {result}".format(result=result))
    return result
コード例 #8
0
ファイル: swift_helper.py プロジェクト: zizzhang/sahara
def get_swift_configs():
    configs = x.load_hadoop_xml_defaults('swift/resources/conf-template.xml')
    for conf in configs:
        if conf['name'] == HADOOP_SWIFT_AUTH_URL:
            conf['value'] = su.retrieve_auth_url() + "auth/tokens/"
        if conf['name'] == HADOOP_SWIFT_TENANT:
            conf['value'] = retrieve_tenant()
        if CONF.os_region_name and conf['name'] == HADOOP_SWIFT_REGION:
            conf['value'] = CONF.os_region_name
        if conf['name'] == HADOOP_SWIFT_DOMAIN_NAME:
            # NOTE(jfreud): Don't be deceived here... Even though there is an
            # attribute provided by context called domain_name, it is used for
            # domain scope, and hadoop-swiftfs always authenticates using
            # project scope. The purpose of the setting below is to override
            # the default value for project domain and user domain, domain id
            # as 'default', which may not always be correct.
            # TODO(jfreud): When hadoop-swiftfs allows it, stop hoping that
            # project_domain_name is always equal to user_domain_name.
            conf['value'] = context.current().project_domain_name

    result = [cfg for cfg in configs if cfg['value']]
    LOG.info("Swift would be integrated with the following "
             "params: {result}".format(result=result))
    return result
コード例 #9
0
ファイル: internal_swift.py プロジェクト: hongbin/sahara
def _get_conn(user, password):
    return swiftclient.Connection(su.retrieve_auth_url(),
                                  user,
                                  password,
                                  tenant_name=swift_helper.retrieve_tenant(),
                                  auth_version="2.0")
コード例 #10
0
ファイル: internal_swift.py プロジェクト: esala116/sahara
def _get_conn(user, password):
    return swiftclient.Connection(su.retrieve_auth_url(),
                                  user,
                                  password,
                                  tenant_name=CONF.os_admin_tenant_name,
                                  auth_version="2.0")
コード例 #11
0
ファイル: test_utils.py プロジェクト: B-Rich/sahara
 def _assert(uri):
     self.setup_context(auth_uri=uri)
     self.assertEqual(correct, utils.retrieve_auth_url())
コード例 #12
0
ファイル: test_utils.py プロジェクト: uladz/sahara
 def _assert(uri):
     url_for_mock.return_value = uri
     self.assertEqual(correct, utils.retrieve_auth_url())
コード例 #13
0
ファイル: test_utils.py プロジェクト: AlexanderYAPPO/sahara
 def _assert(uri):
     url_for_mock.return_value = uri
     self.assertEqual(correct, utils.retrieve_auth_url())
コード例 #14
0
ファイル: swift_utils.py プロジェクト: wuhsh/sahara
def retrieve_auth_url(endpoint_type="publicURL", **kwargs):
    return utils.retrieve_auth_url(endpoint_type)
コード例 #15
0
 def _assert(uri):
     self.setup_context(auth_uri=uri)
     self.assertEqual(correct, utils.retrieve_auth_url())
コード例 #16
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")
コード例 #17
0
def _get_conn(user, password):
    return swiftclient.Connection(su.retrieve_auth_url(),
                                  user,
                                  password,
                                  tenant_name=CONF.os_admin_tenant_name,
                                  auth_version="2.0")