Reply
Highlighted
Accepted Solution

Infoblox python API help

[ Edited ]
Authority
Posts: 18
8778     0
To  invoking the API call, i ran the following :
a=infoblox.Infoblox('infoblox_ipaddress', 'username', 'pasword', '2.3', 'default', 'default', False)
a.get_host_by_ip('ipaddress') gives :
 
[u'hostname.domain']
 
But , now if i try to add a host record :
 
a.create_host_record('ipadress', 'hostname.domain') gives :
 
infoblox.InfobloxGeneralException: Host records cannot be added to the zone domain while Microsoft servers are configured for the zone.
 
Any help would be appreaciated!!!

Re: Infoblox python API help

Adviser
Posts: 43
8779     0

Host records can't be created on Microsoft managed zones.  Try creating individual A/PTR records instead.

Re: Infoblox python API help

Authority
Posts: 18
8779     0

How do i create a A or a PTR record using this python API. Here are the list of methods it has  :

 

 

 

  • create_network
  • delete_network
  • create_networkcontainer
  • delete_networkcontainer
  • get_next_available_network
  • create_host_record
  • create_txt_record
  • delete_host_record
  • delete_txt_record
  • add_host_alias
  • delete_host_alias
  • create_cname_record
  • delete_cname_record
  • update_cname_record
  • create_dhcp_range
  • delete_dhcp_range
  • get_next_available_ip
  • get_host
  • get_host_by_ip
  • get_ip_by_host
  • get_host_by_extattrs
  • get_host_by_regexp
  • get_txt_by_regexp
  • get_host_extattrs
  • get_network
  • get_network_by_ip
  • get_network_by_extattrs
  • get_network_extattrs
  • update_network_extattrs
  • delete_network_extattrs

 

Re: Infoblox python API help

Adviser
Posts: 43
8779     0

Looks like this library does not support creating a/ptr records.  

 

You might want to use this library instead - https://github.com/infobloxopen/infoblox-client

 

Re: Infoblox python API help

Authority
Posts: 18
8779     0

Ok thanks, let me try this library.

Re: Infoblox python API help

Authority
Posts: 18
8779     0

Ok, So far here what i have figured :

 

opts = {'host': '192.168.1.1', 'username': 'admin', 'password'Smiley Tongueassword ''}

conn = connector.Connector(opts)

 

To Create a A and PTR record :

a_record = objects.ARecord.create(conn, name='test.domain.com', ip='10.0.0.1)

ptr_record = objects.PtrRecordV4.create(conn, ptrdname='test.domain.com', ip='10.0.0.1')

 

To delete a A and PTR record :

a_record.delete()

ptr_record.delete()

 

 

But if i want to delete an already existing A and PTR , then how would i go about doing so ??

 

Any help would be appreciated!!!

 

Thanks

Anirudh 

Re: Infoblox python API help

Authority
Posts: 18
8779     0

My guess is you need to perform a lookup for the record you want to delete and then use the object reference to delete.

Re: Infoblox python API help

Adviser
Posts: 43
8779     0

You need to find the record, then use the delete method.

 

E.g.

 

find_arecord=objects.ARecord.search(conn, ip='10.0.0.1')

delete_arecord=find_arecord.delete()

 

Note that a record and ptr record searches currently only support search by ip address.

 

There are a number of helper functions in https://github.com/infobloxopen/infoblox-client/blob/master/infoblox_client/object_manager.py 

 

You can use these as code examples to build your own helper functions such as searching a/ptr records by name instead of by ip address.

 

Re: Infoblox python API help

Authority
Posts: 18
8779     0

Thanks for the pointers guys, really helpfull!!!

 

 

Re: Infoblox python API help

[ Edited ]
Authority
Posts: 18
8779     0

Now with this API, i have the ability to bulk add the A and PTR records by putting them in a for loop.

 

But once in a while i still get NIOS timed out:

 

infoblox_client.exceptions.InfobloxTimeoutError: Connection to NIOS timed out

 

How can i get past this, Is there a way to increate the timeout ?

 

Any pointers would be appreciated.

 

Thanks

Anirudh

Re: Infoblox python API help

Adviser
Posts: 357
8779     0
Try setting the 'http_request_timeout' when you create the connection to something high - say 60 seconds. The underlying requests module has a retries option, but it looks like it's not exposed on the infoblox client connector - I will open a github issue on that.

John

Re: Infoblox python API help

Authority
Posts: 18
8779     0

Thanks for the suggetion. I will give that a try. 

Right now i am catching this error as exception and rerunning the script several times to make sure A and PTR records are made.

 

 

Another question is my wapi version is 2.3, should i bother changing that in the library becasue the default value is :

 

wapi_version': '1.4

 

Regardless it still work

 

Thanks

Anirudh

 

Re: Infoblox python API help

Adviser
Posts: 43
8779     0

WAPI versions maintain compatibility with newer NIOS releases.  So unless you need to use any of the new objects in WAPI 2.3, there's no need to upgrade the WAPI version in your Python code.

Showing results for 
Search instead for 
Do you mean 

Recommended for You