Reply

Create host record with multiple IP addresses

New Member
Posts: 3
2458     0

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.

 

Best Regards,

Ioannis

 

Re: Create host record with multiple IP addresses

Moderator
Moderator
Posts: 315
2458     0

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)

Re: Create host record with multiple IP addresses

New Member
Posts: 3
2458     0

Thank you MRichard Smiley Happy

 

I was able to make use of what you suggested and now the code works as a charm Smiley Happy

 

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,

Ioannis

Re: Create host record with multiple IP addresses

Moderator
Moderator
Posts: 315
2459     0

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()

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You