首先看到的第一個檔案就是
\OpenStack\keystone-2014.1\keystone\assignment\backends\kvs.py
第一個類別是 class Assignment(kvs.Base, assignment.Driver):點入就可見一些kvs(key value store)的格式說明:
"""KVS Assignment backend.
This backend uses the following mappings to store data:
* Domains:
* domain_list -> [domain_id, ...]
* domain-{id} -> domain_ref
* domain_name-{name} -> domain_ref
* Projects:
* tenant-{id} -> project_ref
* tenant_name-{name} -> project_ref
* Roles:
* role_list -> [role_id, ...]
* role-{id} -> role_ref
* Role assignments:
* metadata_user-{target}-{user_id} ->
{'roles': [{'id': role-id, ...}, ...]}
* metadata_group-{target}-{group_id} ->
{'roles': [{'id': role-id, ...}, ...]}
"""
# Public interface
這就是kvs中儲存資料的內容規格.
再回前一頁 接下去 就是他提供的存取資料介面:
def __init__(self):
def get_project(self, tenant_id):
def list_projects(self, hints):
def list_projects_in_domain(self, domain_id):
def get_project_by_name(self, tenant_name, domain_id):
def create_project(self, tenant_id, tenant):
def update_project(self, tenant_id, tenant):
def _get_metadata(self, user_id=None, tenant_id=None, domain_id=None, group_id=None):
def _get_roles_for_just_user_and_project(user_id, tenant_id):
def _get_roles_for_group_and_project(group_id, project_id):
def get_role(self, role_id):
def list_roles(self, hints):
def list_projects_for_user(self, user_id, group_ids, hints):
def get_roles_for_groups(self, group_ids, project_id=None, domain_id=None):
def list_projects_for_groups(self, group_ids):
def list_domains_for_groups(self, group_ids):
def list_user_ids_for_project(self, tenant_id):
def _subrole_id_to_dn(self, role_id, tenant_id):
def add_role_to_user_and_project(self, user_id, tenant_id, role_id):
def _add_role_to_group_and_project(self, group_id, tenant_id, role_id):
def create_role(self, role_id, role):
def delete_role(self, role_id):
def delete_project(self, tenant_id):
def remove_role_from_user_and_project(self, user_id, tenant_id, role_id):
def _remove_role_from_group_and_project(self, group_id, tenant_id, role_id):
def update_role(self, role_id, role):
def create_domain(self, domain_id, domain):
def get_domain(self, domain_id):
def update_domain(self, domain_id, domain):
def delete_domain(self, domain_id):
def list_domains(self, hints):
def delete_user(self, user_id):
def delete_group(self, group_id):
def create_grant(self, role_id, user_id=None, group_id=None, domain_id=None, project_id=None, inherited_to_projects=False):
def get_grant(self, role_id, user_id=None, group_id=None, domain_id=None, project_id=None, inherited_to_projects=False):
def delete_grant(self, role_id, user_id=None, group_id=None, domain_id=None, project_id=None, inherited_to_projects=False):
def list_grants(self, user_id=None, group_id=None, domain_id=None, project_id=None, inherited_to_projects=False):
def get_domain_by_name(self, domain_name):
def list_role_assignments(self):
點入看第一個方法def get_project(self, tenant_id):
**** CubicPower OpenStack Study ****
def get_project(self, tenant_id):
try:
return self.db.get('tenant-%s' % tenant_id)
except exception.NotFound:
raise exception.ProjectNotFound(project_id=tenant_id)
其中self.db.get('tenant-%s' % tenant_id)
就是從db 中以tenant_id抓取project的資料.
就如同開頭的資料規格所說:
* Projects:
* tenant-{id} -> project_ref
沒有留言:
張貼留言