本文整理汇总了Python中DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient.addOrModifyResource方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceStatusClient.addOrModifyResource方法的具体用法?Python ResourceStatusClient.addOrModifyResource怎么用?Python ResourceStatusClient.addOrModifyResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient
的用法示例。
在下文中一共展示了ResourceStatusClient.addOrModifyResource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Synchronizer
# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient import addOrModifyResource [as 别名]
#.........这里部分代码省略.........
if len(nodesToUpdate) > 0:
gLogger.debug(str(NodeInCS))
gLogger.debug(str(nodesToUpdate))
# Update Service table
siteInGOCDB = [self.__getServiceEndpointInfo(node) for node in nodesToUpdate]
siteInGOCDB = Utils.list_sanitize(siteInGOCDB)
#sites = [Utils.unpack(getDIRACSiteName(s[0]['SITENAME'])) for s in siteInGOCDB]
sites = []
for sInGOCDB in siteInGOCDB:
siteName = getDIRACSiteName( sInGOCDB[ 0 ][ 'SITENAME' ] )
if not siteName[ 'OK' ]:
gLogger.error( siteName[ 'Message' ] )
return siteName
sites.append( siteName[ 'Value' ] )
sites = Utils.list_sanitize( Utils.list_flatten( sites ) )
_ = [ self.__updateService(s, serviceType) for s in sites ]
# Update Resource table
for node in NodeInCS:
if serviceType == "Computing":
resourceType = CS.getCEType(site, node)
if node not in resourcesInDB and node is not None:
try:
siteInGOCDB = self.__getServiceEndpointInfo(node)[0]['SITENAME']
except IndexError: # No INFO in GOCDB: Node does not exist
gLogger.warn("Node %s is not in GOCDB!! Considering that it does not exists!" % node)
continue
assert(type(siteInGOCDB) == str)
#Utils.protect2(self.rsClient.addOrModifyResource, node, resourceType, serviceType, site, siteInGOCDB )
res = self.rsClient.addOrModifyResource( node, resourceType, serviceType, site, siteInGOCDB )
if not res[ 'OK' ]:
gLogger.error( res[ 'Message' ] )
return res
resourcesInDB.add( node )
################################################################################
def _syncResources( self ):
gLogger.info("Starting sync of Resources")
# resources in the DB now
#resourcesInDB = set((r[0] for r in Utils.unpack(self.rsClient.getResource())))
resources = self.rsClient.getResource()
if not resources[ 'OK' ]:
gLogger.error( resources[ 'Message' ] )
return resources
resourcesInDB = set( [ resource[ 0 ] for resource in resources[ 'Value' ] ] )
# Site-CE / Site-SE mapping in CS now
#CEinCS = Utils.unpack(getSiteCEMapping( 'LCG' ))
CEinCS = getSiteCEMapping( 'LCG' )
if not CEinCS[ 'OK' ]:
gLogger.error( CEinCS[ 'Message' ] )
return CEinCS
CEinCS = CEinCS[ 'Value' ]
# All CEs in CS now
CEInCS = Utils.set_sanitize([CE for celist in CEinCS.values() for CE in celist])
# All SE Nodes in CS now