Skip to content
Snippets Groups Projects
Commit 92972fd1 authored by Rafael Guterres Jeffman's avatar Rafael Guterres Jeffman
Browse files

ipahost: fix adding host for servers without DNS configuration.

When using ipahost module with servers where DNS was not configured
it failed to add hosts due to an exception raised on `dnsrecord_show`
that was not being correctly handled.

As the exception was being handled twice, the This patch simply removes
one of the handlers, allowing the exception to propagate to the caller,
where it is handled.

Fixes issue #434.
parent 8c17d762
No related branches found
No related tags found
No related merge requests found
......@@ -439,6 +439,12 @@ def find_host(module, name):
def find_dnsrecord(module, name):
"""
Search for a DNS record.
This function may raise ipalib_errors.NotFound in some cases,
and it should be handled by the caller.
"""
domain_name = name[name.find(".")+1:]
host_name = name[:name.find(".")]
......@@ -447,14 +453,8 @@ def find_dnsrecord(module, name):
"idnsname": to_text(host_name)
}
try:
_result = api_command(module, "dnsrecord_show", to_text(domain_name),
_args)
except ipalib_errors.NotFound as e:
msg = str(e)
if "record not found" in msg or "zone not found" in msg:
return None
module.fail_json(msg="dnsrecord_show failed: %s" % msg)
return _result["result"]
......@@ -876,8 +876,11 @@ def main():
msg = str(e)
dns_not_configured = "DNS is not configured" in msg
dns_zone_not_found = "DNS zone not found" in msg
if ip_address is None and (
dns_not_configured or dns_zone_not_found
dns_res_not_found = "DNS resource record not found" in msg
if (
dns_res_not_found
or ip_address is None
and (dns_not_configured or dns_zone_not_found)
):
# IP address(es) not given and no DNS support in IPA
# -> Ignore failure
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment