dnspython: Add compatibility shim

`dnspython` 2.0.0 has many changes and several deprecations like:

```
> dns.resolver.resolve() has been added, allowing control of whether
search lists are used. dns.resolver.query() is retained for backwards
compatibility, but deprecated. The default for search list behavior can
be set at in the resolver object with the use_search_by_default
parameter. The default is False.

> dns.resolver.resolve_address() has been added, allowing easy
address-to-name lookups.
```

The new class `DNSResolver`:
- provides the compatibility layer
- defaults the previous behavior (the search list configured in the
  system's resolver configuration is used for relative names)
- defaults lifetime to 15sec (determines the number of seconds
  to spend trying to get an answer to the question)

Fixes: https://pagure.io/freeipa/issue/8383
Signed-off-by: Stanislav Levin <slev@altlinux.org>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Stanislav Levin
2020-08-28 16:31:10 +03:00
committed by Alexander Bokovoy
parent fdb227e55a
commit 49e643783d
16 changed files with 158 additions and 86 deletions

View File

@@ -22,8 +22,6 @@ from __future__ import absolute_import
import logging
import dns.resolver
import six
from ipalib import api, errors, util
@@ -64,7 +62,7 @@ from ipapython.ipautil import (
CheckedIPAddress,
TMP_PWD_ENTROPY_BITS
)
from ipapython.dnsutil import DNSName
from ipapython.dnsutil import DNSName, zone_for_name
from ipapython.ssh import SSHPublicKey
from ipapython.dn import DN
from ipapython import kerberos
@@ -826,7 +824,7 @@ class host_del(LDAPDelete):
if updatedns:
# Remove A, AAAA, SSHFP and PTR records of the host
fqdn_dnsname = DNSName(fqdn).make_absolute()
zone = DNSName(dns.resolver.zone_for_name(fqdn_dnsname))
zone = DNSName(zone_for_name(fqdn_dnsname))
relative_hostname = fqdn_dnsname.relativize(zone)
# Get all resources for this host