當前位置: 首頁>>代碼示例>>Python>>正文


Python Credential.split方法代碼示例

本文整理匯總了Python中sfa.trust.credential.Credential.split方法的典型用法代碼示例。如果您正苦於以下問題:Python Credential.split方法的具體用法?Python Credential.split怎麽用?Python Credential.split使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sfa.trust.credential.Credential的用法示例。


在下文中一共展示了Credential.split方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check_sliver_credentials

# 需要導入模塊: from sfa.trust.credential import Credential [as 別名]
# 或者: from sfa.trust.credential.Credential import split [as 別名]
    def check_sliver_credentials(self, creds, urns):
        # build list of cred object hrns
        slice_cred_names = []
        for cred in creds:
            slice_cred_hrn = Credential(cred=cred).get_gid_object().get_hrn() 
            top_auth_hrn = top_auth(slice_cred_hrn)
            site_hrn = '.'.join(slice_cred_hrn.split('.')[:-1])
            slice_part = slice_cred_hrn.split('.')[-1]
            if top_auth_hrn == self.hrn:
                login_base = slice_cred_hrn.split('.')[-2][:12]
            else:
                login_base = hash_loginbase(site_hrn)

            slicename = '_'.join([login_base, slice_part])   
            slice_cred_names.append(slicename) 

        # look up slice name of slivers listed in urns arg
        slice_ids = []
        for urn in urns:
            sliver_id_parts = Xrn(xrn=urn).get_sliver_id_parts()
            try:
                slice_ids.append(int(sliver_id_parts[0]))
            except ValueError: 
                pass

        if not slice_ids:
             raise Forbidden("sliver urn not provided")

        slices = self.shell.GetSlices(slice_ids)
        sliver_names = [slice['name'] for slice in slices]

        # make sure we have a credential for every specified sliver ierd
        for sliver_name in sliver_names:
            if sliver_name not in slice_cred_names:
                msg = "Valid credential not found for target: %s" % sliver_name
                raise Forbidden(msg)
開發者ID:nfvproject,項目名稱:SFA,代碼行數:38,代碼來源:pldriver.py


注:本文中的sfa.trust.credential.Credential.split方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。