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

WAPI: Add new IP for existing host

New Member
Posts: 2
2247     2

I've tried to add a new IP for an existing host via a python script and the WAPI.

 

To crate a new host is not a problem and this works fines.

url = f"https://{self.config['Infoblox']['host']}{self.config['Infoblox']['url']}record:host?_return_fields={return_fields}"
data = {
    "name": hostname,
    "configure_for_dns": False,
    "network_view": self.config['Infoblox']['network_view'],
    'ipv4addrs': [
        {
            'configure_for_dhcp': False,
            'ipv4addr': f"func:nextavailableip:{subnet},{self.config['Infoblox']['network_view']}"
        }
    ]
}

Then use requests and post the data to the infoblox server.

 

But when i try the same for an existing host i've always get the error 

{'Error': 'AdmConProtoError: IP address for the Host record is missing.', 'code': 'Client.Ibap.Proto', 'text': 'IP address for the Host record is missing.'}

 

The code looks bit different

url = f"https://{self.config['Infoblox']['host']}{self.config['Infoblox']['url']}{hostname_ref}{self.config['Infoblox']['network_view']}?_return_fields={return_fields}"
data = {
    "name": hostname_ref,
    "configure_for_dns": False,
    "network_view": self.config['Infoblox']['network_view'],
    'ipv4addrs+': [
        {
            'configure_for_dhcp': False,
            'ipv4addr': f"func:nextavailableip:{subnet},{self.config['Infoblox']['network_view']}"
        }
    ]
}

The URL called to add an IP address is
https://<srv>/wapi/v2.12/record:host/ZG5zLmhvc3QkLm5vbl9ETlNfaG9zdF9yb290My4wLjE2NTI3OTE1MTQzMzUudGVzdDI:test2/Testing?_return_fields=ipv4addrs

It doesn't work even if i try it with a fixed address.

 

I also tried to get all the existing IPs for an host and pass it so it should overwrite the existing IPs for that host. But the WAPI always created a new host object and doens't alter the existing one.

 

I don't see my error, has someone an idea what's the problem?

Re: WAPI: Add new IP for existing host

New Member
Posts: 2
2247     2

I've figured it out. Cost some time but the Problem was that both calls are transported as the HTML method "POST" but to alter a host record it has to be "PUT".

Showing results for 
Search instead for 
Did you mean: 

Recommended for You