def getNgpfGatewayIpMacAddress(self, gatewayIp): """ Description Get the NGPF gateway IP Mac Address. The IPv4 session status must be UP. Parameter gatewayIp: : The gateway IP address. Return: - 0: No Gateway IP address found. - removePacket[Unresolved] - The Gateway IP's Mac Address. """ queryData = {'from': '/', 'nodes': [{'node': 'topology', 'properties': [], 'where': []}, {'node': 'deviceGroup', 'properties': [], 'where': []}, {'node': 'ethernet', 'properties': [], 'where': []}, {'node': 'ipv4', 'properties': ['gatewayIp'], 'where': []} ]} queryResponse = self.ixnObj.query(data=queryData, silentMode=False) for topology in queryResponse.json()['result'][0]['topology']: for deviceGroup in topology['deviceGroup']: try: # Getting in here means IPv4 session status is UP. ipv4Href = deviceGroup['ethernet'][0]['ipv4'][0]['href'] ipv4SessionStatus = self.getSessionStatus(ipv4Href) gatewayIpMultivalue = deviceGroup['ethernet'][0]['ipv4'][0]['gatewayIp'] self.ixnObj.logInfo('\t%s' % ipv4Href) self.ixnObj.logInfo('\tIPv4 sessionStatus: %s' % ipv4SessionStatus) self.ixnObj.logInfo('\tGatewayIpMultivalue: %s' % gatewayIpMultivalue) response = self.ixnObj.getMultivalueValues(gatewayIpMultivalue) valueList = response self.ixnObj.logInfo('gateway IP: %s' % valueList) if gatewayIp in valueList: gatewayIpIndex = valueList.index(gatewayIp) self.ixnObj.logInfo('Found gateway: %s ; Index:%s' % (gatewayIp, gatewayIpIndex)) queryData = {'from': deviceGroup['ethernet'][0]['href'], 'nodes': [{'node': 'ipv4', 'properties': ['gatewayIp', 'resolvedGatewayMac'], 'where': []} ]} queryResponse = self.ixnObj.query(data=queryData, silentMode=False) response = self.ixnObj.get(self.ixnObj.httpHeader+ipv4Href+'?includes=resolvedGatewayMac') gatewayMacAddress = response.json()['resolvedGatewayMac'] self.ixnObj.logInfo('gatewayIpMacAddress: %s' % gatewayMacAddress) if 'Unresolved' in gatewayMacAddress: raise IxNetRestApiException('Gateway Mac Address is unresolved.') return gatewayMacAddress[0] except: pass return 0