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


Python Network.checkHostsMatch方法代码示例

本文整理汇总了Python中DIRAC.Core.Utilities.Network.checkHostsMatch方法的典型用法代码示例。如果您正苦于以下问题:Python Network.checkHostsMatch方法的具体用法?Python Network.checkHostsMatch怎么用?Python Network.checkHostsMatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.Core.Utilities.Network的用法示例。


在下文中一共展示了Network.checkHostsMatch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __reduceComponentList

# 需要导入模块: from DIRAC.Core.Utilities import Network [as 别名]
# 或者: from DIRAC.Core.Utilities.Network import checkHostsMatch [as 别名]
 def __reduceComponentList( self, componentList ):
   """
   Only keep the most restrictive components
   """
   for i in range( len( componentList ) ):
     component = componentList[i]
     for j in range( len( componentList ) ):
       if i == j or componentList[j] == False :
         continue
       potentiallyMoreRestrictiveComponent = componentList[j]
       match = True
       for key in component:
         if key not in potentiallyMoreRestrictiveComponent:
           match = False
           break
         if key == 'Host':
           result = Network.checkHostsMatch( component[key],
                                             potentiallyMoreRestrictiveComponent[key] )
           if not result[ 'OK' ] or not result[ 'Value' ]:
             match = False
             break
         else:
           if component[key] != potentiallyMoreRestrictiveComponent[key]:
             match = False
             break
       if match:
         componentList[i] = False
         break
   return [ comp for comp in componentList if comp != False ]
开发者ID:sbel,项目名称:bes3-jinr,代码行数:31,代码来源:ComponentMonitoringDB.py

示例2: __addFoundDefinedComponent

# 需要导入模块: from DIRAC.Core.Utilities import Network [as 别名]
# 或者: from DIRAC.Core.Utilities.Network import checkHostsMatch [as 别名]
 def __addFoundDefinedComponent( self, compDictList ):
   cD = self.walkSet( self.__requiredSet, compDictList[0] )
   dbD = self.walkSet( self.__dbSet, compDictList[0] )
   now = Time.dateTime()
   unmatched = compDictList
   for dbComp in dbD:
     if 'Status' not in dbComp:
       self.__setStatus( dbComp, 'OK' )
       if dbComp[ 'Type' ] == "service":
         if 'Port' not in dbComp:
           self.__setStatus( dbComp, 'Error', "Port is not defined" )
         elif dbComp[ 'Port' ] not in [ compDict[ 'Port' ] for compDict in compDictList if 'Port' in compDict ]:
           self.__setStatus( compDict, 'Error',
                             "Port (%s) is different that specified in the CS" % dbComp[ 'Port' ] )
       elapsed = now - dbComp[ 'LastHeartbeat' ]
       elapsed = elapsed.days * 86400 + elapsed.seconds
       if elapsed > self.__maxSecsSinceHeartbeat:
         self.__setStatus( dbComp, "Error",
                           "Last heartbeat was received at %s (%s secs ago)" % ( dbComp[ 'LastHeartbeat' ],
                                                                                 elapsed ) )
     cD.append( dbComp )
     #See if we have a perfect match
     newUnmatched = []
     for unmatchedComp in unmatched:
       perfectMatch = True
       for field in unmatchedComp:
         if field in ( 'Status', 'Message' ):
           continue
         if field not in dbComp:
           perfectMatch = False
           continue
         if field == 'Host':
           result = Network.checkHostsMatch( unmatchedComp[ field ], dbComp[ field ] )
           if not result[ 'OK' ] or not result[ 'Value' ]:
             perfectMatch = False
         else:
           if unmatchedComp[ field ] != dbComp[ field ]:
             perfectMatch = False
       if not perfectMatch:
         newUnmatched.append( unmatchedComp )
     unmatched = newUnmatched
   for unmatchedComp in unmatched:
     self.__setStatus( unmatchedComp, "Error", "There is no component up with this properties" )
     cD.append( unmatchedComp )
开发者ID:sbel,项目名称:bes3-jinr,代码行数:46,代码来源:ComponentMonitoringDB.py


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