def VerifyArpNgpfPy(ipType='ipv4'): # This API requires: # 1> DeviceGroupProtocolStacksNgpfPy # # ipType: ipv4 or ipv6 # # This API will verify for ARP session resolvement on # every TopologyGroup/DeviceGroup and/or # TopologyGroup/DeviceGroup/DeviceGroup that has protocol "enabled". # # How it works? # Each device group has a list of $sessionStatus: up, down or notStarted. # If the deviceGroup has sessionStatus as "up", then ARP will be verified. # It also has a list of $resolvedGatewayMac: MacAddress or removePacket[Unresolved] # These two lists are aligned. # If lindex 0 on $sessionSatus is up, then the API expects lindex 0 on $resolvedGatewayMac # to have a mac address. # If not, then arp is not resolved. # This script will wait up to the $maxRetry before it declares failed. # # Return 0 if ARP passes. # Return 1 if device group is not started # Return a list of unresolved ARPs startFlag = 0 unresolvedArpList = [] for topology in ixNet.getList(ixNet.getRoot(), 'topology'): for deviceGroup in ixNet.getList(topology, 'deviceGroup'): print '\n', deviceGroup deviceGroupStatus = ixNet.getAttribute(deviceGroup, '-status') print '\tdeviceGroup status:', deviceGroupStatus if deviceGroupStatus == 'started': startFlag = 1 arpResult = DeviceGroupProtocolStackNgpfPy(deviceGroup, ipType) if arpResult != 0: unresolvedArpList = unresolvedArpList + arpResult if ixNet.getList(deviceGroup, 'deviceGroup') != '': for innerDeviceGroup in ixNet.getList(deviceGroup, 'deviceGroup'): print '\n', innerDeviceGroup arpResult = DeviceGroupProtocolStackNgpfPy(innerDeviceGroup, ipType) if arpResult != 0: unresolvedArpList = unresolvedArpList + arpResult elif ixNet.getAttribute(deviceGroup, '-status') == 'mixed': startFlag = 1 print '\tWarning: Ethernet stack is started, but layer3 is not started' arpResult = DeviceGroupProtocolStackNgpf(deviceGroup, ipType) if arpResult != 0: unresolvedArpList = unresolvedArpList + arpResult if ixNet.getList(deviceGroup, 'deviceGroup') != '': for innerDeviceGroup in ixNet.getList(deviceGroup, 'deviceGroup'): print '\n', innerDeviceGroup deviceGroupStatus2 = ixNet.getAttribute(innerDeviceGroup, '-status') if deviceGroupStatus2 == 'started': arpResult = DeviceGroupProtocolStackNgpfPy(deviceGroup, ipType) if arpResult != 0: unresolvedArpList = unresolvedArpList + arpResult if unresolvedArpList == [] and startFlag == 1: return 0 if unresolvedArpList == [] and startFlag == 0: return 1 if unresolvedArpList != [] and startFlag == 1: print '\n' for unresolvedArp in unresolvedArpList: print 'UnresolvedArps:', unresolvedArp print '\n' return unresolvedArpList