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

Python auth.get_default_credentials函数代码示例

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

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



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

示例1: _get_object_storage_client

    def _get_object_storage_client(self, credentials):
        if not CONF.service_available.swift:
            return None
        import swiftclient
        auth_url = CONF.identity.uri
        # add current tenant to swift operator role group.
        admin_credentials = auth.get_default_credentials('identity_admin')
        keystone_admin = self._get_identity_client(admin_credentials)

        # enable test user to operate swift by adding operator role to him.
        roles = keystone_admin.roles.list()
        operator_role = CONF.object_storage.operator_role
        member_role = [role for role in roles if role.name == operator_role][0]
        # NOTE(maurosr): This is surrounded in the try-except block cause
        # neutron tests doesn't have tenant isolation.
        try:
            keystone_admin.roles.add_user_role(self.identity_client.user_id,
                                               member_role.id,
                                               self.identity_client.tenant_id)
        except keystoneclient.exceptions.Conflict:
            pass

        endpoint_type = CONF.object_storage.endpoint_type
        os_options = {'endpoint_type': endpoint_type}
        return swiftclient.Connection(auth_url, credentials.username,
                                      credentials.password,
                                      tenant_name=credentials.tenant_name,
                                      auth_version='2',
                                      os_options=os_options)
开发者ID:BhargavaRegalla,项目名称:tempest,代码行数:29,代码来源:clients.py


示例2: __init__

 def __init__(self):
     os = clients.Manager(
         auth.get_default_credentials('user', fill_in=False))
     self.images_client = os.images_client
     self.flavors_client = os.flavors_client
     self.image_pattern = CONF.input_scenario.image_regex
     self.flavor_pattern = CONF.input_scenario.flavor_regex
开发者ID:hkumarmk,项目名称:tempest,代码行数:7,代码来源:utils.py


示例3: __init__

 def __init__(self):
     # Load configuration items
     self.ssh_users = json.loads(CONF.input_scenario.ssh_user_regex)
     self.non_ssh_image_pattern = \
         CONF.input_scenario.non_ssh_image_regex
     # Setup clients
     ocm = clients.OfficialClientManager(
         auth.get_default_credentials('user'))
     self.client = ocm.compute_client
开发者ID:BhargavaRegalla,项目名称:tempest,代码行数:9,代码来源:utils.py


示例4: 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


示例5: 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


示例6: _get_roles

    def _get_roles(self):
        admin_credentials = auth.get_default_credentials('identity_admin')
        keystone_admin = self._get_identity_client(admin_credentials)

        username = self.credentials.username
        tenant_name = self.credentials.tenant_name
        user_id = keystone_admin.users.find(name=username).id
        tenant_id = keystone_admin.tenants.find(name=tenant_name).id

        roles = keystone_admin.roles.roles_for_user(
            user=user_id, tenant=tenant_id)

        return [r.name for r in roles]
开发者ID:BhargavaRegalla,项目名称:tempest,代码行数:13,代码来源:clients.py


示例7: _get_admin_clients

 def _get_admin_clients(self):
     """
     Returns a tuple with instances of the following admin clients (in this
     order):
         identity
         network
     """
     if self.tempest_client:
         os = clients.AdminManager(interface=self.interface)
     else:
         os = clients.OfficialClientManager(
             auth.get_default_credentials('identity_admin')
         )
     return os.identity_client, os.network_client
开发者ID:Mirantis,项目名称:tempest,代码行数:14,代码来源:isolated_creds.py


示例8: __init__

    def __init__(self, credentials=None):
        """
        We allow overriding of the credentials used within the various
        client classes managed by the Manager object. Left as None, the
        standard username/password/tenant_name[/domain_name] is used.

        :param credentials: Override of the credentials
        """
        self.auth_version = CONF.identity.auth_version
        if credentials is None:
            self.credentials = auth.get_default_credentials('user')
        else:
            self.credentials = credentials
        # Check if passed or default credentials are valid
        if not self.credentials.is_valid():
            raise exceptions.InvalidCredentials()
        # Creates an auth provider for the credentials
        self.auth_provider = self.get_auth_provider(self.credentials)
        # FIXME(andreaf) unused
        self.client_attr_names = []
开发者ID:CiscoSystems,项目名称:tempest,代码行数:20,代码来源:manager.py


示例9: _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


示例10: _get_network_client

    def _get_network_client(self):
        # The intended configuration is for the network client to have
        # admin privileges and indicate for whom resources are being
        # created via a 'tenant_id' parameter.  This will often be
        # preferable to authenticating as a specific user because
        # working with certain resources (public routers and networks)
        # often requires admin privileges anyway.
        if not CONF.service_available.neutron:
            return None
        import neutronclient.v2_0.client

        credentials = auth.get_default_credentials('identity_admin')

        auth_url = CONF.identity.uri
        dscv = CONF.identity.disable_ssl_certificate_validation
        endpoint_type = CONF.network.endpoint_type

        return neutronclient.v2_0.client.Client(
            username=credentials.username,
            password=credentials.password,
            tenant_name=credentials.tenant_name,
            endpoint_type=endpoint_type,
            auth_url=auth_url,
            insecure=dscv)
