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

InfobloxConnectionError Hides reason for failed query #354

Open
scetron opened this issue Nov 18, 2022 · 2 comments
Open

InfobloxConnectionError Hides reason for failed query #354

scetron opened this issue Nov 18, 2022 · 2 comments

Comments

@scetron
Copy link

scetron commented Nov 18, 2022

The InfobloxConnectionError returned when searching for IPv4Address objects (that don't exist) hides the error response from Infoblox that the network does not exist and gives an invalid URL instead.

{'reason': HTTPError('400 Client Error: Bad Request for url: https://infoblox/wapi/v2.12/ipv4address?network=10.0.0.0%2F18&status=USED&_proxy_search=GM')}

The error should be more descriptive at the very least. I would argue that the error is wrong as technically the URL is correct.

@sarya-infoblox
Copy link
Collaborator

Hi @scetron, Thanks for bringing up this issue, we will take try and fix it in our next release.

@JkhatriInfobox
Copy link
Contributor

JkhatriInfobox commented Oct 22, 2024

Hi @scetron,

with the below script we tried to check the issue, the actual error is coming as a warning in to the console log.

from infoblox_client import objects
from infoblox_client import connector
import urllib3
import datetime
import logging
urllib3.disable_warnings()
# Configure the root logger
logging.basicConfig(level=logging.INFO, format="%(asctime)s — %(name)s — %(levelname)s — %(message)s")
opts = {'host': 'GRID-IP', 'username': 'admin', 'password': 'Infoblox@123'}
conn = connector.Connector(opts)

ipv4address = conn.get_object('ipv4address', {'network': '10.100.12.0/24'})

print(ipv4address)

As same error is being reproduced with the script but as a log it is also sharing the actual content of the response received from the NIOS API as below:.

2024-10-22 15:35:47,886 — infoblox_client.connector — WARNING — Failed on object search with url https://172.28.83.33/wapi/v2.10/ipv4address?network=10.100.12.0%2F24: b'{ "Error": "AdmConProtoError: 10.100.12.0/24 does not match any network",\n "code": "Client.Ibap.Proto",\n "text": "10.100.12.0/24 does not match any network"\n}'
2024-10-22 15:35:47,909 — infoblox_client.connector — WARNING — Failed on object search with url https://172.28.83.33/wapi/v2.10/ipv4address?network=10.100.12.0%2F24&_proxy_search=GM: b'{ "Error": "AdmConProtoError: 10.100.12.0/24 does not match any network",\n "code": "Client.Ibap.Proto",\n "text": "10.100.12.0/24 does not match any network"\n}'

$ python client.py 

**2024-10-22 15:35:47,886 — infoblox_client.connector — WARNING — Failed on object search with url https://GRID-IP/wapi/v2.10/ipv4address?network=10.100.12.0%2F24: b'{ "Error": "AdmConProtoError: 10.100.12.0/24 does not match any network",\n  "code": "Client.Ibap.Proto",\n  "text": "10.100.12.0/24 does not match any network"\n}'
2024-10-22 15:35:47,909 — infoblox_client.connector — WARNING — Failed on object search with url https://GRID-IP/wapi/v2.10/ipv4address?network=10.100.12.0%2F24&_proxy_search=GM: b'{ "Error": "AdmConProtoError: 10.100.12.0/24 does not match any network",\n  "code": "Client.Ibap.Proto",\n  "text": "10.100.12.0/24 does not match any network"\n}'**

Traceback (most recent call last):
  File "/home/aws/.local/lib/python3.10/site-packages/infoblox_client/connector.py", line 317, in get_object
    return self._handle_get_object(obj_type, query_params, extattrs,
  File "/home/aws/.local/lib/python3.10/site-packages/infoblox_client/connector.py", line 354, in _handle_get_object
    return self._get_object(obj_type, url)
  File "/home/aws/.local/lib/python3.10/site-packages/infoblox_client/connector.py", line 370, in _get_object
    r.raise_for_status()
  File "/usr/lib/python3.10/site-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://GRID-IP/wapi/v2.10/ipv4address?network=10.100.12.0%2F24

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/aws/.local/lib/python3.10/site-packages/infoblox_client/connector.py", line 53, in callee
    return func(*args, **kwargs)
  File "/home/aws/.local/lib/python3.10/site-packages/infoblox_client/connector.py", line 321, in get_object
    return self._handle_get_object(obj_type, query_params,
  File "/home/aws/.local/lib/python3.10/site-packages/infoblox_client/connector.py", line 354, in _handle_get_object
    return self._get_object(obj_type, url)
  File "/home/aws/.local/lib/python3.10/site-packages/infoblox_client/connector.py", line 370, in _get_object
    r.raise_for_status()
  File "/usr/lib/python3.10/site-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://GRID-IPwapi/v2.10/ipv4address?network=10.100.12.0%2F24&_proxy_search=GM

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/aws/IBClient/client.py", line 12, in <module>
    ipv4address = conn.get_object('ipv4address', {'network': '10.100.12.0/24'})
  File "/home/aws/.local/lib/python3.10/site-packages/infoblox_client/connector.py", line 57, in callee
    raise ib_ex.InfobloxConnectionError(reason=e)
infoblox_client.exceptions.InfobloxConnectionError: Infoblox HTTP request failed with: 400 Client Error: Bad Request for url: https://GRID-IP/wapi/v2.10/ipv4address?network=10.100.12.0%2F24&_proxy_search=GM

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

3 participants