10-24-2022 02:21 AM
We are trying to make use of Infoblox-client to create hosts that have mutiple IPv4 addresses, but it looks like we are having difficulties populating the list of of NIOS IP Objects.
The error message we get is: "Should be string or list of NIOS IP objects."
Is there an example of how the List of "NIOS IP Objects" should look like?
Many thanks in advance.
10-27-2022 05:27 AM
When creating the host records, you can send an individual ip address, or you can send an array of IP addresses like this:
ipaddr_101 = objects.IP.create(ip='192.168.1.101') ipaddr_102 = objects.IP.create(ip='192.168.1.102') addr_array = [ipaddr_101, ipaddr_102] myhost = objects.HostRecord.create(conn, name="newhost.examlpe.com", ip=addr_array)
10-31-2022 08:05 AM
Thank you MRichard
I was able to make use of what you suggested and now the code works as a charm
Now, I am having difficulties deleting specific IPv4 addresses that form a Host.
I have seen that "record:host_ipv4addr" does not support any delete functions.
From the GUI, you are able to delete only one specific IP if you like. Is that an option via the infoblox-client?
Many thanks in advance,
11-15-2022 05:05 AM
First, retrieve the host record, and then extract the list of IP addresses. Then remove the address from the list of addresses. In this example I'm just matching by IP address. And finally update the host record back to the grid again.
myhost2 = objects.HostRecord.search(conn, name="newhost.example.com", view="Internal DNS") ipaddrs = myhost2.ipv4addrs for i in range(len(ipaddrs)): if ipaddrs[i-1].ipv4addr == "192.168.1.102": del ipaddrs[i-1] myhost2.ipaddrs = ipaddrs myhost2.update()