- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Add a new fixed address - WAPI API Python requests
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2020 12:45 PM
Hello,
I am very new to infoblox and the WAPI API. I am trying to create a script that creates fixed addresses for a given network using Python, requests and the WAPI API. I have not been succesful at this and was wondering if anyone has done it or if I could get a clue on how to do it. Here's my code:
Re: Add a new fixed address - WAPI API Python requests
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2020 05:38 AM
You don't need to get the network first, the fixed address will be created in the correct network for the IP address.
This will work, given the IP address and the MAC address.
import requests
import urllib3
import json urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) session = requests.Session() session.auth = ('admin', 'infoblox') session.verify = False url = 'https://link.com/wapi/v2.7.3/' headers = {'Content-type': 'application/json'} data = {
'ipv4addr' : '192.168.123.123',
'mac':'00:12:51:12:34:56',
} r = session.post(url + 'fixedaddress', json=data, headers=headers, verify=False) response = r.json() print(response)
If you're not particular about the IP address, and you just want to assign it to the next available address in a specific network, you can do this:
import requests import urllib3 import json urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) session = requests.Session() session.auth = ('admin', 'infoblox') session.verify = False url = 'https://link.com/wapi/v2.7.3/' headers = {'Content-type': 'application/json'} data = { "ipv4addr": { "_object_function": "next_available_ip", "_object": "network", "_object_parameters": {"network": "192.168.123.0/24"}, "_result_field": "ips", }, 'mac':'00:12:52:12:34:56', } r = session.post(url + 'fixedaddress', json=data, headers=headers, verify=False) response = r.json() print(response)