当前位置: 首页>>代码示例>>Python>>正文


Python auth.get_credentials函数代码示例

本文整理汇总了Python中tempest.lib.auth.get_credentials函数的典型用法代码示例。如果您正苦于以下问题:Python get_credentials函数的具体用法?Python get_credentials怎么用?Python get_credentials使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_credentials函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_credentials

def get_credentials(fill_in=True, identity_version=None, **kwargs):
    """Get credentials from dict based on config

    Wrapper around auth.get_credentials to use the configured identity version
    if none is specified.

    :param fill_in: If True, a request to the Token API is submitted, and the
                    credential object is filled in with all names and IDs from
                    the token API response.
    :param identity_version: The identity version to talk to and the type of
                             credentials object to be created. 'v2' or 'v3'.
    :param kwargs: Attributes to be used to build the Credentials object.
    :returns: An object of a sub-type of `auth.Credentials`
    """
    params = dict(config.service_client_config(), **kwargs)
    identity_version = identity_version or CONF.identity.auth_version
    # In case of "v3" add the domain from config if not specified
    # To honour the "default_credentials_domain_name", if not domain
    # field is specified at all, add it the credential dict.
    if identity_version == 'v3':
        domain_fields = set(x for x in auth.KeystoneV3Credentials.ATTRIBUTES
                            if 'domain' in x)
        if not domain_fields.intersection(kwargs.keys()):
            domain_name = CONF.auth.default_credentials_domain_name
            # NOTE(andreaf) Setting domain_name implicitly sets user and
            # project domain names, if they are None
            params['domain_name'] = domain_name

        auth_url = CONF.identity.uri_v3
    else:
        auth_url = CONF.identity.uri
    return auth.get_credentials(auth_url,
                                fill_in=fill_in,
                                identity_version=identity_version,
                                **params)
开发者ID:masayukig,项目名称:tempest,代码行数:35,代码来源:credentials_factory.py

示例2: get_credentials

 def get_credentials(self, user, project, password):
     # User and project already include both ID and name here,
     # so there's no need to use the fill_in mode
     return auth.get_credentials(
         auth_url=None,
         fill_in=False,
         identity_version='v2',
         username=user['name'], user_id=user['id'],
         tenant_name=project['name'], tenant_id=project['id'],
         password=password)
开发者ID:Hybrid-Cloud,项目名称:tempest,代码行数:10,代码来源:cred_client.py

示例3: test_get_hash

 def test_get_hash(self):
     self.stubs.Set(token_client.TokenClient, 'raw_request',
                    fake_identity._fake_v2_response)
     test_account_class = preprov_creds.PreProvisionedCredentialProvider(
         **self.fixed_params)
     hash_list = self._get_hash_list(self.test_accounts)
     test_cred_dict = self.test_accounts[3]
     test_creds = auth.get_credentials(fake_identity.FAKE_AUTH_URL,
                                       **test_cred_dict)
     results = test_account_class.get_hash(test_creds)
     self.assertEqual(hash_list[3], results)
开发者ID:Hybrid-Cloud,项目名称:hybrid-tempest,代码行数:11,代码来源:test_preprov_creds.py

示例4: test_get_hash

 def test_get_hash(self):
     # Test with all accounts to make sure we try all combinations
     # and hide no race conditions
     hash_index = 0
     for test_cred_dict in self.test_accounts:
         test_account_class = preprov_creds.PreProvisionedCredentialProvider(**self.fixed_params)
         hash_list = self._get_hash_list(self.test_accounts)
         test_creds = auth.get_credentials(
             fake_identity.FAKE_AUTH_URL, identity_version=self.fixed_params["identity_version"], **test_cred_dict
         )
         results = test_account_class.get_hash(test_creds)
         self.assertEqual(hash_list[hash_index], results)
         hash_index += 1
开发者ID:redhat-openstack,项目名称:tempest,代码行数:13,代码来源:test_preprov_creds.py

示例5: get_credentials

def get_credentials(fill_in=True, identity_version=None, **kwargs):
    params = dict(DEFAULT_PARAMS, **kwargs)
    identity_version = identity_version or CONF.identity.auth_version
    # In case of "v3" add the domain from config if not specified
    if identity_version == "v3":
        domain_fields = set(x for x in auth.KeystoneV3Credentials.ATTRIBUTES if "domain" in x)
        if not domain_fields.intersection(kwargs.keys()):
            domain_name = CONF.auth.default_credentials_domain_name
            params["user_domain_name"] = domain_name

        auth_url = CONF.identity.uri_v3
    else:
        auth_url = CONF.identity.uri
    return auth.get_credentials(auth_url, fill_in=fill_in, identity_version=identity_version, **params)
开发者ID:mshalamov,项目名称:tempest,代码行数:14,代码来源:credentials_factory.py

