def VerifyAllProtocolSessionsNgpfPy(): # This API will loop through each created Topology Group and verify # all the created protocols for session up for up to 90 seconds total. # # Returns 0 if all sessions are UP. # Returns 1 if any session remains DOWN after 90 seconds. protocolList = ['ancp', 'bfdv4Interface', 'bgpIpv4Peer', 'dhcpv4relayAgent', 'dhcpv4server', 'geneve', 'greoipv4', 'igmpHost', 'igmpQuerier', 'lac', 'ldpBasicRouter', 'ldpConnectedInterface', 'ldpTargetedRouter', 'lns', 'openFlowController', 'openFlowSwitch', 'ospfv2', 'ovsdbcontroller', 'ovsdbserver', 'pcc', 'pce', 'pcepBackupPCEs', 'pimV4Interface', 'ptp', 'rsvpteIf', 'rsvpteLsps', 'tag', 'vxlan' ] sessionDownList = ['down', 'notStarted'] startCounter = 1 timeEnd = 120 import time for protocol in protocolList: for topology in ixNet.getList(ixNet.getRoot(), 'topology'): for deviceGroup in ixNet.getList(topology, 'deviceGroup'): for ethernet in ixNet.getList(deviceGroup, 'ethernet'): for ipv4 in ixNet.getList(ethernet, 'ipv4'): for currentProtocol in ixNet.getList(ipv4, protocol): for timer in range(startCounter, timeEnd+1): currentStatus = ixNet.getAttribute(currentProtocol, '-sessionStatus') print '\n%s' % currentProtocol print '\tTotal sessions: %d' % len(currentStatus) totalDownSessions = 0 for eachStatus in currentStatus: if eachStatus != 'up': totalDownSessions += 1 print '\tTotal sessions Down: %d' % totalDownSessions if timer < timeEnd and [element for element in sessionDownList if element in currentStatus] == []: print '\tProtocol sessions are all up' startCounter = timer break if timer < timeEnd and [element for element in sessionDownList if element in currentStatus] != []: print '\tWait %d/%d seconds' % (timer, timeEnd) time.sleep(1) continue if timer == timeEnd and [element for element in sessionDownList if element in currentStatus] != []: print '\tProtocol session failed to come up:' return 1 return 0