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


Python novaclient.client方法代码示例

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


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

示例1: authenticate_cinder_admin

# 需要导入模块: import novaclient [as 别名]
# 或者: from novaclient 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

示例2: authenticate_keystone

# 需要导入模块: import novaclient [as 别名]
# 或者: from novaclient 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


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