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

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 [email protected]

  • 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 | [email protected] |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

發佈了28 篇原創文章 · 獲贊 8 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章