OpenStack入门之 OpenStack Cloud Administrator Guid(二)Keystone,horizon

来源:互联网 发布:linux如何更改ftp目录 编辑:程序博客网 时间:2024/06/05 20:21

Identity management(Keystone)


OpenStackIdentity Service,代码名称叫Keystone,是OpenStack默认的身份管理系统。在安装了Identity Service后,你可以在etc/keystone.conf下配置它,或者也可以通过一个单独的日志配置文件(separate logging configuration file)。通过使用keystone 命令行接口来初始化IdentityService的数据。

 

Identity Service concepts

User management

         用户管理的主要部分有:

  • User

代表一个拥有关联信息(如用户名,密码,邮件)的个人用户。下面是一个创建用户名为alice的用户的例子:

$ keystone user-create --name=alice --pass=mypassword123--email=alice@example.com

  • Tenant

一个项目,组或者一个组织。当你请求OpenStack服务的时候,你必须指定一个租户(tenant)。例如,你想要查询计算服务(Compute service)来获取正在运行的虚拟机列表,你必须在查询的时候指定是哪个租户中的虚拟机列表。下面是创建一个叫acme的租户的例子:

$ keystone tenant-create --name=acme

l  因为在早期的Compute版本中使用的是project而不是tenant,所以一些命令行工具使用--project_id而不是—tenant-id或者—os-tenant-id来表示一个tenant的id

  • Role.

指明在指定的租户中用户可以进行的操作。下面是创建一个名叫compute-user的角色的例子:

$ keystone role-create--name=compute-user

l  在个别如Compute和ImageService中,会给一个role指定意义。但在Identity Service中,一个role仅仅是一个名字。

Identity Service为一个用户(user)指定一个租户(tenant)和一个角色(role)。你可以在acme租户中把compute-user角色赋给alice用户。

$ keystone user-list

+--------+---------+-------------------+--------+

| id | enabled | email | name |

+--------+---------+-------------------+--------+

| 892585 | True | alice@example.com |alice |

+--------+---------+-------------------+--------+

$ keystone role-list

+--------+--------------+

| id | name |

+--------+--------------+

| 9a764e | compute-user |

+--------+--------------+

$ keystone tenant-list

+--------+------+---------+

| id | name | enabled |

+--------+------+---------+

| 6b8fd2 | acme | True |

+--------+------+---------+

$ keystone user-role-add--user=892585 --role=9a764e --tenant-id=6b8fd2

一个用户可以在不同的租户中有不同的角色。比如说,alice用户也可以在Cyberdyne租户里拥有admin角色。一个用户也可以在同一租户里有多种角色。

         /etc/[SERVICE_CODENAME]/policy.json文件控制了在指定服务中用户可以进行哪些操作。比如说,/etc/nova/policy.json指定了Compute中的权限。。

         省略一些更详细的说明。。如有需要参见原文。

 

Service management

         IdentityService 提供了身份,令牌,目录,和策略服务。包括了:

  • keystone-all.

在一个独立进程中开启提供catalog,authorization和authentication services的服务和管理API。

  • Identity Service functions.

每个服务都有一个可插拔的后端以提供不同的方式来使用特殊的服务。大部分都支持标准的后端,如LDAP或SQL。

         IdentityService 为每个服务都维护一个相应的用户,比如一个叫nova的用户对应Compute 服务,还有一个叫service的特殊服务租户(special service tenant)。

 

Group

         一个组是一个用户的集合。管理员可以创建组并添加用户,然后可以给一个组的用户赋予角色,而不需在单独指定每个用户。每个组都在一个域(domain)内。组在IdentityAPI的第三版(Identity服务的Grizzly版本)中才被引入。

         IdentityAPI V3提供了如下的组相关的操作:创建、删除、更新(修改名字或描述)组,为组增加、删除用户,列举所有组成员,列举某用户所在的所有组,为组增加基于租户的角色,为组增加基于域的角色,查询组所拥有的角色。

Ø  Identity service服务器可能不会允许所有的操作。比如说如果你用LDAP作为Identity的后端,则更新组会被禁用,因此,请求创建,删除,或者更新组都会失败。

 

Domains

         域定义了对身份实体的管理边界。一个域可能代表一个个体,一个公司,或者一个运营商自有的空间。它用来直接向系统用户(system users)暴露管理活动。

User CRUD

         Identity服务提供了一个用户CRUD(Create,Retrieve,Update,Delete)过滤器。这个过滤器可以被添加到public_api管道中,同时允许永续使用一个HTTP PATCH来修改他们的密码。要使用这个扩展你需要先定义一个user_crud_extension过滤器,在keystone.conf文件的*_body 中间件后和public_apiWSGI管道的public_service应用之前插入它。如下:

[filter:user_crud_extension]

paste.filter_factory =keystone.contrib.user_crud:CrudExtension.factory

[pipeline:public_api]

pipeline = stats_monitoringurl_normalize token_auth admin_token_auth xml_body json_body debugec2_extension user_crud_extension public_service

 

         然后每个用户就可以通过HTTP PATCH来修改密码了:

