def VerifySessionsOspfV2NgpfPy(): # This API will loop through all Topology Groups for ospf configuration and # verify all of its sessions. # # Returns 0 if all sessions are UP. # Returns a list of local router ID addresses that are down. 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 ospfV2 in ixNet.getList(ipv4, 'ospfv2'): print '\nVerifying ospfV2Router sessions:', ospfV2 sessionStatusList = ixNet.getAttribute(ospfV2, '-sessionStatus') localRouterIdList = ixNet.getAttribute(ospfV2, '-localRouterID') if 'down' in sessionStatusList: duplicateIndexes = [index for index,element in enumerate(sessionStatusList) if element == 'down'] returnList = [] print 'duplicateIndexes:', duplicateIndexes for eachIndex in duplicateIndexes: localRouterIpAddress = localRouterIdList[eachIndex] returnList.append(localRouterIpAddress) print 'Local router ID Address is down:', localRouterIpAddress return returnList else: return 0