• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python auth.get_credentials函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_alt_creds

 def get_alt_creds(self):
     if self.isolated_creds.get('alt'):
         return self.isolated_creds.get('alt')
     creds = self.get_creds(1)
     alt_credential = auth.get_credentials(**creds)
     self.isolated_creds['alt'] = alt_credential
     return alt_credential
开发者ID:armando-migliaccio,项目名称:tempest-1,代码行数:7,代码来源:accounts.py


示例2: _clean_tenant

    def _clean_tenant(self, tenant):
        LOG.debug("Cleaning tenant:  %s " % tenant['name'])
        is_dry_run = self.options.dry_run
        dry_run_data = self.dry_run_data
        is_preserve = self.options.preserve_tempest_conf_objects
        tenant_id = tenant['id']
        tenant_name = tenant['name']
        tenant_data = None
        if is_dry_run:
            tenant_data = dry_run_data["_tenants_to_clean"][tenant_id] = {}
            tenant_data['name'] = tenant_name

        kwargs = {"username": CONF.identity.admin_username,
                  "password": CONF.identity.admin_password,
                  "tenant_name": tenant['name']}
        mgr = clients.Manager(credentials=auth.get_credentials(**kwargs))
        kwargs = {'data': tenant_data,
                  'is_dry_run': is_dry_run,
                  'saved_state_json': None,
                  'is_preserve': is_preserve,
                  'is_save_state': False,
                  'tenant_id': tenant_id}
        for service in self.tenant_services:
            svc = service(mgr, **kwargs)
            svc.run()
开发者ID:cameron-r,项目名称:tempest-configuration,代码行数:25,代码来源:cleanup.py


示例3: get_primary_creds

 def get_primary_creds(self):
     if self.credentials.get('primary'):
         return self.credentials.get('primary')
     creds = self._get_creds()
     primary_credential = auth.get_credentials(**creds)
     self.credentials['primary'] = primary_credential
     return primary_credential
开发者ID:BhargavaRegalla,项目名称:tempest,代码行数:7,代码来源:accounts.py


示例4: get_alt_creds

 def get_alt_creds(self):
     if self.credentials.get('alt'):
         return self.credentials.get('alt')
     creds = self._get_creds()
     alt_credential = auth.get_credentials(**creds)
     self.credentials['alt'] = alt_credential
     return alt_credential
开发者ID:BhargavaRegalla,项目名称:tempest,代码行数:7,代码来源:accounts.py


示例5: get_primary_creds

 def get_primary_creds(self):
     if self.isolated_creds.get('primary'):
         return self.isolated_creds.get('primary')
     creds = self.get_creds(0)
     primary_credential = auth.get_credentials(**creds)
     self.isolated_creds['primary'] = primary_credential
     return primary_credential
开发者ID:armando-migliaccio,项目名称:tempest-1,代码行数:7,代码来源:accounts.py


示例6: test_get_hash

 def test_get_hash(self):
     self.stubs.Set(http.ClosingHttp, "request", fake_identity._fake_v2_response)
     test_account_class = accounts.Accounts("test_name")
     hash_list = self._get_hash_list(self.test_accounts)
     test_cred_dict = self.test_accounts[3]
     test_creds = auth.get_credentials(**test_cred_dict)
     results = test_account_class.get_hash(test_creds)
     self.assertEqual(hash_list[3], results)
开发者ID:Mirantis,项目名称:tempest,代码行数:8,代码来源:test_accounts.py


示例7: test_credentials

 def test_credentials(self):
     return auth.get_credentials(
         username=self.test_user,
         user_id=self.user["id"],
         password=self.test_password,
         tenant_name=self.test_tenant,
         tenant_id=self.tenant["id"],
     )
开发者ID:cloudbase,项目名称:lis-tempest,代码行数:8,代码来源:base.py


示例8: test_get_hash

 def test_get_hash(self):
     self.stubs.Set(token_client.TokenClientJSON, 'raw_request',
                    fake_identity._fake_v2_response)
     test_account_class = accounts.Accounts('test_name')
     hash_list = self._get_hash_list(self.test_accounts)
     test_cred_dict = self.test_accounts[3]
     test_creds = auth.get_credentials(**test_cred_dict)
     results = test_account_class.get_hash(test_creds)
     self.assertEqual(hash_list[3], results)
开发者ID:CiscoSystems,项目名称:tempest,代码行数:9,代码来源:test_accounts.py


示例9: get_primary_creds

 def get_primary_creds(self):
     if self.isolated_creds.get('primary'):
         return self.isolated_creds.get('primary')
     if not self.use_default_creds:
         creds = self.get_creds(0)
         primary_credential = auth.get_credentials(**creds)
     else:
         primary_credential = auth.get_default_credentials('user')
     self.isolated_creds['primary'] = primary_credential
     return primary_credential
