欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

openstack云計算keystone架構源碼分析

 更新時間:2022年04月20日 10:55:38   作者:Jeff的技術棧  
這篇文章主要為大家介紹了openstack云計算keystone架構源碼分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪

keystone架構

Keystone API

Keystone API與Openstack其他服務的API類似,也是基于ReSTFul HTTP實現(xiàn)的。

Keystone API劃分為Admin API和Public API:

  • Public API不僅實現(xiàn)獲取版本以及相應擴展信息的操作,同時包括獲取Token以及Token租戶信息的操作;
  • Admin API主要提供服務開發(fā)者使用,不僅可以完成Public API的操作,同時對User、Tenant、Role和Service Endpoint進行管理操作。

Router

Keystone Router主要實現(xiàn)上層API和底層服務的映射和轉換功能,包括四種Router類型。

(1) AdminRouter負責將Admin API請求映射為相應的行為操作并轉發(fā)至底層相應的服務執(zhí)行;

(2) PublicRouter與AdminRouter類似;

(3) PublicVersionRouter對系統(tǒng)版本的請求API進行映射操作;

(4) AdminVersionRouter與PublicVersionRouter類似。

Services

Keystone Service接收上層不同Router發(fā)來的操作請求,并根據(jù)不同后端驅動完成相應操作,主要包括四種類型;

(1) Identity Service

Identity Service提供關于用戶和用戶組的授權認證及相關數(shù)據(jù)。

Keystone-10.0.0支持ldap.core.Identity,Sql.Identity兩種后端驅動,系統(tǒng)默認的是Sql.Identity;

Users:

用戶這一概念在openstack中實際上是用來標識一個使用者(an individual API consumer)

一個用戶必須被一個具體的domain擁有

所有的用戶名不是全局唯一的,在同一個domain中用戶名才唯一

Groups:

用戶組是一個包含了一系列用戶的容器,一個group必須被一個具體的domain擁有

所有的組名不是全局唯一的,在同一domain種組名才唯一

(2) Resource Service

Resouse服務提供關于projects和domains的數(shù)據(jù)

projects

Projects(在v2.0中稱之為Tenants)在openstack中project代表資源的結合

一個project必須被一個具體的domain所擁有

所有的project都不是全局唯一的,僅僅在一個domain中project唯一

新建一個project沒有指定domain,它將被添加到默認的domain中即default

Domains

Domains是一個更高級別的包含n個projects-users-groups的容器。
默認的Domains名為Default

在v3版本中的唯一性概念

Domain名,在所有的domains中全局唯一

Role名.在所有的domains中全局唯一

User名,僅僅在它自己所在的domain中唯一

Project名,僅僅在它自己所在的domain中唯一

Group名,僅僅在它自己所在的domain中唯一

基于這些容器結構,domains代表了openstack資源的管理方式,只要某一assignment(project-user-role)被授予權限,一個domain中的用戶就可以訪問另外一個domain中的資源。

(3) Assignment Service

Assignment Service提供role及role assignments的數(shù)據(jù)

Roles

role角色標識了一個用戶可以獲得的權限級別

可以在domain或project級別授予role。

可以分配給單個用戶或組級別role。

role名稱是全局唯一的。

Role Assignments

A 3-tuple that has a Role, a Resource and an Identity.

Resource指的是project

Identity指的是user

Role指的是role即project-user-role

(4) Token Service

Token Service提供認證和管理令牌token的功能,用戶的credentials認證通過后就得到token

Keystone-10.0.0對于Token Service支持Kvs.Token,Memcache.Token,

Memcache_pool.Token,Sql.Token四種后端驅動,系統(tǒng)默認的是kvs.Token

(5) Catalog Service

Catalog Service提供service和Endpoint相關的管理操作(service即openstack所有服務,endpont即訪問每個服務的url)

keystone-10.0.0對Catalog Service支持兩種后端驅動:Sql.Catalog、Templated.Catalog兩種后端驅動,系統(tǒng)默認的是templated.Catalog;

(6) Policy ServicePolicy Service

提供一個基于規(guī)則的授權驅動和規(guī)則管理

keystone-10.0.0對Policy Service支持兩種后端驅動:rules.Policy,sql.Policy,默認使用sql.Policy

Backend Driver

Backend Driver具有多種類型,不同的Service選擇不同的Backend Driver。

官方https://docs.openstack.org/keystone/latest/#groups

keystone管理這些概念的方法

組件名稱管理對象生成方法保存方式配置項
identityuser,以及 user group-sql, ldap.core

[identity]

driver = keystone.identity.backends.[sql|ldap.core].Identity

token用戶的臨時 tokenpki,pkiz,uuidsql, kvs,memcached

[token]

driver = keystone.token.persistence.backends.[sql|kvs|memcache|memcache_pool].Token

provider=keystone.token.providers.[pkiz|pki|uuid].Provider
credentialEC2 credential sql

[credential]

driver = keystone.credential.backends.sql.Credential

provider=keystone.token.providers.[core|fernet].Provider

catalogregion,service,endpoint sql|templated

[catalog]

driver = keystone.catalog.backends.[sql|templated].Catalog

assignmenttenant,domain,role 以及它們與 user 之間的關系external, password, tokensql

[assignment]

methods = external, password, token

password = keystone.auth.plugins.password.Password

trusttrustsql 

[trust]

driver = keystone.trust.backends.[sql].Trust

policyKeystone service 的用戶鑒權策略 ruels|sql

[default]

policy_file = policy.json

[policy]

driver = keystone.policy.backends.[ruels|sql].Policy

keystone-10.0.0代碼結構展示

