mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-26 16:16:31 -06:00
dns: Fix support for dnspython 1.1x
`nameservers` was transformed into the property in dnspython 2:
bbf0cfd239
This causes
> AttributeError: type object 'Resolver' has no attribute 'nameservers'
on the previous dnspython 1.1x.
Fixes: https://pagure.io/freeipa/issue/9339
Signed-off-by: Stanislav Levin <slev@altlinux.org>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
parent
6a4d34fba9
commit
b152e8c3ae
@ -87,6 +87,7 @@ class DNSResolver(dns.resolver.Resolver):
|
||||
changes this to 5sec, while the previous one was 30sec.
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._nameservers = None
|
||||
super().__init__(*args, **kwargs)
|
||||
self.reset_ipa_defaults()
|
||||
self.resolve = getattr(super(), "resolve", self.query)
|
||||
@ -144,7 +145,11 @@ class DNSResolver(dns.resolver.Resolver):
|
||||
nameservers.remove(ipv4_loopback)
|
||||
self.nameservers = nameservers
|
||||
|
||||
@dns.resolver.Resolver.nameservers.setter
|
||||
@property
|
||||
def nameservers(self):
|
||||
return self._nameservers
|
||||
|
||||
@nameservers.setter
|
||||
def nameservers(self, nameservers):
|
||||
"""
|
||||
*nameservers*, a ``list`` of nameservers with optional ports:
|
||||
@ -181,7 +186,11 @@ class DNSResolver(dns.resolver.Resolver):
|
||||
nameservers = _nameservers
|
||||
|
||||
# Call dns.resolver.Resolver.nameservers setter
|
||||
dns.resolver.Resolver.nameservers.__set__(self, nameservers)
|
||||
if hasattr(dns.resolver.Resolver, "nameservers"):
|
||||
dns.resolver.Resolver.nameservers.__set__(self, nameservers)
|
||||
else:
|
||||
# old dnspython (<2) doesn't have 'nameservers' property
|
||||
self._nameservers = nameservers
|
||||
# Set nameserver_ports after successfull call to setter
|
||||
self.nameserver_ports = nameserver_ports
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user