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


Python client.Client方法代码示例

本文整理汇总了Python中keystoneclient.v2_0.client.Client方法的典型用法代码示例。如果您正苦于以下问题:Python client.Client方法的具体用法?Python client.Client怎么用?Python client.Client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keystoneclient.v2_0.client的用法示例。


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

示例1: authenticate_nova_user

# 需要导入模块: from keystoneclient.v2_0 import client [as 别名]
# 或者: from keystoneclient.v2_0.client import Client [as 别名]
def authenticate_nova_user(self, keystone, user, password, tenant):
        """Authenticates a regular user with nova-api."""
        self.log.debug('Authenticating nova user ({})...'.format(user))
        ep = keystone.service_catalog.url_for(service_type='identity',
                                              interface='publicURL')
        if keystone.session:
            return nova_client.Client(NOVA_CLIENT_VERSION,
                                      session=keystone.session,
                                      auth_url=ep)
        elif novaclient.__version__[0] >= "7":
            return nova_client.Client(NOVA_CLIENT_VERSION,
                                      username=user, password=password,
                                      project_name=tenant, auth_url=ep)
        else:
            return nova_client.Client(NOVA_CLIENT_VERSION,
                                      username=user, api_key=password,
                                      project_id=tenant, auth_url=ep) 
开发者ID:openstack,项目名称:charm-swift-proxy,代码行数:19,代码来源:utils.py

示例2: __init__

# 需要导入模块: from keystoneclient.v2_0 import client [as 别名]
# 或者: from keystoneclient.v2_0.client import Client [as 别名]
def __init__(self):
        auth_url = cfg.CONF.keystone_authtoken.auth_uri
        auth_user = cfg.CONF.keystone_authtoken.admin_user
        auth_password = cfg.CONF.keystone_authtoken.admin_password
        auth_tenant = cfg.CONF.keystone_authtoken.admin_tenant_name
        self.version = self._get_api_version(auth_url)
        if self.version == 'v2':
            LOG.debug("auth_url=%(auth_url)s, auth_user=%(auth_user)s, "
                      "auth_tenant=%(auth_tenant)s",
                      {'auth_url': auth_url, 'auth_user': auth_user,
                       'auth_tenant': auth_tenant})
            self.keystone_client = clientv2.Client(
                auth_url=auth_url,
                username=auth_user,
                password=auth_password,
                tenant_name=auth_tenant,
            )
        elif self.version == 'v3':
            raise cfg.Error('keystone api v3 is not supported yet') 
开发者ID:DeNADev,项目名称:networking-bigswitch-l3-pe,代码行数:21,代码来源:keystone_client.py

示例3: authenticate_cinder_admin

# 需要导入模块: from keystoneclient.v2_0 import client [as 别名]
# 或者: from keystoneclient.v2_0.client import Client [as 别名]
def authenticate_cinder_admin(self, keystone_sentry, username,
                                  password, tenant, api_version=2):
        """Authenticates admin user with cinder."""
        # NOTE(beisner): cinder python client doesn't accept tokens.
        keystone_ip = keystone_sentry.info['public-address']
        ept = "http://{}:5000/v2.0".format(keystone_ip.strip().decode('utf-8'))
        _clients = {
            1: cinder_client.Client,
            2: cinder_clientv2.Client}
        return _clients[api_version](username, password, tenant, ept) 
开发者ID:openstack,项目名称:charm-swift-proxy,代码行数:12,代码来源:utils.py

示例4: authenticate_keystone

# 需要导入模块: from keystoneclient.v2_0 import client [as 别名]
# 或者: from keystoneclient.v2_0.client import Client [as 别名]
def authenticate_keystone(self, keystone_ip, username, password,
                              api_version=False, admin_port=False,
                              user_domain_name=None, domain_name=None,
                              project_domain_name=None, project_name=None):
        """Authenticate with Keystone"""
        self.log.debug('Authenticating with keystone...')
        port = 5000
        if admin_port:
            port = 35357
        base_ep = "http://{}:{}".format(keystone_ip.strip().decode('utf-8'),
                                        port)
        if not api_version or api_version == 2:
            ep = base_ep + "/v2.0"
            auth = v2.Password(
                username=username,
                password=password,
                tenant_name=project_name,
                auth_url=ep
            )
            sess = keystone_session.Session(auth=auth)
            client = keystone_client.Client(session=sess)
            # This populates the client.service_catalog
            client.auth_ref = auth.get_access(sess)
            return client
        else:
            ep = base_ep + "/v3"
            auth = v3.Password(
                user_domain_name=user_domain_name,
                username=username,
                password=password,
                domain_name=domain_name,
                project_domain_name=project_domain_name,
                project_name=project_name,
                auth_url=ep
            )
            sess = keystone_session.Session(auth=auth)
            client = keystone_client_v3.Client(session=sess)
            # This populates the client.service_catalog
            client.auth_ref = auth.get_access(sess)
            return client 
