def DeviceGroupProtocolStackNgpfPy(deviceGroup, ipType): # This Proc is an internal API for VerifyArpNgpf. # It's created because each deviceGroup has IPv4/IPv6 and # a deviceGroup could have inner deviceGroup that has IPv4/IPv6. # Therefore, you can loop device groups. import re unresolvedArpList = [] for ethernet in ixNet.getList(deviceGroup, 'ethernet'): for ipProtocol in ixNet.getList(ethernet, ipType): resolvedGatewayMac = ixNet.getAttribute(ipProtocol, '-resolvedGatewayMac') for index in range(0, len(resolvedGatewayMac)): if (bool(re.match('.*Unresolved.*', resolvedGatewayMac[index]))): multivalueNumber = ixNet.getAttribute(ipProtocol, '-address') srcIpAddrNotResolved = ixNet.getAttribute(ixNet.getRoot()+multivalueNumber, '-values')[index] print '\tFailed to resolveARP:', srcIpAddrNotResolved unresolvedArpList.append(srcIpAddrNotResolved) if unresolvedArpList == []: print '\tARP is resolved' return 0 else: return unresolvedArpList stics" "Flow Statistics" "Traffic Item Statistics" ''' viewList = ixNet.getList(ixNet.getRoot()+'/statistics', 'view') statViewSelection = getStatsBy try: statsViewIndex = viewList.index('::ixNet::OBJ-/statistics/view:"' + getStatsBy +'"') except Exception, errMsg: sys.exit('\nNo such statistic name: %s' % getStatsBy) # ::ixNet::OBJ-/statistics/view:"Flow Statistics" view = viewList[statsViewIndex] columnList = ixNet.getAttribute(view+'/page', '-columnCaptions') #print '\n', columnList if csvFile != None: import csv csvFileName = csvFile.replace(' ', '_') if csvEnableFileTimestamp: import datetime timestamp = datetime.datetime.now().strftime('%H%M%S') if '.' in csvFileName: csvFileNameTemp = csvFileName.split('.')[0] csvFileNameExtension = csvFileName.split('.')[1] csvFileName = csvFileNameTemp+'_'+timestamp+'.'+csvFileNameExtension else: csvFileName = csvFileName+'_'+timestamp csvFile = open(csvFileName, 'w') csvWriteObj = csv.writer(csvFile) csvWriteObj.writerow(columnList) startTime = 1 stopTime = 30 for timer in xrange(startTime, stopTime + 1): totalPages = ixNet.getAttribute(view+'/page', '-totalPages') if totalPages == 'null': print 'GetStatView: Getting total pages for %s is not ready: %s/%s' % (getStatsBy, startTime, stopTime) time.sleep(2) else: break row = 0 statDict = {} print '\nPlease wait for all the stats to be queried ...' for currentPage in xrange(1, int(totalPages)+1): ixNet.setAttribute(view+'/page', '-currentPage', currentPage) ixNet.commit() whileLoopStopCounter = 0 while (ixNet.getAttribute(view+'/page', '-isReady')) != 'true': if whileLoopStopCounter == 5: print'\nGetStatView: Could not get stats' return 1 if whileLoopStopCounter < 5: print'\nGetStatView: Not ready yet. Waiting %s/5 seconds ...' % whileLoopStopCounter time.sleep(1) whileLoopStopCounter += 1 pageList = ixNet.getAttribute(view+'/page', '-rowValues') totalFlowStatistics = len(pageList) for pageListIndex in xrange(0, totalFlowStatistics): rowList = pageList[pageListIndex] if csvFile != None: csvWriteObj.writerow(rowList[0]) for rowIndex in xrange(0, len(rowList)): row += 1 cellList = rowList[rowIndex] statDict[row] = {} # CellList: ['Ethernet - 002', 'Ethernet - 001', 'OSPF T1 to T2', '206.27.0.0-201.27.0.0', 'OSPF T1 to T2-FlowGroup-1 - Flow Group 0002', '1225', '1225', '0', '0', '0', '0', '0', '0', '156800', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '00:00:00.781', '00:00:00.849'] index = 0 for statValue in cellList: statDict[row].update({columnList[index]: statValue}) index += 1 if csvFile != None: csvFile.close() return statDict