def VerifyProtocolSessionStatusUpNgpfHlPy(protocolHandleList, totalTime=60): ''' protocolHandleList: One or more protocol handles in a list to verify for sessions status 'UP'. Protocol handle example: /topology:1/deviceGroup:1/ethernet:1/ipv4:1 /topology:1/deviceGroup:1/ethernet:1/ipv4:1/ospfv2:1 ''' errorFlag = 0 for eachProtocolSessionToVerify in protocolHandleList: for timer in range(1, totalTime+1): sessionStatus = ixia_ngpf.protocol_info( handle = eachProtocolSessionToVerify, mode = 'aggregate' ) currentSessionUp = sessionStatus[eachProtocolSessionToVerify]['aggregate']['sessions_up'] totalSessions = sessionStatus[eachProtocolSessionToVerify]['aggregate']['sessions_total'] print '\nVerifying protocol sessions', eachProtocolSessionToVerify print '\t%s/%s: CurrentSessionUp:%s TotalSessions:%s\n' % (timer, totalTime, currentSessionUp, totalSessions) if timer < totalTime and currentSessionUp != totalSessions: time.sleep(1) continue if timer < totalTime and currentSessionUp == totalSessions: break if timer == totalTime and currentSessionUp != totalSessions: print '\nError: It has been %s seconds and total sessions are not all UP. ' % timer errorFlag = 1 if errorFlag: sys.exit()