keystone-manage 是個 CLI 工具,它通過和 Keystone service 交互來做一些無法使用 Keystone REST API 來進行的操作,包括:

db_sync: Sync the database.

db_version: Print the current migration version of the database.

mapping_purge: Purge the identity mapping table.

pki_setup: Initialize the certificates used to sign tokens.

saml_idp_metadata: Generate identity provider metadata.

ssl_setup: Generate certificates for SSL.

token_flush: Purge expired tokens.

每個Keystone 組件,比如 catalog, token 等都有一個單獨的目錄。
每個組件目錄中:

routes.py 定義了該組件的 routes (routes 見 探索 OpenStack 之(11):cinder-api Service 啟動過程分析 以及 WSGI / Paste deploy / Router 等介紹)。

其中identity 和 assignment 分別定義了 admin 和 public 使用的 routes,分別供 admin service 和 public service 使用。

controller.py 文件定義了該組件所管理的對象,比如 assignment 的controller.py 文件定義了 Tenant、Role、Project 等類。

core.py 定了了兩個類 Manager 和 Driver。Manager 類對外提供該組件操作具體對象的方法入口;

Driver 類定義了該組件需要其Driver實現(xiàn)類所提供的接口。
backend 目錄下的每個文件是每個具體driver 的實現(xiàn)

下載keystone-10.0.0演示https://www.openstack.org/

keystone服務啟動

Keystone is an HTTP front-end to several services. Like other OpenStack applications, this is done using python WSGI interfaces and applications are configured together usingPaste. The application’s HTTP endpoints are made up of pipelines of WSGI middleware。。。

詳見:https://docs.openstack.org/keystone/latest/

/usr/bin/keystone-all 會啟動 keystone 的兩個service:admin and main,它們分別對應 /etc/keystone/keystone-paste.ini文件中的兩個composite:

可見 admin service 提供給administrator 使用;main 提供給 public 使用。

它們分別都有 V2.0 和 V3 版本,只是目前的 keystone Cli 只支持 V2.0.比較下 admin 和 public:

名稱middlewaresfactory功能區(qū)別
admin比 public 多s3_extensionkeystone.service:public_app_factory

從 factory 函數(shù)來看, admin service 比 public service 多了identity 管理功能, 以及 assignment 的admin/public 區(qū)別:

1. admin 多了對 GET/users/{user_id} 的支持,多了get_all_projects,get_project,get_user_roles 等功能

2. keystone 對 admin service 提供 admin extensions, 比如OS-KSADM等;對 public service 提供 public extensions。

簡單總結一下, public service 主要提供了身份驗證和目錄服務功能;admin service 增加了 tenant、user、role、user group 的管理功能。

public

sizelimit url_normalize build_auth_context token_auth admin_token_auth xml_body_v2

json_body ec2_extension user_crud_extension

keystone.service:admin_app_factory

/usr/bin/keystone-all 會啟動 admin 和 public 兩個 service,分別綁定不同 host 和 端口。

默認的話,綁定host 都是 0.0.0.0;

admin 的綁定端口是 35357 (admin_port), public 的綁定端口是 5000 (public_port)。

因此,給 admin 使用的OS_AUTH_URL 為 http://controller:35357/v2.0,

給 public 使用的OS_AUTH_URL=http://controller:5000/v2.0

keystone詳細說明

WSGI server的父進程(50511號進程)開啟兩個socket去分別監(jiān)聽本環(huán)境的5000和35357號端口,
其中5000號端口是為main的WSGI server提供的,35357號端口為admin的WSGI server提供的。

即WSGI server的父進程接收到5000號端口的HTTP請求時,則將把該請求轉發(fā)給為main開啟的WSGI server去處理,

而WSGI server的父進程接收到35357號端口的HTTP請求時,則將把該請求轉發(fā)給為admin開啟的WSGI server去處理。

vim /etc/keystone/keystone-paste.ini

日志

2016-09-14 11:53:01.037 12698 INFO keystone.common.wsgi [req-07b28d5b-084c-467e-b45a-a4c8a52b7e96
9ff041112e454cca9b54bf117a80ca29 15426931fe4746d08736c5e5c1da6b1c 
- 6e495643fb014e5e8a3992c69d80d234 6e495643fb014e5e8a3992c69d80d234] 
GET http://controller02:35357/v3/auth/tokens

(1) type = composite

這個類型的section會把URL請求分發(fā)到對應的Application,use表明具體的分發(fā)方式,比如”egg:Paste#urlmap”表示使用Paste包中的urlmap模塊,這個section里的其他形式如”key = value”的行是使用urlmap進行分發(fā)時的參數(shù)。

(2) type = app

一個app就是一個具體的WSGI Application。

(3) type = filter-app

接收一個請求后,會首先調用filter-app中的use所指定的app進行過濾,如果這個請求沒有被過濾,就會轉發(fā)到next所指定的app進行下一步的處理。

(4) type = filter

與filter-app類型的區(qū)別只是沒有next。

(5) type = pipeline

pipeline由一系列filter組成。

這個filter鏈條的末尾是一個app。pipeline類型主要是對filter-app進行了簡化,否則,如果多個filter,就需要多個filter-app,然后使用next進行連接。OpenStack的paste的deploy的配置文件

主要采用的pipeline的方式。

因為url為http://192.168.118.1:5000/v2.0/tokens,因為基本url的后面接的信息為/v2.0,所以將到public_api的section作相應操作。

以上就是openstack云計算keystone架構源碼分析的詳細內容,更多關于openstack云計算keystone架構的資料請關注腳本之家其它相關文章!

相關文章

最新評論