def sendPing(self, srcIpList=None, destIp=None): """ Description Send PING from the the list of srcIp to destIp. This function will query for the IPv4 object that has the srcIp address. Parameters srcIpList: : The srcIp addresses in a list. Could be 1 or more src IP addresses, but must be in a list. This API will look up the IPv4 object that has the srcIp. destIp: : The destination IP to ping. Returns Success: 1 requests sent, 1 replies received. Failed: Ping: 1.1.1.1 -> 1.1.1.10 failed - timeout 0: Returns 0 if no src IP address found in the srcIpList. """ queryData = {'from': '/', 'nodes': [{'node': 'topology', 'properties': ['name'], 'where': []}, {'node': 'deviceGroup', 'properties': [], 'where': []}, {'node': 'ethernet', 'properties': [], 'where': []}, {'node': 'ipv4', 'properties': ['address', 'count'], 'where': []}] } url = self.ixnObj.sessionUrl+'/topology/deviceGroup/ethernet/ipv4/operations/sendping' queryResponse = self.ixnObj.query(data=queryData) srcIpIndexList = [] noSrcIpIndexFound = [] for topology in queryResponse.json()['result'][0]['topology']: for ipv4 in topology['deviceGroup'][0]['ethernet'][0]['ipv4']: ipv4Obj = ipv4['href'] ipv4Count = ipv4['count'] ipv4AddressMultivalue = ipv4['address'] ipv4AddressList = self.ixnObj.getMultivalueValues(ipv4AddressMultivalue) url = self.ixnObj.httpHeader+ipv4Obj+'/operations/sendping' for eachSrcIp in srcIpList: # Don't error out if eachSrcIp is not found in the ipv4AddressList because # it may not be in the current for loop topology. try: srcIpIndex = ipv4AddressList.index(eachSrcIp) srcIpIndexList.append(srcIpIndex+1) except: noSrcIpIndexFound.append(eachSrcIp) pass if srcIpIndexList != []: data = {'arg1': ipv4Obj, 'arg2': destIp, 'arg3': srcIpIndexList} response = self.ixnObj.post(url, data=data) self.ixnObj.waitForComplete(response, url+response.json()['id']) self.ixnObj.logInfo(response.json()['result'][0]['arg3']) if noSrcIpIndexFound != []: self.ixnObj.logError('No srcIp address found in configuration: {0}'.format(noSrcIpIndexFound)) return response.json()['result'][0]['arg3'] # Reset these variable to empty list. srcIpIndexList = [] noSrcIpIndexFound = [] if srcIpIndexList == []: raise IxNetRestApiException('No srcIp addresses found in configuration: {0}'.format(srcIpList))