Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestException not working #376

Open
stevenwmn21 opened this issue Feb 12, 2024 · 0 comments
Open

RequestException not working #376

stevenwmn21 opened this issue Feb 12, 2024 · 0 comments

Comments

@stevenwmn21
Copy link

Operating system is Red Hat Rel 7
python 3.9.15
WAPI v2.12.2

When using the infoblox-client to query an ipv4address object, and there is not a network in IPAM for that address, I am unable to catch the error gracefully, instead the script will bomb out with the error
WARNING:infoblox_client.connector:Failed on object search with url
"Error": "AdmConDataError: None (IBDataError: IB.Data:A network was not found for this address.)", \n "code": "Client.Ibap.Data", \n "text": "A network was not found for this address."\n}'

If I rewrite the code using the requests module, I can catch it gracefully using the requests.exceptions.RequestException exception.

Here is a snipit of code that can not be caught if I pass an IP address that does not belong to an existing network
def search_ipv4addr(connection, search_val: str):
"""Function to get a List of records from IPAM"""
kwargs = {
'max_results': 2000,
}
print(connection)
print(search_val)
try:
result = connection.get_object('ipv4address', { 'ip_address': search_val, '_return_fields': 'discovered_data' } , **kwargs )
except InfobloxConnectionError as con_error:
print(con_error)
exit()
except InfobloxBadWAPICredential as cred_error:
print(cred_error)
print('InfobloxBadWAPICredential')
exit()
except InfobloxTimeoutError as timeout_error:
print(timeout_error)
print('InfobloxTimeoutError')
exit()
else:
return result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant