Reputation: 344
I am trying to update 'host record name', and for achieving the same I am using infoblox-client but I am hitting a roadblock coz of which m not able to modify/update the host record. I have tried the same via REST API and m able to modify the name as required but via infoblox-client m kind of stuck.
Following are the steps that m trying to update the record:
opts = {'host': '192.168.1.10', 'username': 'admin', 'password': 'admin'}
conn = connector.Connector(opts)
my_ip = objects.IP.create(ip='192.168.1.25')
#to create new host record with parameters
record = objects.HostRecord.create(conn, view='my_dns_view', name='my_host_record.my_zone.com', ip=my_ip)
#to modify m trying following but no luck:
#1_both of below snippet adds a new name to record instead of upodating the same
-> result = objects.HostRecord.create(conn, view='my_dns_view', name='new_name.my_zone.com', ip=my_ip, check_if_exists=True, update_if_exists=True)
-> result = objects.ARecordBase.create(conn, ip='192.168.102.14', name='some-new_name.ansible.com', view='default', update_if_exists=True)
#2_I have gone through infoblox-client test case(test_update_fields_on_create) which I have following steps to modify record:
a_record = [{'_ref': 'record:previously_created_record', 'ip': '192.168.1.52', 'name': 'other_name'}]
#this gives me error for host,username missing.
conn = connector.Connector(a_record)
#this results to None which ultimately blocks me
res = conn.get_object('record:host',a_record)
Upvotes: 0
Views: 740
Reputation: 344
I was able to resolve the issue, got mixed up with creating and updating.
So, for any one who face similar kind of issue here is the coded solution:
opts = {'host': '192.168.1.10', 'username': 'admin', 'password': 'admin'}
conn = connector.Connector(opts)
my_ip = objects.IP.create(ip='192.168.1.25')
#to create new host record with parameters
record = objects.HostRecord.create(conn, view='my_dns_view', name='host_record.my_zone.com', ip=my_ip)
#to update the name, directly use update_object:
testConn = conn.update_object(record._ref, {'name': 'new_name_host_record.my_zone.com'})
Simple.. I was beating around the bush earlier..
Upvotes: 0