Sort SRV records by priority

In some cases where multiple SRV records are present, LDAP and Kerberos records were returned in different order, causing replication issues in a multi master enviorment.

Update ipadiscovery.py

Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Alex Zeleznikov 2017-04-04 09:42:10 +03:00 committed by Martin Basti
parent b03ede8796
commit 8ec8e24015

View File

@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import operator
import socket
import six
@ -493,6 +494,7 @@ class IPADiscovery(object):
try:
answers = resolver.query(qname, rdatatype.SRV)
answers = sorted(answers, key=operator.attrgetter('priority'))
except DNSException as e:
root_logger.debug("DNS record not found: %s", e.__class__.__name__)
answers = []