def verifyArp(self, ipType='ipv4', deviceGroupName=None , silentMode=True): """ Description Verify for ARP resolvement on every enabled Device Group including inner Device Groups. If device group name is specified , verify ARP on specified device group 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 $sessionStatus and $resolvedGatewayMac lists are aligned. If lindex 0 on $sessionSatus is up, then $resolvedGatewayMac on index 0 expects to have a mac address. Not removePacket[Unresolved]. If not, then arp is not resolved. Requires self.deviceGroupProtocolStacksNgpf() self.verifyNgpfProtocolStarted() Parameter ipType: : ipv4 or ipv6 deviceGroupName: : Name of the device group to send arp request silentMode: : True to show less display on the terminal. False for debugging purposes. """ self.ixnObj.logInfo('Verify ARP: %s' % ipType) unresolvedArpList = [] startFlag = 0 queryData = {'from': '/', 'nodes': [{'node': 'topology', 'properties': [], 'where': []}, {'node': 'deviceGroup', 'properties': [], 'where': []} ]} queryResponse = self.ixnObj.query(data=queryData, silentMode=False) for topology in queryResponse.json()['result'][0]['topology']: for deviceGroup in topology['deviceGroup']: deviceGroupObj = deviceGroup['href'] response = self.ixnObj.get(self.ixnObj.httpHeader+deviceGroupObj, silentMode=silentMode) deviceName = response.json()['name'] if deviceGroupName: if deviceName == deviceGroupName: pass else: continue # Verify if the Device Group is enabled. If not, don't go further. enabledMultivalue = response.json()['enabled'] response = self.getMultivalueValues(enabledMultivalue, silentMode=silentMode) if response[0] == 'false': continue timeout = 30 for counter in range(1,timeout+1): response = self.ixnObj.get(self.ixnObj.httpHeader+deviceGroupObj, silentMode=silentMode) deviceGroupStatus = response.json()['status'] if deviceGroupStatus == 'notStarted': raise IxNetRestApiException('\nDevice Group is not started: {0}.'.format(deviceGroupObj)) if counter < timeout and deviceGroupStatus == 'starting': self.ixnObj.logInfo('\tWait %d/%d' % (counter, timeout), timestamp=False) time.sleep(1) continue if counter < timeout and deviceGroupStatus in ['started', 'mixed']: break if counter == timeout and deviceGroupStatus not in ['started', 'mixed']: raise IxNetRestApiException('\nDevice Group failed to come up: {0}.'.format(deviceGroupObj)) if deviceGroupStatus in ['started', 'mixed']: startFlag = 1 arpResult = self.deviceGroupProtocolStackNgpf(deviceGroupObj, ipType, silentMode=silentMode) if arpResult != 0: unresolvedArpList = unresolvedArpList + arpResult response = self.ixnObj.get(self.ixnObj.httpHeader+deviceGroupObj+'/deviceGroup', silentMode=silentMode) if response.status_code == 200 and response.json() != []: innerDeviceGroupObj = response.json()[0]['links'][0]['href'] self.ixnObj.logInfo('%s' % self.ixnObj.httpHeader+innerDeviceGroupObj, timestamp=False) response = self.ixnObj.get(self.ixnObj.httpHeader+innerDeviceGroupObj, silentMode=silentMode) deviceGroupStatus1 = response.json()['status'] self.ixnObj.logInfo('\tdeviceGroup Status: %s' % deviceGroupStatus1, timestamp=False) if deviceGroupStatus == 'started': arpResult = self.deviceGroupProtocolStackNgpf(innerDeviceGroupObj, ipType, silentMode=silentMode) if arpResult != 0: unresolvedArpList = unresolvedArpList + arpResult if unresolvedArpList == [] and startFlag == 0: # Device group status is not started. raise IxNetRestApiException("\nError: Device Group is not started. It must've went down. Can't verify arp.") if unresolvedArpList != [] and startFlag == 1: # Device group status is started and there are arp unresolved. print() raise IxNetRestApiException('\nError: Unresolved ARP: {0}'.format(unresolvedArpList))