[Freeipa-devel] [freeipa PR#681][synchronized] Fix ipadiscovery

2017-04-04 Thread alex-zel
   URL: https://github.com/freeipa/freeipa/pull/681
Author: alex-zel
 Title: #681: Fix ipadiscovery
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/681/head:pr681
git checkout pr681
From 3ac30ca118685134dd38b07e4b55ecbb4c880a3a Mon Sep 17 00:00:00 2001
From: Alex Zeleznikov 
Date: Sun, 2 Apr 2017 11:53:11 +0300
Subject: [PATCH 1/3] ipadiscovery sort SRV record by priority

Sort SRV records for LDAP/KRB based on priority.
---
 ipaclient/install/ipadiscovery.py | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/ipaclient/install/ipadiscovery.py b/ipaclient/install/ipadiscovery.py
index 46e05c9..c6fc240 100644
--- a/ipaclient/install/ipadiscovery.py
+++ b/ipaclient/install/ipadiscovery.py
@@ -492,7 +492,16 @@ def ipadns_search_srv(self, domain, srv_record_name, default_port,
 root_logger.debug("Search DNS for SRV record of %s", qname)
 
 try:
-answers = resolver.query(qname, rdatatype.SRV)
+answers = []
+			dns_answers = resolver.query(qname, rdatatype.SRV)
+			for answer in dns_answers:
+if not len(answers):
+	answers.append(answer)
+else:
+	i = 0
+	while i < len(answers) and answer.priority > answers[i].priority:
+		i += 1
+	answers.insert(i, answer)
 except DNSException as e:
 root_logger.debug("DNS record not found: %s", e.__class__.__name__)
 answers = []
@@ -521,7 +530,16 @@ def ipadnssearchkrbrealm(self, domain=None):
 root_logger.debug("Search DNS for TXT record of %s", qname)
 
 try:
-answers = resolver.query(qname, rdatatype.TXT)
+answers = []
+			dns_answers = resolver.query(qname, rdatatype.SRV)
+			for answer in dns_answers:
+if not len(answers):
+	answers.append(answer)
+else:
+	i = 0
+	while i < len(answers) and answer.priority > answers[i].priority:
+		i += 1
+	answers.insert(i, answer)
 except DNSException as e:
 root_logger.debug("DNS record not found: %s", e.__class__.__name__)
 answers = []

From 993c99868f3e033122bfe6fc95f53c701243d3f0 Mon Sep 17 00:00:00 2001
From: Alex Zel 
Date: Sun, 2 Apr 2017 12:04:11 +0300
Subject: [PATCH 2/3] fix indentation

---
 ipaclient/install/ipadiscovery.py | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/ipaclient/install/ipadiscovery.py b/ipaclient/install/ipadiscovery.py
index c6fc240..4f18398 100644
--- a/ipaclient/install/ipadiscovery.py
+++ b/ipaclient/install/ipadiscovery.py
@@ -493,15 +493,15 @@ def ipadns_search_srv(self, domain, srv_record_name, default_port,
 
 try:
 answers = []
-			dns_answers = resolver.query(qname, rdatatype.SRV)
-			for answer in dns_answers:
-if not len(answers):
-	answers.append(answer)
-else:
-	i = 0
-	while i < len(answers) and answer.priority > answers[i].priority:
-		i += 1
-	answers.insert(i, answer)
+dns_answers = resolver.query(qname, rdatatype.SRV)
+for answer in dns_answers:
+if not len(answers):
+answers.append(answer)
+else:
+i = 0
+while i < len(answers) and answer.priority > answers[i].priority:
+i += 1
+answers.insert(i, answer)
 except DNSException as e:
 root_logger.debug("DNS record not found: %s", e.__class__.__name__)
 answers = []
@@ -531,15 +531,15 @@ def ipadnssearchkrbrealm(self, domain=None):
 
 try:
 answers = []
-			dns_answers = resolver.query(qname, rdatatype.SRV)
-			for answer in dns_answers:
-if not len(answers):
-	answers.append(answer)
-else:
-	i = 0
-	while i < len(answers) and answer.priority > answers[i].priority:
-		i += 1
-	answers.insert(i, answer)
+dns_answers = resolver.query(qname, rdatatype.SRV)
+for answer in dns_answers:
+if not len(answers):
+answers.append(answer)
+else:
+i = 0
+while i < len(answers) and answer.priority > answers[i].priority:
+i += 1
+answers.insert(i, answer)
 except DNSException as e:
 root_logger.debug("DNS record not found: %s", e.__class__.__name__)
 answers = []

From 73fc5dc8cf1b8c6f34ff767079aa2209b26c2aa1 Mon Sep 17 00:00:00 2001
From: Alex Zel 
Date: Tue, 4 Apr 2017 08:57:04 +0300
Subject: [PATCH 3/3] Update ipadiscovery.py

---
 ipaclient/install/ipadiscovery.py | 24 
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/ipaclient/install/ipadiscovery.py b/ipaclient/install/ipadiscovery.py
index 

[Freeipa-devel] [freeipa PR#681][synchronized] Fix ipadiscovery

2017-04-03 Thread alex-zel
   URL: https://github.com/freeipa/freeipa/pull/681
Author: alex-zel
 Title: #681: Fix ipadiscovery
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/681/head:pr681
git checkout pr681
From 3ac30ca118685134dd38b07e4b55ecbb4c880a3a Mon Sep 17 00:00:00 2001
From: Alex Zeleznikov 
Date: Sun, 2 Apr 2017 11:53:11 +0300
Subject: [PATCH 1/3] ipadiscovery sort SRV record by priority

Sort SRV records for LDAP/KRB based on priority.
---
 ipaclient/install/ipadiscovery.py | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/ipaclient/install/ipadiscovery.py b/ipaclient/install/ipadiscovery.py
index 46e05c9..c6fc240 100644
--- a/ipaclient/install/ipadiscovery.py
+++ b/ipaclient/install/ipadiscovery.py
@@ -492,7 +492,16 @@ def ipadns_search_srv(self, domain, srv_record_name, default_port,
 root_logger.debug("Search DNS for SRV record of %s", qname)
 
 try:
-answers = resolver.query(qname, rdatatype.SRV)
+answers = []
+			dns_answers = resolver.query(qname, rdatatype.SRV)
+			for answer in dns_answers:
+if not len(answers):
+	answers.append(answer)
+else:
+	i = 0
+	while i < len(answers) and answer.priority > answers[i].priority:
+		i += 1
+	answers.insert(i, answer)
 except DNSException as e:
 root_logger.debug("DNS record not found: %s", e.__class__.__name__)
 answers = []
@@ -521,7 +530,16 @@ def ipadnssearchkrbrealm(self, domain=None):
 root_logger.debug("Search DNS for TXT record of %s", qname)
 
 try:
-answers = resolver.query(qname, rdatatype.TXT)
+answers = []
+			dns_answers = resolver.query(qname, rdatatype.SRV)
+			for answer in dns_answers:
+if not len(answers):
+	answers.append(answer)
+else:
+	i = 0
+	while i < len(answers) and answer.priority > answers[i].priority:
+		i += 1
+	answers.insert(i, answer)
 except DNSException as e:
 root_logger.debug("DNS record not found: %s", e.__class__.__name__)
 answers = []

From 993c99868f3e033122bfe6fc95f53c701243d3f0 Mon Sep 17 00:00:00 2001
From: Alex Zel 
Date: Sun, 2 Apr 2017 12:04:11 +0300
Subject: [PATCH 2/3] fix indentation

---
 ipaclient/install/ipadiscovery.py | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/ipaclient/install/ipadiscovery.py b/ipaclient/install/ipadiscovery.py
index c6fc240..4f18398 100644
--- a/ipaclient/install/ipadiscovery.py
+++ b/ipaclient/install/ipadiscovery.py
@@ -493,15 +493,15 @@ def ipadns_search_srv(self, domain, srv_record_name, default_port,
 
 try:
 answers = []
-			dns_answers = resolver.query(qname, rdatatype.SRV)
-			for answer in dns_answers:
-if not len(answers):
-	answers.append(answer)
-else:
-	i = 0
-	while i < len(answers) and answer.priority > answers[i].priority:
-		i += 1
-	answers.insert(i, answer)
+dns_answers = resolver.query(qname, rdatatype.SRV)
+for answer in dns_answers:
+if not len(answers):
+answers.append(answer)
+else:
+i = 0
+while i < len(answers) and answer.priority > answers[i].priority:
+i += 1
+answers.insert(i, answer)
 except DNSException as e:
 root_logger.debug("DNS record not found: %s", e.__class__.__name__)
 answers = []
@@ -531,15 +531,15 @@ def ipadnssearchkrbrealm(self, domain=None):
 
 try:
 answers = []
-			dns_answers = resolver.query(qname, rdatatype.SRV)
-			for answer in dns_answers:
-if not len(answers):
-	answers.append(answer)
-else:
-	i = 0
-	while i < len(answers) and answer.priority > answers[i].priority:
-		i += 1
-	answers.insert(i, answer)
+dns_answers = resolver.query(qname, rdatatype.SRV)
+for answer in dns_answers:
+if not len(answers):
+answers.append(answer)
+else:
+i = 0
+while i < len(answers) and answer.priority > answers[i].priority:
+i += 1
+answers.insert(i, answer)
 except DNSException as e:
 root_logger.debug("DNS record not found: %s", e.__class__.__name__)
 answers = []

From 3c957c5b1407d89ddbd81eda99bdd4056d1ebc51 Mon Sep 17 00:00:00 2001
From: Alex Zel 
Date: Tue, 4 Apr 2017 08:57:04 +0300
Subject: [PATCH 3/3] Update ipadiscovery.py

---
 ipaclient/install/ipadiscovery.py | 24 
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/ipaclient/install/ipadiscovery.py b/ipaclient/install/ipadiscovery.py
index