Skip to content
View in the app

A better way to browse. Learn more.

Gear Crushers

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Infoblox API Dummys Guide

Featured Replies

I thought it would also be good to include a (relatively) brief introduction for people who are new to both scripting and to the Infoblox APIs. This is oriented to the newer Web API (WAPI), also known as the RESTful API. There is another API, the Perl API or PAPI. I don't use that so I'm not that familar with it; I'll leave it to somone else to give an example Perl/PAPI script for this problem. Also, I use Python to do WAPI scripting, because Python is both powerful and relatively easy to learn; again, if you want to do WAPI scripting in PowerShell, Perl, etc., other people can address that.

First you need to install Python; I'll presume you're using Microsoft Windows. (Python comes pre-installed on Mac and Linux systems.) Windows installers for Python 2 and Python 3 are available from the Python Software Foundation at https://www.python.org/downloads/windows. I recommend using the latest Python 2.7 release (2.7.10 at the time of writing). You can install Python for all users on the system (default) or just for yourself. By default Python is installed into the directory C:\Python27, and I recommend you leave it there. Finally, you should add C:\Python27 and C:\Python27\Scripts to the system PATH variable. (This is not done by default.)

Python scripts are run from the Windows command prompt; once Python is installed and your PATH variable is set correctly you should be able to enter the following commands to verify that both Python itself and the pip utility are installed:

python --version
pip --version

You should then install the Python requests module:

pip install requests

Finally, you can test whether you can do WAPI calls as follows: First, create a file called wapitest.py with the following contents, replacing 'gm.example.com' with the name or IP address of your grid master, 'admin' with a suitable Infoblox userid, and 'infoblox' by the corresponding password:

import requests

url = 'https://gm.example.com/wapi/v1.0/'
id = 'admin'
pw = 'infoblox'

# The following line is needed only for Windows; omit it otherwise.
requests.packages.urllib3.disable_warnings()

r = requests.get(url + 'network', auth=(id, pw), verify=False)

print r.text

Then run the following command from the Windows command prompt:

python wapitest.py

The script should print out a list that looks something like the following, where each set of curly braces { and } enclose a WAPI object for a particular network:

[
    {
        "_ref": "network/ZG5zLm5ldHdvcmskMTkyLjE2OC4wLjAvMjMvMA:192.168.0.0/23/default", 
        "comment": "Main home network", 
        "network": "192.168.0.0/23", 
        "network_view": "default"
    }
 ...
]