$ curl -X PATCHhttp://localhost:5000/v2.0/OS-KSCRUD/users/<userid> -H

"Content-type:application/json" \

-H "X_Auth_Token:<authtokenid>" -d '{"user": {"password":"ABCD",

"original_password":"DCBA"}}'

         在密码修改之后,用户当前所有的令牌都会被删除。(如果后端是KVS或者sql的话)

 

Logging

         Youconfigure logging externally to the rest of the Identity Service.日志的配置在log_conf下的keystone.conf文件的[DEFAULT]部分。想要使用syslog来记录日志,在[DEFAULT]里设置use_syslog=true

         一个样例日志文件在etc/logging.conf.sample目录下。像OpenStack其他项目一样,Identity使用pythonlogging 模块,可以使用扩展配置来自定义日志级别和格式。

         。。。一些更详细说明,略。

 

Monitoring

         Identity提供了一些基本的请求/响应的监控统计数据。(outof the box)

         收集数据可以通过定义一个stats_monitoring过滤器并把它添加到任何需要的WSGI管道的开头,如下:

[filter:stats_monitoring]

paste.filter_factory = keystone.contrib.stats:StatsMiddleware.factory

[pipeline:public_api]

pipeline = stats_monitoring [...]public_service

         需要报告(report)收集数据的话,需要定义一个stats_reporting过滤器并添加到你的admin_apiWSGI管道的结尾(推荐放在*_body中间件后面,*_extension过滤器前面):

[filter:stats_reporting]

paste.filter_factory =keystone.contrib.stats:StatsExtension.factory

[pipeline:admin_api]

pipeline = [...] json_bodystats_reporting ec2_extension [...] admin_service

向amdin API查询统计数据:

$ curl -H 'X-Auth-Token: ADMIN'http://localhost:35357/v2.0/OS-STATS/stats

重置收集的数据:

$ curl -H 'X-Auth-Token: ADMIN' -XDELETE \

http://localhost:35357/v2.0/OS-STATS/stats

Start the Identity Service

     $keystone-all

使用上面的命令可以开启服务。它启动了两个wsgi.Server insntances。一个是admin(the administration API),另一个就是main(the primary/public APIinterface)。他们运行在一个独立进程里。

Example usage

         Thekeystoneclient is set up to expect commands in the general form of keystone

command argument, followed by flag-likekeyword arguments to provide additional

(often optional) information. For example,the command user-listand tenantcreatecan be invoked as follows:

# Using token auth env variables

exportSERVICE_ENDPOINT=http://127.0.0.1:5000/v2.0/

export SERVICE_TOKEN=secrete_token

keystone user-list

keystone tenant-create --name=demo

# Using token auth flags

keystone --token=secrete--endpoint=http://127.0.0.1:5000/v2.0/ user-list

keystone --token=secrete--endpoint=http://127.0.0.1:5000/v2.0/ tenant-create --name=demo

# Using user + password + tenant_nameenv variables

export OS_USERNAME=admin

export OS_PASSWORD=secrete

export OS_TENANT_NAME=admin

keystone user-list

keystone tenant-create --name=demo

# Using user + password + tenant_nameflags

keystone --username=admin--password=secrete --tenant_name=admin user-list

keystone --username=admin--password=secrete --tenant_name=admin tenant-create --name=demo

Authentication middleware with user name and password

         Youcan also configure the Identity Service authentication middleware using the

admin_userand admin_passwordoptions. Whenusing the admin_userand

admin_passwordoptions theadmin_tokenparameter is optional. If admin_tokenis

specified, it is used only if the specifiedtoken is still valid.

For services that have a separatepaste-deploy .ini file, you can configure the authentication

middleware in the [keystone_authtoken]sectionof the main configuration file, such

as nova.conf. In Compute, for example, youcan remove the middleware parameters

from api-paste.ini, as follows:

[filter:authtoken]

paste.filter_factory =

keystoneclient.middleware.auth_token:filter_factory

And set the following values innova.confas follows:

[DEFAULT]

...

auth_strategy=keystone

[keystone_authtoken]

auth_host = 127.0.0.1

auth_port = 35357

auth_protocol = http

auth_uri = http://127.0.0.1:5000/

admin_user = admin

admin_password = SuperSekretPassword

admin_tenant_name = service

 

         Thissample paste config filter makes use of the admin_userand admin_password

options:

[filter:authtoken]

paste.filter_factory =keystoneclient.middleware.auth_token:filter_factory

service_port = 5000

service_host = 127.0.0.1

auth_port = 35357

auth_host = 127.0.0.1

auth_token =012345SECRET99TOKEN012345

admin_user = admin

admin_password = keystone123

Troubleshoot the Identity Service

         看日志:/var/log/keystone.log


Dashboard(Horizon)

----------
使用了Django框架的web界面。

Customize the dashboard

Set up session storage for the dashboard

Local memory cache

Key-value stores

Memcached

Redis

Initialize and configure the database

Cached database

Cookies

0 0
原创粉丝点击