【openStack】Libcloud 如何支持 keystone V3?

时间:2023-02-11 23:09:31

Examples

This section includes some examples which show how to use the newly available functionality. For more information, please refer to the docstrings in theopenstack_identity module.

Authenticating against Keystone API v3 using the OpenStack compute driver

This example shows how to authenticate against Keystone API v3 using the OpenStack compute driver (for the time being, default auth version used by the compute driver is 2.0).

from pprint import pprint

from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver cls = get_driver(Provider.OPENSTACK)
driver = cls('<username>', '<password>',
ex_force_auth_version='3.x_password',
ex_force_auth_url='http://192.168.1.100:5000',
ex_force_service_type='compute',
ex_force_service_region='regionOne',
ex_tenant_name='<my tenant>') pprint(driver.list_nodes())

Obtaining auth token scoped to the domain

This example show how to obtain a token which is scoped to a domain and not to a project / tenant which is a default.

Keep in mind that most of the OpenStack services don’t yet support tokens which are scoped to a domain, so such tokens are of a limited use right now.

from pprint import pprint

from libcloud.common.openstack_identity import OpenStackIdentity_3_0_Connection
from libcloud.common.openstack_identity import OpenStackIdentityTokenScope driver = OpenStackIdentity_3_0_Connection(auth_url='http://<host>:<port>',
user_id='admin',
key='<key>',
token_scope=OpenStackIdentityTokenScope.DOMAIN,
domain_name='Default',
tenant_name='admin') driver.authenticate()
pprint(driver.auth_token)

Talking directly to the OpenStack Keystone API v3

This example shows how to talk directly to OpenStack Keystone API v3 and perform administrative tasks such as listing users and roles.

from pprint import pprint

from libcloud.common.openstack_identity import OpenStackIdentity_3_0_Connection
from libcloud.common.openstack_identity import OpenStackIdentityTokenScope driver = OpenStackIdentity_3_0_Connection(auth_url='http://<host>:<port>',
user_id='admin',
key='<key>',
token_scope=OpenStackIdentityTokenScope.PROJECT,
tenant_name='admin') # This call doesn't require authentication
pprint(driver.list_supported_versions()) # The calls bellow require authentication and admin access
# (depends on the ACL configuration)
driver.authenticate() users = driver.list_users()
roles = driver.list_roles() pprint(users)
pprint(roles)

A quick note on backward compatibility

If you only use OpenStack compute driver, those changes are fully backward compatible and you aren’t affected.

If you use OpenStackAuthConnection class to talk directly to the Keystone installation, you need to update your code to either use the newOpenStackIdentityConnection class or a version specific class sinceOpenStackAuthConnection class has been removed.

参考资料:

http://libcloud.apache.org/getting-started.html

http://www.tuicool.com/articles/NvYvaa

https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd=libcloud%20keystone%20ex_force_auth_version&oq=libcloud%20keystone%20%26lt%3B.0&rsv_pq=a51b518200044b8a&rsv_t=4eb0lAF%2BhC59R3Z7fs%2BvDC3%2B%2BQ2dxF2mXLegEqfVeU%2BrK88FClYH5tlcjWQ&rqlang=cn&rsv_enter=1&rsv_sug3=2&rsv_sug1=1&rsv_sug7=000&rsv_n=2&rsv_sug2=0&inputT=697&rsv_sug4=764&rsv_sug=1

https://libcloud.readthedocs.io/en/latest/apidocs/libcloud.common.html#module-libcloud.common.openstack

https://libcloud.readthedocs.io/en/latest/apidocs/libcloud.common.html#module-libcloud.common.openstack_identity

https://libcloud.readthedocs.io/en/latest/apidocs/modules.html

https://libcloud.readthedocs.io/en/latest/supported_providers.html#compute