If the above program works then you are ready to create more complicated scripts, and to run the script I attached earlier. (You just need to include the code line above that disables warning; I forgot about that because I write my scripts on a Mac.) If you're interested in learning more about how to code in Python there are lots of free resources on the Internet, including the Python tutorial (https://docs.python.org/2/tutorial/) and the Hitchhiker's Guide to Python (http://docs.python-guide.org/en/latest/).

Another way to test to see if you can access the Web API: If you're using Windows, bring up Internet Explorer and enter the following URL (again replacing 'gm.example.com' with the name or IP address of your grid master):

This should first give you a certificate error page you'll have to click through, and then it should display a page of XML output listing the network objects.

If the above test fails, and if you can access your normal grid master interface via the same browser and site, post a reply and we can try further debugging.

The basic idea is that every WAPI object has a set of fields associated with it. So, for example, in NIOS 6.12 (WAPI 1.7) the range object has 78 different possible fields (if I've counted correctly), including start_addr, end_addr, network (the subnet containing the range), and so on. The fields for each object are documented in the WAPI reference manual; for the range object see Section 3.32, Table 3.13, on pages 395-396 in the WAPI 1.7 manual.

When the WAPI results are returned in JSON format (the normal case) the fields of an object are represented as key/value pairs, where the key is the field name and the value is the field value, for example:

{'field_1': 'value_1', 'field_2': 'value_2', ..., 'field_n': 'value_n'}

Note that field names are always character strings, but (unlike the example above) in general field values may be strings, numbers, or more complex objects (e.g., lists of strings).

In Python a WAPI object and its fields are represented using the Python dictionary type, with syntax like that shown above. If range1 is a range object then the start_addr field of that object would be retrieved as either range1['start_addr'] or range1.get('start_addr'). The difference between these is relevant when a particular field does not have a value for a particular object. For example, some range objects may have an associated comment and some may not. If the range object range1 does not have an associated comment then referencing range1['comment'] will cause a fatal error, but using range1.get('comment') will just return an empty string.

This is relevant when retrieving the names and values of extensible attributes for an object. In WAPI 1.2 and later an object's extensible attributes are returned in a special field extattrs; for example, if range1 is a range object then its associated collection of extensible attributes would be accessible as range1['extattrs']. The value of the extattrs field is a set of key/value pairs representing the various extensible attributes; in other words, in Python the value of the extattrs field is itself a dictionary. For example, if the range object range1 has two extensible attributes Country and State, then range1['extattrs'] would have a value like the following:

{'Country': {'value': 'US'}, 'State': {'value': 'Maryland'}}

Note that the values of each of the extensible attributes Country and State are not simple strings, but are sets of key/value pairs, one of which (with the key 'value') stores the actual extensible attribute value.

Retrieving extensible attribute values is therefore a bit tricky: First you have to check if the extensible attribute is actually present in the extattrs field, and then (and only then) you can retrieve its values. If range1 is a range object then you can do this using Python code as follows:

country = ''
if 'Country' in range1['extattrs']:
    country = range1['extattrs']['Country']['value']

or as follows:

if 'Country' not in range1['extattrs']:
    country = ''
else:
    country = range1['extattrs']['Country']['value']

(There are likely more terse ways to do this in Python, but these is the most understandable ways I think.)

The way to interpret the code above is as follows:

1. range1 is a Python dictionary, we index into it using the field name 'extattrs' to retrieve the extattrs field.

2. range1['extattrs'] is also a Python dictionary, we index into it using the extensible attribute name 'Country' to retrieve the Country extensible attribute.

3. range1['extattrs']['Country'] is also a Python dictionary, we index into it using the string 'value' to retrieve the actual value of the Country extensible attribute.

In this example the value of the Country extensible attribute was a text string ('US'), but in general extensible attributes can also be lists, numbers, etc. But that's enough complications for one post!

Pretty good tutorial. Here is a little something extra to help you get setup with the Infoblox API's on your linux server.

Requirements for Unix Management Systems

For IPv4 connections the following are required - Perl 5.8.8 or later

[*]Crypt::SSLeay version 0.51 or later

[*]LWP::UserAgent version 5.813 or later

[*]XML::Parser

For IPv6 connections the following are required

[*]Perl 5.14.2 or later

[*]LWP::UserAgent version 6.02 or later and relevant dependencies, including LWP::Protocol::https - Net::INET6Glue

[*]XML::Parser

to easily install the required libraries it is recommented to use CPAN, after installing perl run

perl - e shell - MCPAN

and once configured simply run

 install LWP::UserAgent

 install XML::Parser

and the other packages you need depending on IPv4 or IPv6 accessibility.

DIRECT INSTALLATION which is what I use

To install the Infoblox DMAPI packages on a UNIX management system, first download and install the API package from:

https:///api/dist/CPAN/authors/id/INFOBLOX/

where ip_addr is the IP address of the appliance. Then locate and download the file Infoblox-xxxxxxx.tar.gz where xxxxxxx is an integer depending on your API package version.

After you download the package, extract it to a temporary directory with:

tar xvfz Infoblox-xxxxxxx.tar.gz

Then execute the following commands:

cd Infoblox-xxxxxxx/

NIOS 7.0 Infoblox API Documentation (Rev. A) ||| 10

perl Makefile.PL

make

make install

Optionally, before you install, test the package by running:

make test

The installation is complete.

Infoblox API Usage Guidelines

The usage instructions are provided to assist you in using the Infoblox API.

Library options

The Infoblox library can optionally be invoked by supplying the following options

:ipv6connection - This will allow the API to connect to IPv6 members.

:hostaddress - if this is specified the new L and L types will be supported, see L for more information

for example, to enable :ipv6connection the use line would be

use Infoblox qw ( :ipv6connection ) ;

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.