本文整理汇总了Python中DIRAC.ResourceStatusSystem.Utilities.CSHelpers.getDomainSites方法的典型用法代码示例。如果您正苦于以下问题:Python CSHelpers.getDomainSites方法的具体用法?Python CSHelpers.getDomainSites怎么用?Python CSHelpers.getDomainSites使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.ResourceStatusSystem.Utilities.CSHelpers
的用法示例。
在下文中一共展示了CSHelpers.getDomainSites方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _syncSites
# 需要导入模块: from DIRAC.ResourceStatusSystem.Utilities import CSHelpers [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.CSHelpers import getDomainSites [as 别名]
def _syncSites(self):
"""
Sync sites: compares CS with DB and does the necessary modifications.
"""
gLogger.info("-- Synchronizing sites --")
domainSitesCS = CSHelpers.getDomainSites()
if not domainSitesCS["OK"]:
return domainSitesCS
domainSitesCS = domainSitesCS["Value"]
for domainName, sitesCS in domainSitesCS.items():
gLogger.verbose("%s sites found in CS for %s domain" % (len(sitesCS), domainName))
sitesDB = self.rStatus.selectStatusElement(
"Site", "Status", elementType=domainName, meta={"columns": ["name"]}
)
if not sitesDB["OK"]:
return sitesDB
sitesDB = [siteDB[0] for siteDB in sitesDB["Value"]]
# Sites that are in DB but not in CS
toBeDeleted = list(set(sitesDB).difference(set(sitesCS)))
gLogger.verbose("%s sites to be deleted" % len(toBeDeleted))
# Delete sites
for siteName in toBeDeleted:
deleteQuery = self.rStatus._extermineStatusElement("Site", siteName)
gLogger.verbose("... %s" % siteName)
if not deleteQuery["OK"]:
return deleteQuery
sitesTuple = self.rStatus.selectStatusElement(
"Site", "Status", elementType=domainName, meta={"columns": ["name", "statusType"]}
)
if not sitesTuple["OK"]:
return sitesTuple
sitesTuple = sitesTuple["Value"]
statusTypes = self.rssConfig.getConfigStatusType(domainName)
# For each ( site, statusType ) tuple not present in the DB, add it.
siteStatusTuples = [(site, statusType) for site in sitesCS for statusType in statusTypes]
toBeAdded = list(set(siteStatusTuples).difference(set(sitesTuple)))
gLogger.verbose("%s site entries to be added" % len(toBeAdded))
for siteTuple in toBeAdded:
query = self.rStatus.addIfNotThereStatusElement(
"Site",
"Status",
name=siteTuple[0],
statusType=siteTuple[1],
status="Unknown",
elementType=domainName,
reason="Synchronized",
)
if not query["OK"]:
return query
return S_OK()
示例2: _syncSites
# 需要导入模块: from DIRAC.ResourceStatusSystem.Utilities import CSHelpers [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.CSHelpers import getDomainSites [as 别名]
def _syncSites( self ):
'''
Sync sites: compares CS with DB and does the necessary modifications.
'''
gLogger.info( '-- Synchronizing sites --')
domainSitesCS = CSHelpers.getDomainSites()
if not domainSitesCS[ 'OK' ]:
return domainSitesCS
domainSitesCS = domainSitesCS[ 'Value' ]
for domainName, sitesCS in domainSitesCS.items():
gLogger.verbose( '%s sites found in CS for %s domain' % ( len( sitesCS ), domainName ) )
sitesDB = self.rStatus.selectStatusElement( 'Site', 'Status', elementType = domainName,
meta = { 'columns' : [ 'name' ] } )
if not sitesDB[ 'OK' ]:
return sitesDB
sitesDB = [ siteDB[0] for siteDB in sitesDB[ 'Value' ] ]
# Sites that are in DB but not in CS
toBeDeleted = list( set( sitesDB ).difference( set( sitesCS ) ) )
gLogger.verbose( '%s sites to be deleted' % len( toBeDeleted ) )
# Delete sites
for siteName in toBeDeleted:
deleteQuery = self.rStatus._extermineStatusElement( 'Site', siteName )
gLogger.verbose( '... %s' % siteName )
if not deleteQuery[ 'OK' ]:
return deleteQuery
sitesTuple = self.rStatus.selectStatusElement( 'Site', 'Status', elementType = domainName,
meta = { 'columns' : [ 'name', 'statusType' ] } )
if not sitesTuple[ 'OK' ]:
return sitesTuple
sitesTuple = sitesTuple[ 'Value' ]
statusTypes = self.rssConfig.getConfigStatusType( domainName )
# For each ( site, statusType ) tuple not present in the DB, add it.
siteStatusTuples = [ ( site, statusType ) for site in sitesCS for statusType in statusTypes ]
toBeAdded = list( set( siteStatusTuples ).difference( set( sitesTuple ) ) )
gLogger.verbose( '%s site entries to be added' % len( toBeAdded ) )
for siteTuple in toBeAdded:
query = self.rStatus.addIfNotThereStatusElement( 'Site', 'Status',
name = siteTuple[ 0 ],
statusType = siteTuple[ 1 ],
status = 'Unknown',
elementType = domainName,
reason = 'Synchronized' )
if not query[ 'OK' ]:
return query
return S_OK()