本文整理匯總了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