maas_common.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:rca-evaluation 作者: sieve-microservices 项目源码 文件源码
def get_cinder_client(previous_tries=0):
        if previous_tries > 3:
            return None
        # right now, cinderclient does not accept a previously derived token
        # or endpoint url. So we have to pass it creds and let it do it's own
        # auth each time it's called.
        # NOTE: (mancdaz) update when https://review.openstack.org/#/c/74602/
        # lands

        auth_details = get_auth_details()
        cinder = c_client.Client('2',
                                 auth_details['OS_USERNAME'],
                                 auth_details['OS_PASSWORD'],
                                 auth_details['OS_TENANT_NAME'],
                                 auth_details['OS_AUTH_URL'],
                                 insecure=auth_details['OS_API_INSECURE'],
                                 endpoint_type=auth_details[
                                     'OS_ENDPOINT_TYPE'])

        try:
            # Do something just to ensure we actually have auth'd ok
            volumes = cinder.volumes.list()
            # Exceptions are only thrown when we iterate over volumes
            [i.id for i in volumes]
        except (c_exc.Unauthorized, c_exc.AuthorizationFailure) as e:
            cinder = get_cinder_client(previous_tries + 1)
        except Exception as e:
            status_err(str(e))

        return cinder
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号