def verifyProtocolSessionsUp2(self, protocolViewName='Protocols Summary', timeout=60): """ Description For IxNetwork version >= 8.50. Defaults to Protocols Summary to verify all configured protocol sessions. There is no need to specify specific protocols to verify. However, you still have the option to specific protocol session to verify. Note: This get stats by using /statistics/statview//data. Prior to 8.50, get stats uses /statistics/statview//page, which is deprecated started 8.50. /statistics/statview//data is more robust. Parameter protocolViewName: : The protocol view name. Get this name from API browser or in IxNetwork GUI statistic tabs. Defaults to 'Protocols Summary' timeout: : The timeout value to declare as failed. Default = 60 seconds. protocolViewName options: 'BGP Peer Per Port' 'DHCPV4 Client Per Port' 'DHCPV4 Server Per Port' 'ISIS-L3 RTR Per Port' 'OSPFv2-RTR Per Port' 'Protocols Summary' """ totalSessionsDetectedUp = 0 totalSessionsDetectedDown = 0 totalPortsUpFlag = 0 for counter in range(1,timeout+1): stats = self.statObj.getStatsData(viewName=protocolViewName, displayStats=False, silentMode=True) self.ixnObj.logInfo('\n%-16s %-14s %-16s %-23s %-22s' % ('Name', 'SessionsUp', 'SessionsDown', 'ExpectedSessionsUp', 'SessionsNotStarted' ), timestamp=False) self.ixnObj.logInfo('-'*91, timestamp=False) totalPorts = len(stats.keys()) ;# Length stats.keys() represents total ports or total protocols. sessionDownFlag = 0 sessionNotStartedFlag = 0 sessionFailedFlag = 0 for session in stats.keys(): if 'Protocol Type' in stats[session]: label = stats[session]['Protocol Type'] if 'Port' in stats[session]: label = stats[session]['Port'] sessionsDown = int(stats[session]['Sessions Down']) sessionsUp = int(stats[session]['Sessions Up']) totalSessions = int(stats[session]['Sessions Total']) sessionsNotStarted = int(stats[session]['Sessions Not Started']) expectedSessionsUp = totalSessions - sessionsNotStarted self.ixnObj.logInfo('%-16s %-14s %-16s %-23s %-22s' % (label, sessionsUp, sessionsDown, expectedSessionsUp, sessionsNotStarted), timestamp=False) if counter < timeout: if sessionsNotStarted != 0: sessionNotStartedFlag = 1 if sessionsDown != 0: sessionDownFlag = 1 if counter == timeout: if sessionsNotStarted != 0: raise IxNetRestApiException('Sessions did not start up') if sessionsDown != 0: raise IxNetRestApiException('Sessions failed to come up') if sessionNotStartedFlag == 1: if counter < timeout: sessionNotStartedFlag = 0 self.ixnObj.logInfo('Protocol sessions are not started yet. Waiting {0}/{1} seconds'.format( counter, timeout)) time.sleep(1) continue if counter == timeout: raise IxNetRestApiException('Sessions are not started') if sessionDownFlag == 1: print('\nWaiting {0}/{1} seconds'.format(counter, timeout)) time.sleep(1) continue if counter < timeout and sessionDownFlag == 0: print('\nProtocol sessions are all up') break