开发者ID:openstack,项目名称:charm-swift-proxy,代码行数:42,代码来源:utils.py

示例5: authenticate_glance_admin

# 需要导入模块: from keystoneclient.v2_0 import client [as 别名]
# 或者: from keystoneclient.v2_0.client import Client [as 别名]
def authenticate_glance_admin(self, keystone):
        """Authenticates admin user with glance."""
        self.log.debug('Authenticating glance admin...')
        ep = keystone.service_catalog.url_for(service_type='image',
                                              interface='adminURL')
        if keystone.session:
            return glance_client.Client(ep, session=keystone.session)
        else:
            return glance_client.Client(ep, token=keystone.auth_token) 
开发者ID:openstack,项目名称:charm-swift-proxy,代码行数:11,代码来源:utils.py

示例6: authenticate_heat_admin

# 需要导入模块: from keystoneclient.v2_0 import client [as 别名]
# 或者: from keystoneclient.v2_0.client import Client [as 别名]
def authenticate_heat_admin(self, keystone):
        """Authenticates the admin user with heat."""
        self.log.debug('Authenticating heat admin...')
        ep = keystone.service_catalog.url_for(service_type='orchestration',
                                              interface='publicURL')
        if keystone.session:
            return heat_client.Client(endpoint=ep, session=keystone.session)
        else:
            return heat_client.Client(endpoint=ep, token=keystone.auth_token) 
开发者ID:openstack,项目名称:charm-swift-proxy,代码行数:11,代码来源:utils.py

示例7: __init__

# 需要导入模块: from keystoneclient.v2_0 import client [as 别名]
# 或者: from keystoneclient.v2_0.client import Client [as 别名]
def __init__(self, endpoint, **kwargs):
        try:
            from keystoneclient.v3 import client
            from keystoneclient.auth import token_endpoint
            from keystoneclient import session
            from keystoneclient.auth.identity import v3
        except ImportError:
            if six.PY2:
                apt_install(["python-keystoneclient"], fatal=True)
            else:
                apt_install(["python3-keystoneclient"], fatal=True)

            from keystoneclient.v3 import client
            from keystoneclient.auth import token_endpoint
            from keystoneclient import session
            from keystoneclient.auth.identity import v3

        self.api_version = 3

        token = kwargs.get("token", None)
        if token:
            auth = token_endpoint.Token(endpoint=endpoint,
                                        token=token)
            sess = session.Session(auth=auth)
        else:
            auth = v3.Password(auth_url=endpoint,
                               user_id=kwargs.get("username"),
                               password=kwargs.get("password"),
                               project_id=kwargs.get("tenant_name"))
            sess = session.Session(auth=auth)

        self.api = client.Client(session=sess) 
开发者ID:openstack,项目名称:charm-swift-proxy,代码行数:34,代码来源:keystone.py

示例8: authenticate

# 需要导入模块: from keystoneclient.v2_0 import client [as 别名]
# 或者: from keystoneclient.v2_0.client import Client [as 别名]
def authenticate(endpoint, token, login_user, login_password,
                 login_tenant_name):
    """Return a keystone client object"""

    if token:
        return client.Client(endpoint=endpoint, token=token)
    else:
        return client.Client(auth_url=endpoint, username=login_user,
                             password=login_password,
                             tenant_name=login_tenant_name) 
开发者ID:yinghai9989,项目名称:openstack_ocata_ansible,代码行数:12,代码来源:keystone_endpoint.py

示例9: __init__

# 需要导入模块: from keystoneclient.v2_0 import client [as 别名]
# 或者: from keystoneclient.v2_0.client import Client [as 别名]
def __init__(self, endpoint, **kwargs):
        try:
            from keystoneclient.v2_0 import client
            from keystoneclient.auth.identity import v2
            from keystoneclient import session
        except ImportError:
            if six.PY2:
                apt_install(["python-keystoneclient"], fatal=True)
            else:
                apt_install(["python3-keystoneclient"], fatal=True)

            from keystoneclient.v2_0 import client
            from keystoneclient.auth.identity import v2
            from keystoneclient import session

        self.api_version = 2

        token = kwargs.get("token", None)
        if token:
            api = client.Client(endpoint=endpoint, token=token)
        else:
            auth = v2.Password(username=kwargs.get("username"),
                               password=kwargs.get("password"),
                               tenant_name=kwargs.get("tenant_name"),
                               auth_url=endpoint)
            sess = session.Session(auth=auth)
            api = client.Client(session=sess)

        self.api = api 
开发者ID:openstack,项目名称:charm-keystone,代码行数:31,代码来源:keystone.py

示例10: __init__

# 需要导入模块: from keystoneclient.v2_0 import client [as 别名]
# 或者: from keystoneclient.v2_0.client import Client [as 别名]
def __init__(self, endpoint, token):
        self.api_version = 2
        self.api = client.Client(endpoint=endpoint, token=token) 
开发者ID:openstack,项目名称:charm-keystone,代码行数:5,代码来源:manager.py


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