def verifyProtocolSessionsUp1(self, protocolViewName='BGP Peer Per Port', timeout=60): """ Description Verify a specified protocol sessions for UP. This method is mainly for IxNetwork version prior to 8.50. 8.50+ could still use this method, but using verifyProtocolSessionsUp2 is more robust because 8.50 introduced new APIs. Parameter protocolViewName: The protocol view name. Some protocolViewName options: 'ISIS-L3 RTR Per Port' 'BGP Peer Per Port' 'OSPFv2-RTR Per Port' """ totalSessionsDetectedUp = 0 totalSessionsDetectedDown = 0 totalPortsUpFlag = 0 for counter in range(1,timeout+1): stats = self.ixnObj.getStatsPage(viewName=protocolViewName, displayStats=False) totalPorts = len(stats.keys()) ;# Length stats.keys() represents total ports. self.ixnObj.logInfo('\nProtocolName: {0}'.format(protocolViewName)) for session in stats.keys(): sessionsUp = int(stats[session]['Sessions Up']) totalSessions = int(stats[session]['Sessions Total']) totalSessionsNotStarted = int(stats[session]['Sessions Not Started']) totalExpectedSessionsUp = totalSessions - totalSessionsNotStarted self.ixnObj.logInfo('\n\tPortName: {0}\n\t TotalSessionsUp: {1}\n\t ExpectedTotalSessionsup: {2}'.format( stats[session]['Port'], sessionsUp, totalExpectedSessionsUp)) if counter < timeout and sessionsUp != totalExpectedSessionsUp: self.ixnObj.logInfo('\t Session is still down') if counter < timeout and sessionsUp == totalExpectedSessionsUp: totalPortsUpFlag += 1 if totalPortsUpFlag == totalPorts: self.ixnObj.logInfo('\n\tAll sessions are up!') return if counter == timeout and sessionsUp != totalExpectedSessionsUp: raise IxNetRestApiException('\nSessions failed to come up') self.ixnObj.logInfo('\n\tWait {0}/{1} seconds'.format(counter, timeout)) print() time.sleep(1)