THE GAME HAS CHANGED

Introducing Infoblox Universal DDI ManagementTM

Watch the launch to discover the new era of management for critical network services. Watch Now

API & Integration, DevOps,NetOps,SecOps

Reply

InfobloxConnectionError Not Working

Techie
Posts: 12
577     0

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

Showing results for 
Search instead for 
Did you mean: 

Recommended for You