當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。