示例6: get_credentials

 def get_credentials(self, user, project, password):
     # User, project and domain already include both ID and name here,
     # so there's no need to use the fill_in mode.
     # NOTE(andreaf) We need to set all fields in the returned credentials.
     # Scope is then used to pick only those relevant for the type of
     # token needed by each service client.
     return auth.get_credentials(
         auth_url=None,
         fill_in=False,
         identity_version='v3',
         username=user['name'], user_id=user['id'],
         project_name=project['name'], project_id=project['id'],
         password=password,
         project_domain_id=self.creds_domain['id'],
         project_domain_name=self.creds_domain['name'],
         domain_id=self.creds_domain['id'],
         domain_name=self.creds_domain['name'])
开发者ID:fnaval,项目名称:tempest,代码行数:17,代码来源:cred_client.py

示例7: _wrap_creds_with_network

 def _wrap_creds_with_network(self, hash):
     creds_dict = self.hash_dict["creds"][hash]
     # Make sure a domain scope if defined for users in case of V3
     # Make sure a tenant is available in case of V2
     creds_dict = self._extend_credentials(creds_dict)
     # This just builds a Credentials object, it does not validate
     # nor fill  with missing fields.
     credential = auth.get_credentials(
         auth_url=None, fill_in=False, identity_version=self.identity_version, **creds_dict
     )
     net_creds = cred_provider.TestResources(credential)
     net_clients = clients.Manager(credentials=credential)
     compute_network_client = net_clients.compute_networks_client
     net_name = self.hash_dict["networks"].get(hash, None)
     try:
         network = fixed_network.get_network_from_name(net_name, compute_network_client)
     except exceptions.InvalidTestResource:
         network = {}
     net_creds.set_resources(network=network)
     return net_creds
开发者ID:mshalamov,项目名称:tempest,代码行数:20,代码来源:preprov_creds.py

示例8: get_client_manager

def get_client_manager(os_auth_url, username, password,
                       tenant_name=None,
                       identity_version='v2',
                       **kwargs):
    halt = kwargs.pop('halt', False)
    verbose = kwargs.pop('verbose', True)
    cm_conf = dict(
        username=username,
        password=password,
        identity_version=identity_version,
        fill_in=True,
        tenant_name=(tenant_name if tenant_name else username),
        disable_ssl_certificate_validation=True)
    cmgr = None
    cm_conf.update(kwargs)
    if halt:
        import pdb;
        pdb.set_trace()
    l_creds = l_auth.get_credentials(os_auth_url, **cm_conf)
    cmgr = clients.Manager(l_creds, os_auth_url, verbose=verbose)
    return cmgr
开发者ID:gravity-tak,项目名称:interactive-tempest,代码行数:21,代码来源:client_manager.py

示例9: get_credentials

 def get_credentials(self, conf, username, tenant_name, password,
                     identity_version='v2'):
     creds_kwargs = {'username': username,
                     'password': password}
     if identity_version == 'v3':
         creds_kwargs.update({'project_name': tenant_name,
                              'domain_name': 'Default',
                              'user_domain_name': 'Default'})
     else:
         creds_kwargs.update({'tenant_name': tenant_name})
     return auth.get_credentials(
         auth_url=None,
         fill_in=False,
         identity_version=identity_version,
         disable_ssl_certificate_validation=conf.get_defaulted(
             'identity',
             'disable_ssl_certificate_validation'),
         ca_certs=conf.get_defaulted(
             'identity',
             'ca_certificates_file'),
         **creds_kwargs)
开发者ID:bkopilov,项目名称:tempest,代码行数:21,代码来源:config_tempest.py

示例10: get_credentials

def get_credentials(fill_in=True, identity_version=None, **kwargs):
    params = dict(DEFAULT_PARAMS, **kwargs)
    identity_version = identity_version or CONF.identity.auth_version
    # In case of "v3" add the domain from config if not specified
    # To honour the "default_credentials_domain_name", if not domain
    # field is specified at all, add it the credential dict.
    if identity_version == 'v3':
        domain_fields = set(x for x in auth.KeystoneV3Credentials.ATTRIBUTES
                            if 'domain' in x)
        if not domain_fields.intersection(kwargs.keys()):
            domain_name = CONF.auth.default_credentials_domain_name
            # NOTE(andreaf) Setting domain_name implicitly sets user and
            # project domain names, if they are None
            params['domain_name'] = domain_name

        auth_url = CONF.identity.uri_v3
    else:
        auth_url = CONF.identity.uri
    return auth.get_credentials(auth_url,
                                fill_in=fill_in,
                                identity_version=identity_version,
                                **params)
开发者ID:WoolenWang,项目名称:tempest,代码行数:22,代码来源:credentials_factory.py

示例11: _verify_credentials

 def _verify_credentials(self, credentials_class, creds_dict, filled=True):
     creds = auth.get_credentials(
         fake_identity.FAKE_AUTH_URL, fill_in=filled, identity_version=self.identity_version, **creds_dict
     )
     self._check(creds, credentials_class, filled)
开发者ID:mshalamov,项目名称:tempest,代码行数:5,代码来源:test_credentials.py


注:本文中的tempest.lib.auth.get_credentials函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。