infoblox-client
infoblox-client copied to clipboard
create DNSZoneForward fails
wapi 2.10 infoblox_client version 0.6
Traceback (most recent call last):
File "/BLOX/create_forward_zones.py", line 66, in <module>
main()
File "/BLOX/create_forward_zones.py", line 63, in main
create_forward_zone(connection, domain="thisisatest.com", fwd_group="Forwarding DNS", ext_servers=my_dict)
File "/IBLOX/create_forward_zones.py", line 39, in create_forward_zone
fwd_zone = objects.DNSZoneForward.create(conn,fqdn=domain, forward_to=ext_server_list,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/IBLOX/venv/lib/python3.11/site-packages/infoblox_client/objects.py", line 370, in create
cls.create_check_exists(connector,
File "/IBLOX/venv/lib/python3.11/site-packages/infoblox_client/objects.py", line 326, in create_check_exists
reply = connector.create_object(local_obj.infoblox_type,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/IBLOX/venv/lib/python3.11/site-packages/infoblox_client/connector.py", line 53, in callee
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/IBLOX/venv/lib/python3.11/site-packages/infoblox_client/connector.py", line 450, in create_object
raise exception(
infoblox_client.exceptions.InfobloxCannotCreateObject: Cannot create 'zone_forward' object(s): b'{ "Error": "AdmConDataError: A domain label either starts or ends with an invalid character.", \n "code": "Client.Ibap.Data", \n "text": "A domain label either starts or ends with an invalid character."\n}' [code 400]
code block
def create_forward_zone(conn, domain: str, fwd_group: str, ext_servers: dict) -> None:
"""Create a forward zone using a domain string, forwarder group name, and
external server dictionary"""
ext_server_list = []
for name, ipv4addr in ext_servers.items():
ext_server = objects.Extserver(name=name,address=ipv4addr)
ext_server_list.append(ext_server)
try:
#create forward zone
fwd_zone = objects.DNSZoneForward.create(conn,fqdn=domain, forward_to=ext_server_list,
ns_group=fwd_group,
fowarders_only = True,)
print(f"{domain} created")
except exceptions.InfobloxFetchGotMultipleObjects:
print("Already exists")
return
One of the name servers in the external server list had a trailing period. Removing this fixed it. If it is in scope, can a check be created on the ExtServer structure to see if a valid string is being passed?