Learn How We Can Help You Keep Teleworkers Protected During the COVID-19 Crisis

API & Integration

Reply
Highlighted

Please help : Creating multiple IP records at one go

Authority
Posts: 32
1269     0

Hi everyone,

 

I have a question. Is there any way by which i can create multiple IP records in infoblox using a single API call.

 

For example 

 

IP Address          Device name

---------------       ----------------

142.182.50.11     DMOKOO

142.182.50.14     DMOKO1

     :

     :

     :

 

14.182.50.23      DMOC23

 

Can I send the IP address and hostname in one single API call to be saved in Infoblox as different IP records?

 

Please help

Highlighted

Re: Please help : Creating multiple IP records at one go

Community Manager
Community Manager
Posts: 184
1270     0

Yes you can do a "multiple body" request.  This example is for DHCP reservations:

 

curl -k1 -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.8/request' -H "Content-Type: application/json" -d \
'[{
    "method":"POST",
    "object":"fixedaddress",
    "data": {
      "name": "host001",
      "comment": "This is a comment for Host 001",
      "mac": "00:00:00:00:00:00",
      "ipv4addr": "10.102.109.1"
    }
  },
  {
    "method":"POST",
    "object":"fixedaddress",
    "data": {
      "name": "host002",
      "comment": "This is a comment for Host 002",
      "mac": "00:00:00:00:00:00",
      "ipv4addr": "10.102.109.2"
    }
  },
  {
    "method":"POST",
    "object":"fixedaddress",
    "data": {
      "name": "host003",
      "comment": "This is a comment for Host 003",
      "mac": "00:00:00:00:00:00",
      "ipv4addr": "10.102.109.3"
    }
  }
]'
Highlighted

Re: Please help : Creating multiple IP records at one go

Authority
Posts: 32
1270     0

Thanks Richard Smiley Happy

Highlighted

Re: Please help : Creating multiple IP records at one go

Techie
Posts: 4
1270     0

By any chance, could you provide an example of this using Python "requests" module?

 

Thanks.

 

Chris.

Highlighted

Re: Please help : Creating multiple IP records at one go

Community Manager
Community Manager
Posts: 184
1270     0

Try this example:

 

#!/usr/bin/env python3

import requests
import urllib3
import sys
import json

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


wapi_base = "https://192.168.1.2/wapi/v2.8/"
auth = ("admin", "infoblox")
HEADERS = {'Content-type': 'application/json'}

ses = requests.session()

payload = [
{
	"method":"POST",
	"object":"fixedaddress",
	"data": {
		"name": "host001",
		"comment": "This is a comment for Host 001",
		"mac": "00:00:00:00:00:00",
		"ipv4addr": "10.102.109.1"
	}
},
{
	"method":"POST",
	"object":"fixedaddress",
	"data": {
		"name": "host002",
		"comment": "This is a comment for Host 002",
		"mac": "00:00:00:00:00:00",
		"ipv4addr": "10.102.109.2"
	}
},
{
	"method":"POST",
	"object":"fixedaddress",
	"data": {
		"name": "host003",
		"comment": "This is a comment for Host 003",
		"mac": "00:00:00:00:00:00",
		"ipv4addr": "10.102.109.3"
	}
}]


r = ses.post(wapi_base + 'request', json=payload, auth=auth,
					headers=HEADERS, verify=False)	

response = r.json()
print (response)


Showing results for 
Search instead for 
Do you mean 

Recommended for You