本文整理汇总了Python中DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient.addOrModifyStorageElement方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceStatusClient.addOrModifyStorageElement方法的具体用法?Python ResourceStatusClient.addOrModifyStorageElement怎么用?Python ResourceStatusClient.addOrModifyStorageElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient
的用法示例。
在下文中一共展示了ResourceStatusClient.addOrModifyStorageElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Synchronizer
# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient import addOrModifyStorageElement [as 别名]
#.........这里部分代码省略.........
if not ses[ 'OK' ]:
gLogger.error( ses[ 'Message' ] )
return ses
DBSEs = set( [ se[0] for se in ses[ 'Value' ] ] )
# Remove storageElements that are in DB but not in CS
for se in DBSEs - CSSEs:
#Utils.protect2(self.rsClient.removeElement, 'StorageElement', se )
res = self.rsClient.removeElement( 'StorageElement', se )
if not res[ 'OK' ]:
gLogger.error( res[ 'Message' ] )
return res
# Add new storage elements
gLogger.info("Updating %d StorageElements in DB (%d on CS vs %d on DB)" % (len(CSSEs - DBSEs), len(CSSEs), len(DBSEs)))
for SE in CSSEs - DBSEs:
srm = CS.getSEHost( SE )
if not srm:
gLogger.warn("%s has no srm URL in CS!!!" % SE)
continue
#siteInGOCDB = Utils.unpack(self.GOCDBClient.getServiceEndpointInfo( 'hostname', srm ))
siteInGOCDB = self.GOCDBClient.getServiceEndpointInfo( 'hostname', srm )
if siteInGOCDB[ 'OK' ]:
siteInGOCDB = siteInGOCDB[ 'Value' ]
else:
gLogger.error("Error getting hostname for %s from GOCDB!!!" % srm)
continue
if siteInGOCDB == []:
gLogger.warn("%s is not in GOCDB!!!" % srm)
continue
siteInGOCDB = siteInGOCDB[ 0 ][ 'SITENAME' ]
#Utils.protect2(self.rsClient.addOrModifyStorageElement, SE, srm, siteInGOCDB )
res = self.rsClient.addOrModifyStorageElement( SE, srm, siteInGOCDB )
if not res[ 'OK' ]:
gLogger.error( res[ 'Message' ] )
return res
################################################################################
def _syncServices(self):
"""This function is in charge of cleaning the Service table in DB
in case of obsolescence."""
# services in the DB now
#servicesInDB = Utils.unpack(self.rsClient.getService())
servicesInDB = self.rsClient.getService()
if not servicesInDB[ 'OK' ]:
gLogger.error( servicesInDB[ 'Message' ] )
return servicesInDB
servicesInDB = servicesInDB[ 'Value' ]
for service_name, service_type, site_name in servicesInDB:
if not service_type in ["VO-BOX", "CondDB", "VOMS", "Storage"]:
#if Utils.unpack(self.rsClient.getResource(siteName=site_name, serviceType=service_type)) == []:
resource = self.rsClient.getResource( siteName = site_name, serviceType = service_type )
if not resource[ 'OK' ]:
gLogger.error( resource[ 'Message' ] )
return resource
if resource[ 'Value' ] == []:
gLogger.info("Deleting Service %s since it has no corresponding resources." % service_name)
#Utils.protect2(self.rsClient.removeElement, "Service", service_name)
res = self.rsClient.removeElement( "Service", service_name )
if not res[ 'OK' ]:
gLogger.error( res[ 'Message' ] )