def verifyProtocolSessionsUp(self, protocolViewName='BGP Peer Per Port', timeout=60): """ Description Verify the specified protocol sessions are UP or not. Parameters protocolViewName: : The protocol view name. Get this name from API browser or in IxNetwork GUI statistic tabs. timeout: : Duration to wait for the protocol sessions to up. Default = 60 seconds. protocolViewName options: 'BFD Aggregated Statistics' 'BGP Aggregated Statistics' 'ISIS Aggregated Statistics' 'OSPF Aggregated Statistics' 'RIPng Aggregated Statistics' 'RIP Aggregated Statistics' 'LDP Aggregated Statistics' 'PIMSM Aggregated Statistics' 'MPLSOAM Aggregated Statistics' Examples verifyProtocolSessionsUp(protcolViewName='ospf Aggregated Statistics') verifyProtocolSessionsUp(protcolViewName='ospf Aggregated Statistics',timeout=90) """ totalSessionsDetectedUp = 0 totalSessionsDetectedDown = 0 totalPortsUpFlag = 0 self.ixnObj.logInfo('Protocol view name %s' % protocolViewName) time.sleep(10) for counter in range(1, timeout + 1): stats = self.statObj.getStats(viewName=protocolViewName, displayStats=False) totalPorts = len(stats.keys()) # Length stats.keys() represents total ports. self.ixnObj.logInfo('ProtocolName: {0}'.format(protocolViewName)) for session in stats.keys(): if re.search('OSPF', protocolViewName, re.I): sessionsUp = int(stats[session]['Full Nbrs.']) totalSessions = int(stats[session]['Sess. Configured']) elif re.search('BGP', protocolViewName, re.I): sessionsUp = int(stats[session]['Sess. Up']) totalSessions = int(stats[session]['Sess. Configured']) elif re.search('ISIS', protocolViewName, re.I): sessionsUp = int(stats[session]['L2 Sess. Up']) totalSessions = int(stats[session]['L2 Sess. Configured']) elif re.search('RIPng', protocolViewName, re.I) or re.search('BFD', protocolViewName, re.I): sessionsUp = int(stats[session]['Routers Running']) totalSessions = int(stats[session]['Routers Configured']) elif re.search('RIP', protocolViewName, re.I): sessionsUp = int(stats[session]['Request Packet Tx']) totalSessions = int(stats[session]['Routers Configured']) elif re.search('LACP', protocolViewName, re.I): sessionsUp = int(stats[session]['LAG Member Ports UP']) totalSessions = int(stats[session]['Total LAG Member Ports']) elif re.search('LDP', protocolViewName, re.I): sessionsUp = int(stats[session]['Targeted Sess. Up']) totalSessions = int(stats[session]['Targeted Sess. Configured']) elif re.search('MPLS', protocolViewName, re.I): sessionsUp = int(stats[session]['BFD Up-Sessions']) totalSessions = int(stats[session]['BFD Session Count']) elif re.search('PIM', protocolViewName, re.I): sessionsUp = int(stats[session]['Rtrs. Running']) totalSessions = int(stats[session]['Rtrs. Configured']) # totalSessionsNotStarted = int(stats[session]['Sessions Not Started']) totalExpectedSessionsUp = totalSessions if totalExpectedSessionsUp != 0: self.ixnObj.logInfo( '\n\tPortName: {0}\n\t TotalSessionsUp: {1}\n\t ExpectedTotalSessionsup: {2}'.format( stats[session]['Port Name'], sessionsUp, totalExpectedSessionsUp), timestamp=False) if counter < timeout and sessionsUp != totalExpectedSessionsUp: self.ixnObj.logInfo('\t Protocol Session is still down', timestamp=False) if counter < timeout and sessionsUp == totalExpectedSessionsUp: totalPortsUpFlag += 1 if totalPortsUpFlag == totalPorts: self.ixnObj.logInfo('All protocol sessions are up!') return if counter == timeout and sessionsUp != totalExpectedSessionsUp: raise IxNetRestApiException('Protocol Sessions failed to come up') self.ixnObj.logInfo('\n\tWait {0}/{1} seconds\n'.format(counter, timeout), timestamp=False) time.sleep(1)