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

API Search regex for integer extensible attribute

New Member
Posts: 1
906     0

Hi guys,

 

i am trying to get a list of all networks that have VLAN ID to determine which VLAN ID would be next. However I am not able to build a valid regex with an integer.

 

A normal query for a VLAN gives me this output, so you can see the structure:

/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID=1

 

<list>
  <value type="object">
    <comment>some network</comment>
    <network>X.X.X.X/24</network>
    <extattrs type="object">
       <tag0 name="VLAN ID" type="object">
         <value type="int">1</value>
       </tag0>
     </extattrs>
    <_ref>network/ZG5zLm5ldHdvcmskMTAuMjUwLjAuMC8yNC8w:X.X.X.X/24/default</_ref>
  </value>
</list>
 
There are many networks that doen have a VLAN ID. So I just want to query all networks which have one.
I tried:
/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID>0
/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID=.*
/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID=*
/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID~.*
/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID!=0
/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID=""
and some other things but nothing works.
 
Is there any regex to get the wanted result from the api?
 
Further note:
If I do not use a = symbol the api will interprete it as part of the name the ea has. 
I.e.:/wapi/v2.9.5/network?_return_fields=comment,network,extattrs&*VLAN%20ID>0
{ "Error": "AdmConProtoError: Unknown extensible attribute: VLAN ID>0", 
  "code": "Client.Ibap.Proto", 
  "text": "Unknown extensible attribute: VLAN ID>0"
}

Re: API Search regex for integer extensible attribute

New Member
Posts: 3
906     0

Hi,

2 years later i encountered the same issue. I could solve it via regex search, which is availble in API v2.12.1.

Using Ansible so the API Call is abstracted:

 

   - name: get all networks with ea vlan
     ansible.builtin.set_fact:
      ib_networks_with_vlan_ea: "{{ lookup('infoblox.nios_modules.nios_lookup', 'network', filter={'*VLAN~': '[0-9]+'}, return_fields=['comment', 'network', 'extattrs'], provider=nios_provider, wantlist=True) }}"
 
It should look like this (maybe needs to be urlencoded):

/wapi/v2.12.1/network?_return_fields=comment,network,extattrs&*VLAN~=[0-9]+

 

not using regex (\d+) since it is not supported:

https://docs.infoblox.com/space/nios86/35886899/Supported+Expressions+for+Search+Parameters 

Re: API Search regex for integer extensible attribute

New Member
Posts: 2
906     0

Just had an similar issue, but I got it to work by using the >= operator

curl -n 'https://<redacted>/wapi/v2.11.5/network?_return_fields%2B=network,extattrs&network_view=default&*VLAN_ID>=0'

Re: API Search regex for integer extensible attribute

New Member
Posts: 2
906     0

In terms of regex lookups with Ansible lookup plugin

add ~ suffix to the field while using filter: 

    - name: fetch networks by regex starting with 10.231
      set_fact:
        networks: "{{ lookup('nios', 'network', filter={'network~': '10.231'}, return_fields=['network','ipv4addr'], provider=nios_provider) }}"

    - name: print out the networks
      debug:
        var: networks

https://infoblox-client.readthedocs.io/en/stable/readme.html#search-by-regular-expression

Showing results for 
Search instead for 
Did you mean: 

Recommended for You