开发者ID:codybum,项目名称:OpenStackInAction,代码行数:10,代码来源:accounts.py


示例10: get_alt_creds

 def get_alt_creds(self):
     if self.isolated_creds.get('alt'):
         return self.isolated_creds.get('alt')
     if not self.use_default_creds:
         creds = self.get_creds(1)
         alt_credential = auth.get_credentials(**creds)
     else:
         alt_credential = auth.get_default_credentials('alt_user')
     self.isolated_creds['alt'] = alt_credential
     return alt_credential
开发者ID:codybum,项目名称:OpenStackInAction,代码行数:10,代码来源:accounts.py


示例11: create_trustor_and_roles

    def create_trustor_and_roles(self):
        # Get trustor project ID, use the admin project
        self.trustor_project_name = self.client.tenant_name
        self.trustor_project_id = self.get_tenant_by_name(
            self.trustor_project_name)['id']
        self.assertIsNotNone(self.trustor_project_id)

        # Create a trustor User
        self.trustor_username = data_utils.rand_name('user-')
        u_desc = self.trustor_username + 'description'
        u_email = self.trustor_username + '@testmail.xx'
        self.trustor_password = data_utils.rand_name('pass-')
        resp, user = self.client.create_user(
            self.trustor_username,
            description=u_desc,
            password=self.trustor_password,
            email=u_email,
            project_id=self.trustor_project_id)
        self.assertEqual(resp['status'], '201')
        self.trustor_user_id = user['id']

        # And two roles, one we'll delegate and one we won't
        self.delegated_role = data_utils.rand_name('DelegatedRole-')
        self.not_delegated_role = data_utils.rand_name('NotDelegatedRole-')

        resp, role = self.client.create_role(self.delegated_role)
        self.assertEqual(resp['status'], '201')
        self.delegated_role_id = role['id']

        resp, role = self.client.create_role(self.not_delegated_role)
        self.assertEqual(resp['status'], '201')
        self.not_delegated_role_id = role['id']

        # Assign roles to trustor
        self.client.assign_user_role(self.trustor_project_id,
                                     self.trustor_user_id,
                                     self.delegated_role_id)
        self.client.assign_user_role(self.trustor_project_id,
                                     self.trustor_user_id,
                                     self.not_delegated_role_id)

        # Get trustee user ID, use the demo user
        trustee_username = self.non_admin_client.user
        self.trustee_user_id = self.get_user_by_name(trustee_username)['id']
        self.assertIsNotNone(self.trustee_user_id)

        # Initialize a new client with the trustor credentials
        creds = auth.get_credentials(
            username=self.trustor_username,
            password=self.trustor_password,
            tenant_name=self.trustor_project_name)
        os = clients.Manager(
            credentials=creds,
            interface=self._interface)
        self.trustor_client = os.identity_v3_client
开发者ID:JasGit,项目名称:tempest,代码行数:55,代码来源:test_trusts.py


示例12: get_credentials

def get_credentials(fill_in=True, identity_version=None, **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()):
            kwargs['user_domain_name'] = CONF.identity.admin_domain_name
    return auth.get_credentials(fill_in=fill_in,
                                identity_version=identity_version,
                                **kwargs)
开发者ID:midokura,项目名称:tempest,代码行数:11,代码来源:cred_provider.py


示例13: _get_credentials

 def _get_credentials(self, user, tenant):
     if self.tempest_client:
         user_get = user.get
         tenant_get = tenant.get
     else:
         user_get = user.__dict__.get
         tenant_get = tenant.__dict__.get
     return auth.get_credentials(
         username=user_get('name'), user_id=user_get('id'),
         tenant_name=tenant_get('name'), tenant_id=tenant_get('id'),
         password=self.password)
开发者ID:Mirantis,项目名称:tempest,代码行数:11,代码来源:isolated_creds.py


示例14: 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()):
            # TODO(andreaf) It might be better here to use a dedicated config
            # option such as CONF.auth.tenant_isolation_domain_name
            params['user_domain_name'] = CONF.identity.admin_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:Dynavisor,项目名称:tempest,代码行数:18,代码来源:cred_provider.py


示例15: _verify_credentials

    def _verify_credentials(self, credentials_class, filled=True,
                            creds_dict=None):

        def _check(credentials):
            # Check the right version of credentials has been returned
            self.assertIsInstance(credentials, credentials_class)
            # Check the id attributes are filled in
            attributes = [x for x in credentials.ATTRIBUTES if (
                '_id' in x and x != 'domain_id')]
            for attr in attributes:
                if filled:
                    self.assertIsNotNone(getattr(credentials, attr))
                else:
                    self.assertIsNone(getattr(credentials, attr))

        if creds_dict is None:
            for ctype in auth.Credentials.TYPES:
                creds = auth.get_default_credentials(credential_type=ctype,
                                                     fill_in=filled)
                _check(creds)
        else:
            creds = auth.get_credentials(fill_in=filled, **creds_dict)
            _check(creds)
