Calling Functions
Numerous WAPI objects support the ability to call functions on objects. Functions are generally called by issuing a POST request, along with a set of attributes and associated values in a Python Dictionary. The dictionary of properties are sent as a JSON body in the request. Object function calls to WAPI object generally take the form:
Tip
The Infoblox NIOS WAPI API is fully documented and available online. You can access the API guide by using the following url path on your Infoblox Grid Manager:
https://<grid_mgr>/wapidoc
See the WAPI Guide for details on all objects, properties, functions, and parameters.
Next Available Network
- Retrieve the object reference from the network container
- Fetch 2 available networks from the network container
- Create the 2 networks received
Tip
The wapi.getone('<wapi_object>', params, **kwargs) method does not return a response object.
It will return an object reference of type string.
To fetch the reference for network container 192.168.0.0/16 from the Grid, we start to create our script with the following:
To fetch the next available 2 networks within the network container 192.168.0.0/16 we add the following to our script:
Our response above is an httpx Response object, and it will contain a number of properties
and methods.
The ones used most often in working with WAPI data are:
| property/method | Description |
|---|---|
json() |
A method returns JSON-encoded object of the result (if the result was JSON encoded) |
status_code |
A property representing the HTTP Status Code (200 is OK, 404 is Not Found and so on) |
text |
A property which returns the content of the response in unicode |
We can test the success or failure of the above request by checking for an OK status on the response object this
is done like adding the following to our script:
To build/create the two next available networks by the function we called, we add the following to our script:
Next Available IP
- Retrieve the object reference from the network
- Fetch 10 available networks from the network
- Create the 10 IP Reservations from the ips received
To fetch the reference for network container 192.168.2.0/24 from the Grid, we start to create our script with the following:
To fetch the next 10 available ips within the network 192.168.2.0/24 we add the following to our script:
To build/create the 10 fixed addresses received by the function we called, we add the following to our script:
Expand Network
- Retrieve the object reference from the network
- Expand Network to a /23
To fetch the reference for network container 192.168.2.0/24 from the Grid, we start to create our script with the following:
Expand network to 192.168.2.0/23 we add the following to our script:
Danger
This function reduces the subnet masks of a network by joining all networks that fall under it. All the ranges and fixed addresses of the original networks are reparented to the new joined network. Any network containers that fall inside the bounds of the joined network are removed. The member assignments for all the encompassed networks are joined together. The default router, broadcast address, and subnet mask overrided from the joined network, including the ranges and fixed addresses, are all cleaned up.