无法通过infoblox-client修改infoblox中的主机记录名称

时间:2018-05-10 08:58:09

标签: python nios

我正在尝试更新“主机记录名称”,为了达到同样的目的,我使用的是infoblox-client,但我遇到了一个路障,因为我无法修改/更新主机记录。我已经通过REST API尝试了同样的方法,并且能够根据需要修改名称,但是通过infoblox-client m卡住了。

以下是尝试更新记录的步骤:

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) 

1 个答案:

答案 0 :(得分:0)

我能够解决这个问题,混淆了创建和更新。

因此,对于任何遇到类似问题的人来说,这就是编码解决方案:

    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'})

简单..我早些时候在灌木丛中殴打..