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

How to specify two IPv4addr's in the dhcpmember JSON payload

New Member
Posts: 2
2901     1

Hi Infoblox community, 

 

I am looking to utilize an API call to PUT two members within the DHCP member assignment field. Here is my code in python:

 

import requests
import json
import sys
import getpass
import pprint

requests.packages.urllib3.disable_warnings()

infoblox = "https://X.X.X.X/wapi/v2.10.1/network/eF5zLm5ldHdvcmskMMAuMTM0LjE00C4wLbI0LzA:X.X.X.X/X/default"
payload = '{"network":"10.X.X.X/X","members":[{"_struct":"dhcpmember","ipv4addr":"1.1.1.1"}]}'
headers = {"Content-type": "application/json", "Accept": "application/json"}
id = 'username'
pw = 'password'
valid_cert = False

response = requests.request("PUT", infoblox, data=payload, headers=headers,
auth=(id, pw), verify=valid_cert)

if response.status_code != requests.codes.ok:
print(response.text)
exit_msg = 'Error {} OBJ REF OR PARAMS ARE WRONG: {}'
sys.exit(exit_msg.format(response.status_code, response.reason))

results = response.json()
pprint.pprint(results)

 My question is how do I specify another IPv4address (lets say 2.2.2.2) in the JSON payload field: [{"_struct":"dhcpmember","ipv4addr":"1.1.1.1"}]} so that I can have both 1.1.1.1 and 2.2.2.2 in the 10.X.X.X/X network's member assignment? 

Re: How to specify two IPv4addr's in the dhcpmember JSON payload

[ Edited ]
New Member
Posts: 2
2901     1

Hello again Infoblox community, 

 

I opened a support ticket with Infoblox and worked with an Engineer who was able to provide an answer to my question! Kudo's to that Engineer! 

 

Here is the syntax for specifying two IP's in the member assignment field using API (I wrote this in Python so if you're using cURL, it may be a bit different): 

 

'{"network": "10.X.X.X/X", "members":[{"_struct":"dhcpmember","ipv4addr":"1.1.1.1"},{"_struct":"dhcpmember","ipv4addr":"2.2.2.2"}]}'

 

so basically, it's just a matter of adding a comma and then another {"_struct"} statement. 

 

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You