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

Please help : Creating multiple IP records at one go

Authority
Posts: 29
6548     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

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

Moderator
Moderator
Posts: 321
6549     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"
    }
  }
]'

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

Authority
Posts: 29
6549     0

Thanks Richard Smiley Happy

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

New Member
Posts: 3
6549     0

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

 

Thanks.

 

Chris.

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

Moderator
Moderator
Posts: 321
6549     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 
Did you mean: 

Recommended for You