本文整理汇总了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 ]
示例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 )