开发者ID:BhargavaRegalla,项目名称:tempest,代码行数:24,代码来源:clients.py


示例11: __init__

 def __init__(self, interface='json', service=None):
     super(AltManager, self).__init__(
         credentials=auth.get_default_credentials('alt_user'),
         interface=interface,
         service=service)
开发者ID:BhargavaRegalla,项目名称:tempest,代码行数:5,代码来源:clients.py


示例12: _get_credentials

 def _get_credentials(cls, get_creds, ctype):
     if CONF.compute.allow_tenant_isolation:
         creds = get_creds()
     else:
         creds = auth.get_default_credentials(ctype)
     return creds
开发者ID:cloudbau,项目名称:tempest,代码行数:6,代码来源:manager.py


示例13: credentials

 def credentials(cls):
     admin_creds = auth.get_default_credentials('identity_admin')
     creds = auth.get_default_credentials('user')
     admin_creds.tenant_name = creds.tenant_name
     return admin_creds
开发者ID:cloudbau,项目名称:tempest,代码行数:5,代码来源:manager.py


示例14: get_admin_creds

 def get_admin_creds(self):
     return auth.get_default_credentials("identity_admin", fill_in=False)
开发者ID:armando-migliaccio,项目名称:tempest-1,代码行数:2,代码来源:accounts.py


示例15: _prepare_ebs_image

    def _prepare_ebs_image(cls):
        if cls.config.cloudscaling.ebs_image_id:
            return cls.config.cloudscaling.ebs_image_id

        if not cls.config.cloudscaling.image_id_ami:
            raise cls.skipException("".join(("EC2 ", cls.__name__,
                                    ": requires image_id_ami setting")))

        if not cls.config.service_available.cinder:
            skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
            raise cls.skipException(skip_msg)
        if not cls.config.service_available.nova:
            skip_msg = ("%s skipped as nova is not available" % cls.__name__)
            raise cls.skipException(skip_msg)

        admin_creds = auth.get_default_credentials('compute_admin')
        os = base_clients.Manager(admin_creds, interface='json')
        cls.os = os
        cls.volumes_client = os.volumes_client
        cls.servers_client = os.servers_client
        cls.images_client = os.images_client
        cls.snapshots_client = os.snapshots_client

        # NOTE(apavlov): create volume
        resp, volume = cls.volumes_client.create_volume(VOLUME_SIZE,
                                                    display_name="aws_volume")
        assert 200 == resp.status
        cls.addResourceCleanUp(cls._delete_volume, volume['id'])
        cls.volumes_client.wait_for_volume_status(volume['id'], 'available')

        # NOTE(apavlov): boot instance
        bdm = [{
            "volume_id": volume['id'],
            "delete_on_termination": "1",
            "device_name": "/dev/vda"}]
        resp, server = cls.servers_client.create_server(
            "aws_instance",
            cls.config.cloudscaling.image_id_ami,
            cls.config.compute.flavor_ref,
            block_device_mapping=bdm)
        assert 202 == resp.status
        rc_server = cls.addResourceCleanUp(cls.servers_client.delete_server,
                                           server['id'])
        cls.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
        # NOTE(apavlov): create image from instance
        image_name = data_utils.rand_name("aws_ebs_image-")
        resp, _ = cls.images_client.create_image(server['id'],
                                                 image_name)
        assert 202 == resp.status
        cls.image_id = resp["location"].split('/')[-1]
        cls.addResourceCleanUp(cls.images_client.delete_image,
                               cls.image_id)
        # NOTE(apavlov): delete instance
        cls.cancelResourceCleanUp(rc_server)
        cls.servers_client.delete_server(server['id'])
        cls.servers_client.wait_for_server_termination(server['id'])

        images = cls.ec2_client.get_all_images()
        for image in images:
            if image_name in image.location:
                return image.id

        raise base.TestCasePreparationError("Can't find ebs image.")
开发者ID:JioCloudCompute,项目名称:ec2-api,代码行数:63,代码来源:base.py


示例16: __init__

 def __init__(self, interface='json', service=None):
     super(AdminManager, self).__init__(
         credentials=auth.get_default_credentials('identity_admin'),
         interface=interface,
         service=service)
开发者ID:pcaruana,项目名称:tempest,代码行数:5,代码来源:clients.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python verify_tempest_config.verify_extensions函数代码示例发布时间:2022-05-27
下一篇:
Python auth.get_credentials函数代码示例发布时间: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