- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
WAPI: Add new IP for existing host
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2022 06:00 AM
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?
Solved! Go to Solution.
Re: WAPI: Add new IP for existing host
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 05:04 AM
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".