2014-08-26

[夏肇毅部落格] OpenStack Study 筆記: keystone assignment backends ldap.py

[夏肇毅部落格] 看完kvs(Key Value Store) 之後,我們就要看assignment 的第二個backend: ldap.
從CubicPower首頁中之 keystone  進入keystone index 第一頁,
看到的第二個檔案就是:

\OpenStack\keystone-2014.1\keystone\assignment\backends\ldap.py

點入
def __init__(self):
可見ldap 的基本資料設定:
**** CubicPower OpenStack Study ****
    def __init__(self):
        super(Assignment, self).__init__()
        self.LDAP_URL = CONF.ldap.url
        self.LDAP_USER = CONF.ldap.user
        self.LDAP_PASSWORD = CONF.ldap.password
        self.suffix = CONF.ldap.suffix
        #These are the only deep dependency from assignment back
        #to identity.  The assumption is that if you are using
        #LDAP for assignments, you are using it for Id as well.
        self.user = ldap_identity.UserApi(CONF)
        self.group = ldap_identity.GroupApi(CONF)
        self.project = ProjectApi(CONF)
        self.role = RoleApi(CONF)
一旦選用 ldap 則identity 亦從ldap 來.
此檔案前面import部份有定義ldap_identity的來源:
from keystone.identity.backends import ldap as ldap_identity

init 之後就是由ldap 所提供的assignment 介面方法.
看一下def get_project(self, tenant_id):
**** CubicPower OpenStack Study ****
    def get_project(self, tenant_id):
        return self._set_default_domain(self.project.get(tenant_id))
前面有定義 self.project = ProjectApi(CONF)
所以就要再去研究一下 之後的類別ProjectApi:
class ProjectApi(common_ldap.EnabledEmuMixIn, common_ldap.BaseLdap):

沒有留言:

張貼留言