开发者ID:BhargavaRegalla,项目名称:tempest,代码行数:23,代码来源:test_credentials.py


示例16: _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:Dynavisor,项目名称:tempest,代码行数:6,代码来源:test_credentials.py


示例17: _get_credentials

 def _get_credentials(self, user, tenant):
     return auth.get_credentials(
         username=user['name'], user_id=user['id'],
         tenant_name=tenant['name'], tenant_id=tenant['id'],
         password=self.password)
开发者ID:hkumarmk,项目名称:tempest,代码行数:5,代码来源:isolated_creds.py


示例18: stress_openstack

def stress_openstack(tests, duration, max_runs=None, stop_on_error=False):
    """
    Workload driver. Executes an action function against a nova-cluster.
    """
    admin_manager = clients.AdminManager()

    ssh_user = CONF.stress.target_ssh_user
    ssh_key = CONF.stress.target_private_key_path
    logfiles = CONF.stress.target_logfiles
    log_check_interval = int(CONF.stress.log_check_interval)
    default_thread_num = int(CONF.stress.default_thread_number_per_action)
    if logfiles:
        controller = CONF.stress.target_controller
        computes = _get_compute_nodes(controller, ssh_user, ssh_key)
        for node in computes:
            do_ssh("rm -f %s" % logfiles, node, ssh_user, ssh_key)
    for test in tests:
        if test.get("use_admin", False):
            manager = admin_manager
        else:
            manager = clients.Manager()
        for p_number in moves.xrange(test.get("threads", default_thread_num)):
            if test.get("use_isolated_tenants", False):
                username = data_utils.rand_name("stress_user")
                tenant_name = data_utils.rand_name("stress_tenant")
                password = "pass"
                identity_client = admin_manager.identity_client
                tenant = identity_client.create_tenant(name=tenant_name)
                identity_client.create_user(username, password, tenant["id"], "email")
                creds = auth.get_credentials(username=username, password=password, tenant_name=tenant_name)
                manager = clients.Manager(credentials=creds)

            test_obj = importutils.import_class(test["action"])
            test_run = test_obj(manager, max_runs, stop_on_error)

            kwargs = test.get("kwargs", {})
            test_run.setUp(**dict(kwargs.iteritems()))

            LOG.debug("calling Target Object %s" % test_run.__class__.__name__)

            mp_manager = multiprocessing.Manager()
            shared_statistic = mp_manager.dict()
            shared_statistic["runs"] = 0
            shared_statistic["fails"] = 0

            p = multiprocessing.Process(target=test_run.execute, args=(shared_statistic,))

            process = {"process": p, "p_number": p_number, "action": test_run.action, "statistic": shared_statistic}

            processes.append(process)
            p.start()
    if stop_on_error:
        # NOTE(mkoderer): only the parent should register the handler
        signal.signal(signal.SIGCHLD, sigchld_handler)
    end_time = time.time() + duration
    had_errors = False
    try:
        while True:
            if max_runs is None:
                remaining = end_time - time.time()
                if remaining <= 0:
                    break
            else:
                remaining = log_check_interval
                all_proc_term = True
                for process in processes:
                    if process["process"].is_alive():
                        all_proc_term = False
                        break
                if all_proc_term:
                    break

            time.sleep(min(remaining, log_check_interval))
            if stop_on_error:
                if any([True for proc in processes if proc["statistic"]["fails"] > 0]):
                    break

            if not logfiles:
                continue
            if _has_error_in_logs(logfiles, computes, ssh_user, ssh_key, stop_on_error):
                had_errors = True
                break
    except KeyboardInterrupt:
        LOG.warning("Interrupted, going to print statistics and exit ...")

    if stop_on_error:
        signal.signal(signal.SIGCHLD, signal.SIG_DFL)
    terminate_all_processes()

    sum_fails = 0
    sum_runs = 0

    LOG.info("Statistics (per process):")
    for process in processes:
        if process["statistic"]["fails"] > 0:
            had_errors = True
        sum_runs += process["statistic"]["runs"]
        sum_fails += process["statistic"]["fails"]
        LOG.info(
            " Process %d (%s): Run %d actions (%d failed)"
#.........这里部分代码省略.........
开发者ID:CiscoSystems,项目名称:tempest,代码行数:101,代码来源:driver.py


示例19: __init__

 def __init__(self, interface='json', service=None):
     self.credentials = auth.get_credentials('identity_admin')
     super(AdminManager, self).__init__(
         self.credentials, interface, service)
开发者ID:accelazh,项目名称:magnetodb,代码行数:4,代码来源:clients_magnetodb.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python auth.get_default_credentials函数代码示例发布时间:2022-05-27
下一篇:
Python temperature.Temperature类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap