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

Bug in function getTrafficItemPktHeaderStackObj #121

Closed Alvinlst closed 3 years ago

Alvinlst commented 3 years ago

The buggy code is here.

Due to the incorrect indentation, this else statement will always be conducted, so an exception will always be raised whenever this method is called.

This could be fixed very easily by returning the stackObj immediately if found:

        for eachStack in response.json():
            currentStackDisplayName = eachStack['displayName'].strip()
            self.ixnObj.logInfo('Packet header name: {0}'.format(currentStackDisplayName), timestamp=False)
            if bool(re.match('^{0}$'.format(packetHeaderName), currentStackDisplayName, re.I)):
                self.ixnObj.logInfo('\nstack: {0}: {1}'.format(eachStack, currentStackDisplayName), timestamp=False)
                stackObj = eachStack['links'][0]['href']
                return stackObj

        raise IxNetRestApiException('\nError: No such stack name found. Verify stack name existence and spelling: %s' % packetHeaderName)

Looking forward to the updates! Thanks!

hubertgee commented 3 years ago

Fixed