本文整理汇总了Python中DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient.getSite方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceStatusClient.getSite方法的具体用法?Python ResourceStatusClient.getSite怎么用?Python ResourceStatusClient.getSite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient
的用法示例。
在下文中一共展示了ResourceStatusClient.getSite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Synchronizer
# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient import getSite [as 别名]
class Synchronizer( object ):
def __init__( self, rsClient = None, rmClient = None ):
self.GOCDBClient = GOCDBClient()
self.rsClient = ResourceStatusClient() if rsClient == None else rsClient
self.rmClient = ResourceManagementClient() if rmClient == None else rmClient
self.synclist = [ 'Sites', 'Resources', 'StorageElements', 'Services', 'RegistryUsers' ]
################################################################################
def sync( self, _a, _b ):
"""
:params:
:attr:`thingsToSync`: list of things to sync
"""
gLogger.info( "!!! Sync DB content with CS content for %s !!!" % ( ", ".join(self.synclist) ) )
for thing in self.synclist:
getattr( self, '_sync' + thing )()
return S_OK()
################################################################################
def __purge_resource( self, resourceName ):
# Maybe remove attached SEs
#SEs = Utils.unpack(self.rsClient.getStorageElement(resourceName=resourceName))
SEs = self.rsClient.getStorageElement( resourceName = resourceName )
if not SEs[ 'OK' ]:
gLogger.error( SEs[ 'Message' ] )
return SEs
#Utils.unpack(self.rsClient.removeElement("StorageElement", [s[0] for s in SEs]))
SEs = [ se[0] for se in SEs ]
res = self.rsClient.removeElement( 'StorageElement', SEs )
if not res[ 'OK' ]:
gLogger.error( res[ 'Message' ] )
return res
# Remove resource itself.
#Utils.unpack(self.rsClient.removeElement("Resource", resourceName))
res = self.rsClient.removeElement( 'Resource', resourceName )
if not res[ 'OK' ]:
gLogger.error( res[ 'Message' ] )
return res
def __purge_site( self, siteName ):
# Remove associated resources and services
#resources = Utils.unpack(self.rsClient.getResource(siteName=siteName))
resources = self.rsClient.getResource( siteName = siteName )
if not resources[ 'OK' ]:
gLogger.error( resources[ 'Message' ] )
return resources
#services = Utils.unpack(self.rsClient.getService(siteName=siteName))
services = self.rsClient.getService( siteName = siteName )
if not services[ 'OK' ]:
gLogger.error( services[ 'Message' ] )
return services
#_ = [self.__purge_resource(r[0]) for r in resources]
for resource in resources:
res = self.__purge_resource( resource[ 0 ] )
if not res[ 'OK' ]:
gLogger.error( res[ 'Message' ] )
return res
#Utils.unpack(self.rsClient.removeElement("Service", [s[0] for s in services]))
services = [ service[ 0 ] for service in services[ 'Value' ] ]
res = self.rsClient.removeElement( 'Service', services )
if not res[ 'OK' ]:
gLogger.error( res[ 'Message' ] )
return res
# Remove site itself
#Utils.unpack(self.rsClient.removeElement("Site", siteName))
res = self.rsClient.removeElement( 'Site', siteName )
if not res[ 'OK' ]:
gLogger.info( res[ 'Message' ] )
return res
def _syncSites( self ):
"""
Sync DB content with sites that are in the CS
"""
def getGOCTier(sitesList):
return "T" + str(min([int(v) for v in CS.getSiteTiers(sitesList)]))
# sites in the DB now
#sitesDB = set((s[0] for s in Utils.unpack(self.rsClient.getSite())))
sites = self.rsClient.getSite()
if not sites[ 'OK' ]:
gLogger.error( sites[ 'Message' ] )
return sites
#.........这里部分代码省略.........