本文整理汇总了Python中DBManager.DBManager.getFromCacheByListElement方法的典型用法代码示例。如果您正苦于以下问题:Python DBManager.getFromCacheByListElement方法的具体用法?Python DBManager.getFromCacheByListElement怎么用?Python DBManager.getFromCacheByListElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager.DBManager
的用法示例。
在下文中一共展示了DBManager.getFromCacheByListElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getFSUUID
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import getFromCacheByListElement [as 别名]
def getFSUUID(self,name_or_ip,_user="",cached=True):
"""
returns UUID of a fileserver, which is used as key for server-entries
in other tables. This does not silently update the Cache
"""
if cached :
# local Cache first
if name_or_ip in self.localCache["FSUUIDs"].keys() :
return self.localCache["FSUUIDs"][name_or_ip]
else :
name_or_ip =self.getDNSInfo(name_or_ip)["names"][0]
if name_or_ip in self.localCache["FSUUIDs"].keys() :
return self.localCache["FSUUIDs"][name_or_ip]
# then DB
if self._CFG.DB_CACHE:
from DBManager import DBManager
from afs.model.FileServer import FileServer
self.Logger.debug("looking up FSUUID in DB_Cache for serv=%s" % name_or_ip)
DNSInfo=self.getDNSInfo(name_or_ip)
thisDBManager=DBManager(self._CFG)
fs=thisDBManager.getFromCacheByListElement(FileServer,FileServer.servernames_js,DNSInfo["names"][0])
if fs != None :
# store it in localCache
self.localCache["FSUUIDs"][name_or_ip] = fs.uuid
return fs.uuid
# not found in local cache and not in DB Cache, get it from live-system
from afs.dao.VLDbDAO import VLDbDAO
self.Logger.debug("getFSUUID: called with %s" % name_or_ip)
DNSInfo=self.getDNSInfo(name_or_ip)
uuid=""
_vlDAO=VLDbDAO()
try :
uuid=_vlDAO.getFsUUID(DNSInfo["names"][0],_user=_user,_cfg=self._CFG)
except :
return None
# store it in localCache
self.localCache["FSUUIDs"][name_or_ip] = uuid
return uuid