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)
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:Looking forward to the updates! Thanks!