I have been successfully using the API to add and remove hosts but now I want to do a check before adding to make sure there isn't a host associated with a specific IP and if there is to delete it, then add the new host. I am doing this in a python webhooks app that is used by Scalr with Openstack. Given it is python I have looked to this page(https://github.com/Infoblox-Development/Infoblox-A
02-01-2017 01:54 PM
Thanks for the response. I have tried "default" previously but unfortunately it didn't work and I don't see a drop down in the UI. Thanks for the new code reference. I'll see what I can find there.
02-02-2017 06:43 AM - edited 02-02-2017 06:51 AM
I tried network_view as default again and got this error: "Network View 'default' not found". I found this in the IPAM tab (image below) and was able to drill down from the network listed to the IP address I was trying to get. It seems like the Network View is "default" so I don't know why that error is being thrown. Any suggestions? Thanks.
02-02-2017 09:28 AM
02-02-2017 11:43 AM
network_view is an option field. You can usually leave it out unless you have more than one net view.
if it is missing, the API will just use the 'default' view and modify the records in there.
a code snippet would help to diagnose any further issues.
Sorry for the long delay in reply. I had other tasks take priority.
This is part of a webhooks app used with Scalr, so the code is getting the IP from an input payload provided by Scalr in the first line.
external_ip = self.payload["data"]["SCALR_EXTERNAL_IP"] response = self.__get_host_for_ip(self.url + "ipv4address?ip_address='" + external_ip + "'") if (response is None): log_message("Nothing was returned.") else: log_message("Response: " + response) def __get_host_for_ip(self, get_url): r = requests.get(url=get_url, auth=(self.username, self.password), verify=False) r_json = r.json() if r.status_code == 200 or r.status_code == 201: #Verify that there is an r_json object if r_json: log_message("Got a response") host_ref = r_json['_ref'] log_message("host_ref: " + host_ref) return host_ref else: return None else: if 'text' in r_json: log_message("!!!!! EXCEPTION in Infoblox Get Host for IP (1): " + r_json['text']) else: log_message("!!!!! EXCEPTION in Infoblox Get Host for IP (2): %s" % e)
I get the following output from this code:
URL parameter: https://10.9.0.224/wapi/v1.2.1/ipv4address?ip_addr
ess='10.48.87.95' !!!!! EXCEPTION in Infoblox Get Host for IP (1): A network was not found for this address.
Is there anything else I need to add to the url sent via requests? Thanks.
Thanks for the previous help but I guess no one has any idea about my last post 2 weeks ago?