本文整理汇总了Python中DIRAC.ResourceStatusSystem.Client.ResourceStatus.ResourceStatus.getStorageStatus方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceStatus.getStorageStatus方法的具体用法?Python ResourceStatus.getStorageStatus怎么用?Python ResourceStatus.getStorageStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.ResourceStatusSystem.Client.ResourceStatus.ResourceStatus
的用法示例。
在下文中一共展示了ResourceStatus.getStorageStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getVOfromProxyGroup
# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatus import ResourceStatus [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatus.ResourceStatus import getStorageStatus [as 别名]
result = getVOfromProxyGroup()
if not result['OK']:
gLogger.notice( 'Error:', result['Message'] )
DIRAC.exit( 1 )
vo = result['Value']
resources = Resources( vo = vo )
result = resources.getEligibleStorageElements()
if not result['OK']:
gLogger.notice( 'Error:', result['Message'] )
DIRAC.exit( 2 )
seList = sortList( result[ 'Value' ] )
resourceStatus = ResourceStatus()
result = resourceStatus.getStorageStatus( seList )
if not result['OK']:
gLogger.notice( 'Error:', result['Message'] )
DIRAC.exit( 3 )
for k,v in result[ 'Value' ].items():
readState, writeState = 'Active', 'Active'
if v.has_key( 'ReadAccess' ):
readState = v[ 'ReadAccess' ]
if v.has_key( 'WriteAccess' ):
writeState = v[ 'WriteAccess']
gLogger.notice("%s %s %s" % ( k.ljust(25),readState.rjust(15),writeState.rjust(15)) )
示例2: Resources
# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatus import ResourceStatus [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatus.ResourceStatus import getStorageStatus [as 别名]
res = Resources().getStorageElements( site )
if not res[ 'OK' ]:
gLogger.error( 'The provided site (%s) is not known.' % site )
DIRAC.exit( -1 )
ses.extend( res[ 'Value' ] )
if not ses:
gLogger.error( 'There were no SEs provided' )
DIRAC.exit()
readAllowed = []
writeAllowed = []
checkAllowed = []
resourceStatus = ResourceStatus()
res = resourceStatus.getStorageStatus( ses )
if not res[ 'OK' ]:
gLogger.error( 'Storage Element %s does not exist' % ses )
DIRAC.exit( -1 )
reason = 'Forced with dirac-admin-allow-se by %s' % userName
for se, seOptions in res[ 'Value' ].items():
resW = resC = resR = { 'OK' : False }
# InActive is used on the CS model, Banned is the equivalent in RSS
if read and seOptions.has_key( 'ReadAccess' ):
if not seOptions[ 'ReadAccess' ] in [ "InActive", "Banned", "Probing", "Degraded" ]:
示例3: StrategyHandler
# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatus import ResourceStatus [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatus.ResourceStatus import getStorageStatus [as 别名]
#.........这里部分代码省略.........
random.shuffle( candidates )
selChannel, selSourceSE, selTargetSE = candidates[0]
ancestor = False
for channelID, treeItem in tree.items():
if selSourceSE in treeItem["DestSE"]:
ancestor = channelID
tree[selChannel.channelID] = { "Ancestor" : ancestor,
"SourceSE" : selSourceSE,
"DestSE" : selTargetSE,
"Strategy" : "DynamicThroughput" }
timeToSite[selTargetSE] = selTimeToStart
sourceSEs.append( selTargetSE )
targetSEs.remove( selTargetSE )
return S_OK( tree )
def reset( self ):
""" reset :chosenStrategy:
:param self: self reference
"""
self.chosenStrategy = 0
def getSupportedStrategies( self ):
""" Get supported strategies.
:param self: self reference
"""
return self.supportedStrategies
def replicationTree( self, sourceSEs, targetSEs, size, strategy=None ):
""" get replication tree
:param str lfn: LFN
:param list sourceSEs: list of sources SE names to use
:param list targetSEs: liost of target SE names to use
:param long size: file size
:param str strategy: strategy name
"""
## update SEs rwAccess every rwUpdatePertion timedelta (default 300 s)
now = datetime.datetime.now()
if now - self.lastRssUpdate > self.rwUpdatePeriod:
update = self.updateGraph( rwAccess=True )
if not update["OK"]:
self.log.warn("replicationTree: unable to update FTS graph: %s" % update["Message"] )
else:
self.lastRssUpdate = now
## get strategy
strategy = strategy if strategy else self.__selectStrategy()
if strategy not in self.getSupportedStrategies():
return S_ERROR("replicationTree: unsupported strategy '%s'" % strategy )
self.log.info( "replicationTree: strategy=%s sourceSEs=%s targetSEs=%s size=%s" %\
( strategy, sourceSEs, targetSEs, size ) )
## fire action from dispatcher
tree = self.strategyDispatcher[strategy]( sourceSEs, targetSEs )
if not tree["OK"]:
self.log.error( "replicationTree: %s" % tree["Message"] )
return tree
## update graph edges
update = self.updateGraph( replicationTree=tree["Value"], size=size )
if not update["OK"]:
self.log.error( "replicationTree: unable to update FTS graph: %s" % update["Message"] )
return update
return tree
def __selectStrategy( self ):
""" If more than one active strategy use one after the other.
:param self: self reference
"""
chosenStrategy = self.activeStrategies[self.chosenStrategy]
self.chosenStrategy += 1
if self.chosenStrategy == self.numberOfStrategies:
self.chosenStrategy = 0
return chosenStrategy
def __getRWAccessForSE( self, seList ):
""" get RSS R/W for :seList:
:param list seList: SE list
"""
rwDict = dict.fromkeys( seList )
for se in rwDict:
rwDict[se] = { "read" : False, "write" : False }
rAccess = self.resourceStatus.getStorageStatus( seList, statusType = "ReadAccess" )
if not rAccess["OK"]:
return rAccess
rAccess = [ k for k, v in rAccess["Value"].items() if "ReadAccess" in v and v["ReadAccess"] in ( "Active",
"Degraded" ) ]
wAccess = self.resourceStatus.getStorageStatus( seList, statusType = "WriteAccess" )
if not wAccess["OK"]:
return wAccess
wAccess = [ k for k, v in wAccess["Value"].items() if "WriteAccess" in v and v["WriteAccess"] in ( "Active",
"Degraded" ) ]
for se in rwDict:
rwDict[se]["read"] = se in rAccess
rwDict[se]["write"] = se in wAccess
return S_OK( rwDict )
示例4: __init__
# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatus import ResourceStatus [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatus.ResourceStatus import getStorageStatus [as 别名]
#.........这里部分代码省略.........
result = self.resourcesHelper.getStorageElementOptionsDict(storageName)
if not result["OK"]:
errStr = "StorageFactory._getConfigStorageName: Failed to get storage options"
gLogger.error(errStr, result["Message"])
return S_ERROR(errStr)
if not result["Value"]:
errStr = "StorageFactory._getConfigStorageName: Supplied storage doesn't exist."
gLogger.error(errStr, storageName)
return S_ERROR(errStr)
if "Alias" in res["Value"]:
configPath = "%s/%s/Alias" % (self.rootConfigPath, storageName)
aliasName = gConfig.getValue(configPath)
result = self._getConfigStorageName(aliasName)
if not result["OK"]:
errStr = "StorageFactory._getConfigStorageName: Supplied storage doesn't exist."
gLogger.error(errStr, configPath)
return S_ERROR(errStr)
resolvedName = result["Value"]
else:
resolvedName = storageName
return S_OK(resolvedName)
def _getConfigStorageOptions(self, storageName):
""" Get the options associated to the StorageElement as defined in the CS
"""
result = self.resourcesHelper.getStorageElementOptionsDict(storageName)
if not result["OK"]:
errStr = "StorageFactory._getStorageOptions: Failed to get storage options."
gLogger.error(errStr, "%s: %s" % (storageName, result["Message"]))
return S_ERROR(errStr)
optionsDict = result["Value"]
result = self.resourceStatus.getStorageStatus(storageName, "ReadAccess")
if not result["OK"]:
errStr = "StorageFactory._getStorageOptions: Failed to get storage status"
gLogger.error(errStr, "%s: %s" % (storageName, result["Message"]))
return S_ERROR(errStr)
# optionsDict.update( result[ 'Value' ][ storageName ] )
return S_OK(optionsDict)
def _getConfigStorageProtocols(self, storageName):
""" Protocol specific information is present as sections in the Storage configuration
"""
result = getSiteForResource(storageName)
if not result["OK"]:
return result
site = result["Value"]
result = self.resourcesHelper.getEligibleNodes("AccessProtocol", {"Site": site, "Resource": storageName})
if not result["OK"]:
return result
nodesList = result["Value"]
protocols = []
for node in nodesList:
protocols.append(node)
protocolDetails = []
for protocol in protocols:
result = self._getConfigStorageProtocolDetails(protocol)
if not result["OK"]:
return result
protocolDetails.append(result["Value"])
self.protocols = self.localProtocols + self.remoteProtocols
return S_OK(protocolDetails)
def _getConfigStorageProtocolDetails(self, protocol):