当前位置: 首页>>代码示例>>Python>>正文


Python CSHelpers.getDomainSites方法代码示例

本文整理汇总了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()
开发者ID:yujikato,项目名称:DIRAC,代码行数:68,代码来源:Synchronizer.py

示例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()
开发者ID:DIRACGrid-test,项目名称:DIRAC,代码行数:63,代码来源:Synchronizer.py


注:本文中的DIRAC.ResourceStatusSystem.Utilities.CSHelpers.getDomainSites方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。