【openStack】Libcloud 如何支持 keystone V3?的更多相关文章

  1. &lbrack;转&rsqb;OpenStack Keystone V3

    Keystone V3 Keystone 中主要涉及到如下几个概念:User.Tenant.Role.Token.下面对这几个概念进行简要说明. User:顾名思义就是使用服务的用户,可以是人.服务或 ...

  2. OpenStack Keystone V3 简介

    Keystone V3 简介 Keystone 中主要涉及到如下几个概念:User.Tenant.Role.Token.下面对这几个概念进行简要说明. User:顾名思义就是使用服务的用户,可以是人. ...

  3. OpenStack实践系列②认证服务Keystone

    OpenStack实践系列②认证服务Keystone 三.实战OpenStack之控制节点3.1 CentOS7的时间同步服务器chrony 下载chrony # yum install -y chr ...

  4. (原创)OpenStack服务如何使用Keystone&lpar;三&rpar;---详细配置Keystone中间件

    (一)Keystone端的操作 (二)如何在OpenStack服务上部署Keystone中间件 (三)详细配置keystonemiddleware 前文我们介绍了如何部署Keystone中间件以及中间 ...

  5. 使用openstackclient调用Keystone v3 API

    本文内容属于个人原创,转载务必注明出处:  http://www.cnblogs.com/Security-Darren/p/4138945.html 考虑到Keystone社区逐渐弃用第二版身份AP ...

  6. 3&period;openstack之mitaka搭建keystone认证服务

    认证服务keystone部署 一:安装和配置服务 1.建库建用户 mysql -u root -p CREATE DATABASE keystone; GRANT ALL PRIVILEGES ON ...

  7. 【OpenStack】OpenStack系列2之KeyStone详解

    源码下载.依赖安装 参考:http://www.oschina.net/question/565065_66271 https://github.com/yongluo2013/osf-opensta ...

  8. openstack第一章:keystone

    第一篇keystone— 身份认证服务 一.Keystone介绍:       keystone 是OpenStack的组件之一,用于为OpenStack家族中的其它组件成员提供统一的认证服务,包括身 ...

  9. (原创)OpenStack服务如何使用Keystone&lpar;一&rpar;---Keystone端的操作

    (一)Keystone端的操作 (二)如何在OpenStack服务上部署Keystone中间件 (三)详细配置keystonemiddleware OpenStack项目如果要使用Keystone作为 ...

随机推荐

  1. 为现代JavaScript开发做好准备

    今天无论是在浏览器中还是在浏览器外,JavaScript世界正在经历翻天覆地地变化.如果我们谈论脚本加载.客户端的MVC框架.压缩器.AMD.Common.js还有Coffeescript……只会让你 ...

  2. &lbrack;置顶&rsqb; Hibernate从入门到精通(五)一对一单向关联映射

    上次的博文中Hibernate从入门到精通(四)基本映射我们已经讲解了一下基本映射和相关概念,接下来我们会讲稍微复杂点的映射——关系映射. 关系映射分类 关系映射即在基本映射的基础上处理多个相关对象和 ...

  3. SVM流行库LIBSvm的使用和调参

    简介:Libsvm is a simple, easy-to-use, and efficient software for SVM classification and regression. It ...

  4. 使用sed替换一行内多个括号内的值

    1. 括号在同一行 # cat test2good morning (good afternoon) (good evening) (goodgood) (good morning) # cat se ...

  5. 【&period;NET线程--进阶(一)】--线程方法详解

    上篇博客从线程的基本概况开始着重讨论了线程,进程,程序之间的区别,然后讨论了线程操作的几个类,并通过实例来说明了线程的创建方法.本篇博客将会带大家更深入的了解线程,介绍线程的基本方法,并通过一个Dem ...

  6. PowerShell 批量签入SharePoint Document Library中的文件

    由于某个文档库设置了编辑前签出功能,导致批量导入文件时这些文件默认的状态都被签出了.如果手动签入则费时费力,故利用PowerShell来实现批量签入Document Library中的文件. Reso ...

  7. js判断是否为手机访问

    JavaScript判断浏览器类型一般有两种办法,一种是根据各种浏览器独有的属性来分辨,另一种是通过分析浏览器的userAgent属性来判断的.在许多情况下,值判断出浏览器类型之后,还需判断浏览器版本 ...

  8. MySQL 一般模糊查询的几种用法

    1.%:表示零个或多个字符.在某些情况下需要中文查询,一般用两个%来查询,即%%: select * from user where name like %五%; -->表示:查询user表中的 ...

  9. 前端之HTML样式

    <!doctype html> h5的文档声明 <html> 网页的根标签(根元素 html)--所有的代码都放置在此内 <head> <meta chars ...

  10. 写web项目注意事项

    1.中文名2.文件存放路径(js css img)3.class详细路径(mydiv.myul li)