Infoblox’s global team of threat hunters uncovers a DNS operation with the ability to bypass traditional security measures and control the Great Firewall of China. Read about “Muddling Meerkat” and the many other threat actors discovered by Infoblox Threat Intel here.

API Examples

Reply

infoblox_client.objects.... Create isn't throwing duplicate errors.. Why?

New Member
Posts: 5
580     0

I'm trying to create an options filter using infoblox_client.objects.Fitleroption.create().  Even with check_if_exists=True and update_if_exists=False, it returns the already existing _ref.  In fact, while production is not changed, the object it returns to me has my fields updated in it, even though the production _ref never updated.  I don't seem to have any way of finding out that it didn't update because create() does not return a tuple with status, nor does it return None because the create failed, nor does it throw an Exception.  That looks like a huge oversight.

 

The only way I can be sure I'm doing this correctly is if use infoblox_client.connection.create_object(). That will throw a duplicate error like this:

 

Error: Cannot create 'filteroption' object(s): b'{ "Error": "AdmConDataError: None (IBDataConflictError: IB.Data.ConflictSmiley Very Happyuplicate object \'willNotWork2\' of type \'dhcp_option_filter\' already exists in the database.)", \n "code": "Client.Ibap.Data.Conflict", \n "text": "Duplicate object \'willNotWork2\' of type \'dhcp_option_filter\' already exists in the database.", \n "trace": " File \\"ibapapachemod.py\\", line 477, in handlerequest\\n File \\"/infoblox/common/lib/python/infoblox/one/admin_conn/wapibase.py\\", line 1474, in execute\\n File \\"/infoblox/common/lib/python/infoblox/one/admin_conn/wapibase.py\\", line 1430, in _exec_handler\\n File \\"/infoblox/common/lib/python/infoblox/one/admin_conn/wapihandler.py\\", line 1324, in execute\\n"\n}' [code 400].

In fact, the only error it raises is if the API returns muliple objects, which makes no sense:

| Class methods inherited from InfobloxObject:
|
| _search(connector, return_fields=None, search_extattrs=None, force_proxy=False, max_results=None, paging=False, **kwargs) from builtins.type
|
| create(connector, check_if_exists=True, update_if_exists=False, **kwargs) from builtins.type
| Create the object in NIOS.
|
| Args:
| check_if_exists: If True, create method will attempt
| to fetch the object to check if it exists.
| update_if_exists: If True, create method will attempt
| to update the object if one exists.
|
| Raises:
| InfobloxFetchGotMultipleObjects: Raised only when check_if_exists
| is True. The fetch method can raise this error when API return
| multiple objects.
|
| Returns: Created Infoblox object.

 

I have also tried the create_check_exists, to see the existing object's ref and make sure I'm not crazy.  Here is the search first, to get the ref:

apply_as_class="False", bootfile="noboot.pxe", comment="A test fromDGF 23", expression="(substring(option vendor-class-identifier,0,20)="PXEClient:Arch:00000")", name="willNotWork2", option_space="DHCP", _ref="filteroption/ZG5zLmRoY3Bfb3B0aW9uX2ZpbHRlciR3aWxsTm90V29yazI:willNotWork2"

Here is the Fiteroption.create( check_if_exists=True, update_if_exists=false, **kwargs):

Filteroption: apply_as_class="False", bootfile="noboot.pxe", comment="A test fromDGF 34", expression="(substring(option vendor-class-identifier,0,20)="PXEClient:Arch:00000")", name="willNotWork2", _ref="filteroption/ZG5zLmRoY3Bfb3B0aW9uX2ZpbHRlciR3aWxsTm90V29yazI:willNotWork2"

Is the object.NAME.create() going to be a problem for everyone?  Why does it exist when we need to use connection.create_object() for proper error handling?

Thank you,

David

Showing results for 
Search instead for 
Did you mean: 

Recommended for You