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


Python DBManager.getFromCache方法代碼示例

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


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

示例1: getHostnameByFSUUID

# 需要導入模塊: from DBManager import DBManager [as 別名]
# 或者: from DBManager.DBManager import getFromCache [as 別名]
    def getHostnameByFSUUID(self,uuid,_user="",cached=True) :
        """
        returns hostname of a fileserver by uuid
        """
        self.Logger.debug("called with %s, cached=%s" % (uuid,cached))
        self.Logger.debug("self._CFG=%s" % (self._CFG))
        if cached :
            # local Cache first
            for hn in self.localCache["FSUUIDs"] :
                if self.localCache["FSUUIDs"][hn] == uuid :
                    return hn
            # then DB 
            if self._CFG.DB_CACHE:
                from DBManager import DBManager
                from afs.model.FileServer import FileServer
                thisDBManager=DBManager(self._CFG)
                fs=thisDBManager.getFromCache(FileServer,uuid=uuid)
                self.Logger.debug("looking up hostname in DB_Cache for uuid=%s" % uuid)
                if fs != None :
                    self.localCache["FSUUIDs"][fs.servernames[0]] = fs.uuid                  
                    return fs.servernames[0]

        # not found in local cache and not in DB Cache, or cacheing disabled.
        # get it from live-system
        from afs.dao.VLDbDAO import VLDbDAO
        _vlDAO=VLDbDAO()
        name_or_ip=None
        for fs in _vlDAO.getFsServList(_cfg=self._CFG,_user="" ) :
            if fs['uuid'] == uuid :
               name_or_ip = fs['name_or_ip']
        if name_or_ip == None :
            raise LookupUtilError("No Server with uuid=%s registered in live-system" % uuid)
        # store it in localCache 
        self.Logger.debug("getHostnameByFSUUID: got name_or_ip =%s from live-system" % name_or_ip)
        name_or_ip=self.getDNSInfo(name_or_ip)["names"][0]
        self.localCache["FSUUIDs"][name_or_ip] = uuid                  
        self.Logger.debug("returning: %s" % name_or_ip)
        return name_or_ip
開發者ID:hpotter24,項目名稱:afspy-master,代碼行數:40,代碼來源:LookupUtil.py


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