【openStack】Libcloud 如何支持 keystone V3?
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?的更多相关文章
- [转]OpenStack Keystone V3
Keystone V3 Keystone 中主要涉及到如下几个概念:User.Tenant.Role.Token.下面对这几个概念进行简要说明. User:顾名思义就是使用服务的用户,可以是人.服务或 ...
- OpenStack Keystone V3 简介
Keystone V3 简介 Keystone 中主要涉及到如下几个概念:User.Tenant.Role.Token.下面对这几个概念进行简要说明. User:顾名思义就是使用服务的用户,可以是人. ...
- OpenStack实践系列②认证服务Keystone
OpenStack实践系列②认证服务Keystone 三.实战OpenStack之控制节点3.1 CentOS7的时间同步服务器chrony 下载chrony # yum install -y chr ...
- (原创)OpenStack服务如何使用Keystone(三)---详细配置Keystone中间件
(一)Keystone端的操作 (二)如何在OpenStack服务上部署Keystone中间件 (三)详细配置keystonemiddleware 前文我们介绍了如何部署Keystone中间件以及中间 ...
- 使用openstackclient调用Keystone v3 API
本文内容属于个人原创,转载务必注明出处: http://www.cnblogs.com/Security-Darren/p/4138945.html 考虑到Keystone社区逐渐弃用第二版身份AP ...
- 3.openstack之mitaka搭建keystone认证服务
认证服务keystone部署 一:安装和配置服务 1.建库建用户 mysql -u root -p CREATE DATABASE keystone; GRANT ALL PRIVILEGES ON ...
- 【OpenStack】OpenStack系列2之KeyStone详解
源码下载.依赖安装 参考:http://www.oschina.net/question/565065_66271 https://github.com/yongluo2013/osf-opensta ...
- openstack第一章:keystone
第一篇keystone— 身份认证服务 一.Keystone介绍: keystone 是OpenStack的组件之一,用于为OpenStack家族中的其它组件成员提供统一的认证服务,包括身 ...
- (原创)OpenStack服务如何使用Keystone(一)---Keystone端的操作
(一)Keystone端的操作 (二)如何在OpenStack服务上部署Keystone中间件 (三)详细配置keystonemiddleware OpenStack项目如果要使用Keystone作为 ...
随机推荐
- Activity去Title的几种方式
第一种:直接加一行代码: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInst ...
- C语言学习 第九次作业总结
本次作业练习的内容是二维数组.下面我先简单的说下二维数组的基本知识点: 二维数组其实这个中文概念颇有误导--会让人感觉这是一个两个维度的概念.所以很多的国外的C语言书籍上会称这种数组为多下标数组:即首 ...
- mysql函数大全
对于针对字符串位置的操作,第一个位置被标记为1. ASCII(str) 返回字符串str的最左面字符的ASCII代码值.如果str是空字符串,返回0.如果str是NULL,返回NULL. mysql& ...
- mysql的explain学习
explain是用来获取sql执行计划的信息. 上面是一个最简单的sql分析.下面来分析每列的意思. ①id ②select_type ③ table ④type ⑤possible_key ⑥ke ...
- LoadRunner安装+汉化+破解
因为工作需要要用到LoadRunner,找个好几个版本,换了两台电脑(公司的win7折腾了好久装不上去),耗时两天终于搞定了,分享给需要的小伙伴们,避免大家踩更多的坑~ 一.安装前的准备 Win10系 ...
- spring定时器,定时器一次执行两次的问题
Spring 定时器 方法一:注解形式 配置文件头加上如下: xmlns:task="http://www.springframework.org/schema/task" htt ...
- 递推 hdu 2064
z[n] n个盘子从1到3次数 先想2个的时候 1->2 2->3 1->2 3->2 2->1 2->3 1->2 2->3 显然 要先把上面n- ...
- 【转】封装原生JS实现Ajax
function createXHR() { if (window.XMLHttpRequest) { //IE7+.Firefox.Opera.Chrome 和Safari return new X ...
- 用Python实现多核心并行计算
平常写的程序,无论是单线程还是多线程,大多只有一个进程,而且只能在一个核心里工作.所以很多应用程序即使正在满载运行,在任务管理器中CPU使用量还是只有50%(双核CPU)或25%(四核CPU) 如果能 ...
- LINQ函数
LINQ函数虽然和LINQ语句实现了同样的功能,但LINQ函数使用起来更加快捷.学过数据库的感觉LINQ语句都不难,但语句比较长. 会LINQ函数,才算会LINQ. 1.Where(),结果过滤 Li ...