OpenIxia / IxNetwork

A central location for IxNetwork sample scripts and utilities. Please also visit http://openixia.com
MIT License
50 stars 59 forks source link

Looking for verify arp and ns function. #39

Closed muthvar1 closed 5 years ago

muthvar1 commented 5 years ago

Looking for a call that verifies if arp or ns is resolved and if not lists all the unresolved ns or arp. I see that under ixNetwork there is a call for sending Ns or Arp across all interfaces, but do not see one for validation of arp resolution.

ixnetwork.py: def SendArpAll(self): """Executes the sendArpAll operation on the server.

            Send ARP for all interfaces.

            Raises:
                    NotFoundError: The requested resource does not exist on the server
                    ServerError: The server has encountered an uncategorized error condition
            """
            return self._execute('SendArpAll', payload=locals(), response_object=None)

    def SendNsAll(self):
            """Executes the sendNsAll operation on the server.

            Send neighbor solicitation to all interfaces.

            Raises:
                    NotFoundError: The requested resource does not exist on the server
                    ServerError: The server has encountered an uncategorized error condition
            """
            return self._execute('SendNsAll', payload=locals(), response_object=None)

Looking for something like we have in HLT def verify_arp(self, max_retry=3, handles=False): ''' For all the unresolved ARPs, ixia returns a string in the below format with all the IP addresses '{topology:6 Port:1/4 IP:200.140.2.3 HANDLE:::ixNet::OBJ-/topology:6/deviceGroup:2/ethernet:1/ipv4:2} \ {topology:6 Port:1/4 IP:200.140.2.4 HANDLE:::ixNet::OBJ-/topology:6/deviceGroup:2/ethernet:1/ipv4:2}' This fucntion return iplist ['200.140.2.3', '200.140.2.4'] or iplist, handle_list ''' ip_list = list() handle_list = list() cmd = 'set unresolved [VerifyArpNgpf ipv4 ' + str(max_retry) + ']' unresolved_arp = self.tcl.eval(cmd) if unresolved_arp != '0': for (ip,handle) in re.findall('IP:(.+?) HANDLE:(.+?)}', unresolved_arp): ip_list.append(ip) handle_list.append(handle) pass

remove dups in handles

    handle_list = list(set(handle_list))
    if not handles:
        return ip_list
    else:
        return (ip_list, handle_list)

def verify_nd(self, max_retry=3, handles=False):
    '''
       For all the unresolved NDs, ixia returns a string in the below format
       with all the IP addresses
       '{topology:6 Port:1/4 IP:2000:140:2:0:0:0:3:1 HANDLE:::ixNet::OBJ-/topology:6/deviceGroup:2/ethernet:1/ipv6:2} \
        {topology:6 Port:1/4 IP:2000:140:2:0:0:0:3:2 HANDLE:::ixNet::OBJ-/topology:6/deviceGroup:2/ethernet:1/ipv6:2}'
       This fucntion return iplist ['2000:140:2:0:0:0:3:1', '2000:140:2:0:0:0:3:2']
       or iplist, handle_list
    '''
    ip_list = list()
    handle_list = list()
    cmd = 'set unresolved [VerifyArpNgpf ipv6 ' + str(max_retry) + ']'
    unresolved_nd = self.tcl.eval(cmd)
    if unresolved_nd != '0':
        for (ip,handle) in re.findall('IP:(.+?) HANDLE:(.+?)}', unresolved_nd):
            ip_list.append(ip)
            handle_list.append(handle)
        pass
    #remove dups in handles
    handle_list = list(set(handle_list))
    if not handles:
        return ip_list
    else:
        return (ip_list, handle_list)
hubertgee commented 5 years ago

For RestPy, use the StatViewAssistant module. Take a look at the sample script bgpNgpf.py after calling ixNetwork.StartAllProtocols(). The following line of codes will verify all configured protocols are started first. Then it will verify all configured protocols sessions are UP including IPv4 ARP being resolved. The CheckCondition default timeout is 90 seconds. Raise an exception if the condition is not met otherwise return a bool result.

protocolsSummary = StatViewAssistant(ixNetwork, 'Protocols Summary')
protocolsSummary.CheckCondition('Sessions Not Started', StatViewAssistant.EQUAL, 0)
protocolsSummary.CheckCondition('Sessions Down', StatViewAssistant.EQUAL, 0)
muthvar1 commented 5 years ago

Hi Hubert, Is there a way to list out the ip's that are not resolved in this case?

hubertgee commented 5 years ago

Hi Varghese,

Yes you could get unresolved arp ip addresses. Take a look at the snapshot taken from the API browser. The list of unresolved mac addresses are aligned with the IP addresses that could not resolve the gateway mac. You have to write some code to do a .find() for the Ipv4 object handle and from there you get the attributes for address and unresolvedGatewayMac.

unresolvedMac

Hubert

muthvar1 commented 5 years ago

Thanks Hubert. Will write some code around this then. Is this something Ixia would be providing in a some later update though? Seems like it is something most people would use. HLTAPI had this implemented, from what I remember.

Varghese