[Freeipa-devel] [freeipa PR#276][synchronized] replica-conncheck: improve error msg + logging

2016-12-02 Thread tomaskrizek
   URL: https://github.com/freeipa/freeipa/pull/276
Author: tomaskrizek
 Title: #276: replica-conncheck: improve error msg + logging
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/276/head:pr276
git checkout pr276
From cf708bce7c4cff3539f4cb1a05e6e917039db45b Mon Sep 17 00:00:00 2001
From: Tomas Krizek 
Date: Fri, 25 Nov 2016 17:23:29 +0100
Subject: [PATCH 1/2] replica-conncheck: improve error message during
 replicainstall

Replica conncheck may fail for other reasons then network
misconfiguration. For example, an incorrect admin password might be
provided. Since conncheck is ran as a separate script in quiet mode,
no insightful error message can be displayed.

https://fedorahosted.org/freeipa/ticket/6497
---
 ipaserver/install/replication.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index 3f909bb..ddae08e 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -104,7 +104,7 @@ def replica_conn_check(master_host, host_name, realm, check_ca,
 if result.returncode != 0:
 raise ScriptError(
 "Connection check failed!"
-"\nPlease fix your network settings according to error messages above."
+"\nSee /var/log/ipareplica-conncheck.log for more information."
 "\nIf the check results are not valid it can be skipped with --skip-conncheck parameter.")
 else:
 print("Connection check OK")

From ba2701ee2d8435946190e6305465107633673844 Mon Sep 17 00:00:00 2001
From: Tomas Krizek 
Date: Fri, 25 Nov 2016 17:27:16 +0100
Subject: [PATCH 2/2] replica-conncheck: improve message logging

Make sure all messages displayed on screen to the user can be found
in the log as well. The messages are also logged if the script is ran
in quiet mode.

https://fedorahosted.org/freeipa/ticket/6497
---
 install/tools/ipa-replica-conncheck | 98 +++--
 1 file changed, 51 insertions(+), 47 deletions(-)

diff --git a/install/tools/ipa-replica-conncheck b/install/tools/ipa-replica-conncheck
index 121f068..e917d56 100755
--- a/install/tools/ipa-replica-conncheck
+++ b/install/tools/ipa-replica-conncheck
@@ -63,7 +63,7 @@ class SshExec(object):
 def __call__(self, command, verbose=False):
 # Bail if ssh is not installed
 if self.cmd is None:
-print("WARNING: ssh not installed, skipping ssh test")
+root_logger.warning("WARNING: ssh not installed, skipping ssh test")
 return ('', '', 0)
 
 tmpf = tempfile.NamedTemporaryFile()
@@ -112,11 +112,6 @@ BASE_PORTS = [
  ]
 
 
-def print_info(msg):
-if not QUIET:
-print(msg)
-
-
 def parse_options():
 def ca_cert_file_callback(option, opt, value, parser):
 if not os.path.exists(value):
@@ -210,10 +205,6 @@ def parse_options():
 if not options.hostname:
 options.hostname = socket.getfqdn()
 
-if options.quiet:
-global QUIET
-QUIET = True
-
 return safe_options, options
 
 
@@ -223,7 +214,8 @@ def logging_setup(options):
 if os.getegid() == 0 and options.log_to_file:
 log_file = paths.IPAREPLICA_CONNCHECK_LOG
 
-standard_logging_setup(log_file, debug=options.debug)
+standard_logging_setup(log_file, verbose=(not options.quiet),
+   debug=options.debug, console_format='%(message)s')
 
 
 def sigterm_handler(signum, frame):
@@ -400,13 +392,14 @@ def port_check(host, port_list):
 else:
 ports_failed.append(port)
 result = "FAILED"
-print_info("   %s (%d): %s" % (port.description, port.port, result))
+root_logger.info("   %s (%d): %s" % (port.description, port.port, result))
 
 if ports_udp_warning:
-print("The following UDP ports could not be verified as open: %s" \
-% ", ".join(str(port.port) for port in ports_udp_warning))
-print("This can happen if they are already bound to an application")
-print("and ipa-replica-conncheck cannot attach own UDP responder.")
+root_logger.warning(
+("The following UDP ports could not be verified as open: %s\n"
+ "This can happen if they are already bound to an application\n"
+ "and ipa-replica-conncheck cannot attach own UDP responder.")
+% ", ".join(str(port.port) for port in ports_udp_warning))
 
 if ports_failed:
 msg_ports = []
@@ -436,29 +429,34 @@ def main():
   "PKI-CA: Directory Service port"))
 
 if options.replica:
-print_info("Check connection from master to remote replica '%s':" % options.replica)
+root_logger.info("Check connection from master to remote replica '%s':"
+ % 

[Freeipa-devel] [freeipa PR#276][synchronized] replica-conncheck: improve error msg + logging

2016-11-30 Thread tomaskrizek
   URL: https://github.com/freeipa/freeipa/pull/276
Author: tomaskrizek
 Title: #276: replica-conncheck: improve error msg + logging
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/276/head:pr276
git checkout pr276
From d46e1a38bb65e20439a6772fbba08df7c4fcef11 Mon Sep 17 00:00:00 2001
From: Tomas Krizek 
Date: Fri, 25 Nov 2016 17:23:29 +0100
Subject: [PATCH 1/2] replica-conncheck: improve error message during
 replicainstall

Replica conncheck may fail for other reasons then network
misconfiguration. For example, an incorrect admin password might be
provided. Since conncheck is ran as a separate script in quiet mode,
no insightful error message can be displayed.

https://fedorahosted.org/freeipa/ticket/6497
---
 ipaserver/install/replication.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index ba35c49..35066c2 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -105,7 +105,7 @@ def replica_conn_check(master_host, host_name, realm, check_ca,
 if result.returncode != 0:
 raise ScriptError(
 "Connection check failed!"
-"\nPlease fix your network settings according to error messages above."
+"\nSee /var/log/ipareplica-conncheck.log for more information."
 "\nIf the check results are not valid it can be skipped with --skip-conncheck parameter.")
 else:
 print("Connection check OK")

From 91b20a812cf699f9fedb1be63006369f58e4e0e6 Mon Sep 17 00:00:00 2001
From: Tomas Krizek 
Date: Fri, 25 Nov 2016 17:27:16 +0100
Subject: [PATCH 2/2] replica-conncheck: improve message logging

Make sure all messages displayed on screen to the user can be found
in the log as well. The messages are also logged if the script is ran
in quiet mode.

https://fedorahosted.org/freeipa/ticket/6497
---
 install/tools/ipa-replica-conncheck | 98 +++--
 1 file changed, 51 insertions(+), 47 deletions(-)

diff --git a/install/tools/ipa-replica-conncheck b/install/tools/ipa-replica-conncheck
index 7ec1ef8..083aa07 100755
--- a/install/tools/ipa-replica-conncheck
+++ b/install/tools/ipa-replica-conncheck
@@ -47,7 +47,6 @@ from cryptography.hazmat.primitives import serialization
 
 CONNECT_TIMEOUT = 5
 RESPONDERS = [ ]
-QUIET = False
 CCACHE_FILE = None
 KRB5_CONFIG = None
 
@@ -60,7 +59,7 @@ class SshExec(object):
 def __call__(self, command, verbose=False):
 # Bail if ssh is not installed
 if self.cmd is None:
-print("WARNING: ssh not installed, skipping ssh test")
+root_logger.warning("WARNING: ssh not installed, skipping ssh test")
 return ('', '', 0)
 
 tmpf = tempfile.NamedTemporaryFile()
@@ -108,10 +107,6 @@ BASE_PORTS = [
  ]
 
 
-def print_info(msg):
-if not QUIET:
-print(msg)
-
 def parse_options():
 def ca_cert_file_callback(option, opt, value, parser):
 if not os.path.exists(value):
@@ -205,10 +200,6 @@ def parse_options():
 if not options.hostname:
 options.hostname = socket.getfqdn()
 
-if options.quiet:
-global QUIET
-QUIET = True
-
 return safe_options, options
 
 def logging_setup(options):
@@ -217,7 +208,8 @@ def logging_setup(options):
 if os.getegid() == 0 and options.log_to_file:
 log_file = paths.IPAREPLICA_CONNCHECK_LOG
 
-standard_logging_setup(log_file, debug=options.debug)
+standard_logging_setup(log_file, verbose=(not options.quiet),
+   debug=options.debug, console_format='%(message)s')
 
 def clean_responders(responders):
 if not responders:
@@ -328,13 +320,14 @@ def port_check(host, port_list):
 else:
 ports_failed.append(port)
 result = "FAILED"
-print_info("   %s (%d): %s" % (port.description, port.port, result))
+root_logger.info("   %s (%d): %s" % (port.description, port.port, result))
 
 if ports_udp_warning:
-print("The following UDP ports could not be verified as open: %s" \
-% ", ".join(str(port.port) for port in ports_udp_warning))
-print("This can happen if they are already bound to an application")
-print("and ipa-replica-conncheck cannot attach own UDP responder.")
+root_logger.warning(
+("The following UDP ports could not be verified as open: %s\n"
+ "This can happen if they are already bound to an application\n"
+ "and ipa-replica-conncheck cannot attach own UDP responder.")
+% ", ".join(str(port.port) for port in ports_udp_warning))
 
 if ports_failed:
 msg_ports = []
@@ -362,29 +355,34 @@ def main():
   "PKI-CA: Directory Service port"))
 
 if 

[Freeipa-devel] [freeipa PR#276][synchronized] replica-conncheck: improve error msg + logging

2016-11-29 Thread tomaskrizek
   URL: https://github.com/freeipa/freeipa/pull/276
Author: tomaskrizek
 Title: #276: replica-conncheck: improve error msg + logging
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/276/head:pr276
git checkout pr276
From d46e1a38bb65e20439a6772fbba08df7c4fcef11 Mon Sep 17 00:00:00 2001
From: Tomas Krizek 
Date: Fri, 25 Nov 2016 17:23:29 +0100
Subject: [PATCH 1/2] replica-conncheck: improve error message during
 replicainstall

Replica conncheck may fail for other reasons then network
misconfiguration. For example, an incorrect admin password might be
provided. Since conncheck is ran as a separate script in quiet mode,
no insightful error message can be displayed.

https://fedorahosted.org/freeipa/ticket/6497
---
 ipaserver/install/replication.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index ba35c49..35066c2 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -105,7 +105,7 @@ def replica_conn_check(master_host, host_name, realm, check_ca,
 if result.returncode != 0:
 raise ScriptError(
 "Connection check failed!"
-"\nPlease fix your network settings according to error messages above."
+"\nSee /var/log/ipareplica-conncheck.log for more information."
 "\nIf the check results are not valid it can be skipped with --skip-conncheck parameter.")
 else:
 print("Connection check OK")

From 916ea2d4e4eb0230a6f371b3d4d83dc055994cc6 Mon Sep 17 00:00:00 2001
From: Tomas Krizek 
Date: Fri, 25 Nov 2016 17:27:16 +0100
Subject: [PATCH 2/2] replica-conncheck: improve message logging

Make sure all messages displayed on screen to the user can be found
in the log as well. The messages are also logged if the script is ran
in quiet mode.

https://fedorahosted.org/freeipa/ticket/6497
---
 install/tools/ipa-replica-conncheck | 97 +++--
 1 file changed, 51 insertions(+), 46 deletions(-)

diff --git a/install/tools/ipa-replica-conncheck b/install/tools/ipa-replica-conncheck
index 7ec1ef8..225a0df 100755
--- a/install/tools/ipa-replica-conncheck
+++ b/install/tools/ipa-replica-conncheck
@@ -47,7 +47,6 @@ from cryptography.hazmat.primitives import serialization
 
 CONNECT_TIMEOUT = 5
 RESPONDERS = [ ]
-QUIET = False
 CCACHE_FILE = None
 KRB5_CONFIG = None
 
@@ -60,7 +59,7 @@ class SshExec(object):
 def __call__(self, command, verbose=False):
 # Bail if ssh is not installed
 if self.cmd is None:
-print("WARNING: ssh not installed, skipping ssh test")
+root_logger.warning("WARNING: ssh not installed, skipping ssh test")
 return ('', '', 0)
 
 tmpf = tempfile.NamedTemporaryFile()
@@ -108,10 +107,6 @@ BASE_PORTS = [
  ]
 
 
-def print_info(msg):
-if not QUIET:
-print(msg)
-
 def parse_options():
 def ca_cert_file_callback(option, opt, value, parser):
 if not os.path.exists(value):
@@ -205,10 +200,6 @@ def parse_options():
 if not options.hostname:
 options.hostname = socket.getfqdn()
 
-if options.quiet:
-global QUIET
-QUIET = True
-
 return safe_options, options
 
 def logging_setup(options):
@@ -217,7 +208,8 @@ def logging_setup(options):
 if os.getegid() == 0 and options.log_to_file:
 log_file = paths.IPAREPLICA_CONNCHECK_LOG
 
-standard_logging_setup(log_file, debug=options.debug)
+standard_logging_setup(log_file, verbose=(not options.quiet),
+   debug=options.debug, console_format='%(message)s')
 
 def clean_responders(responders):
 if not responders:
@@ -328,13 +320,14 @@ def port_check(host, port_list):
 else:
 ports_failed.append(port)
 result = "FAILED"
-print_info("   %s (%d): %s" % (port.description, port.port, result))
+root_logger.info("   %s (%d): %s" % (port.description, port.port, result))
 
 if ports_udp_warning:
-print("The following UDP ports could not be verified as open: %s" \
-% ", ".join(str(port.port) for port in ports_udp_warning))
-print("This can happen if they are already bound to an application")
-print("and ipa-replica-conncheck cannot attach own UDP responder.")
+root_logger.warning(
+("The following UDP ports could not be verified as open: %s\n"
+ "This can happen if they are already bound to an application\n"
+ "and ipa-replica-conncheck cannot attach own UDP responder.")
+% ", ".join(str(port.port) for port in ports_udp_warning))
 
 if ports_failed:
 msg_ports = []
@@ -362,29 +355,34 @@ def main():
   "PKI-CA: Directory Service port"))
 
 if 

[Freeipa-devel] [freeipa PR#276][synchronized] replica-conncheck: improve error msg + logging

2016-11-28 Thread tomaskrizek
   URL: https://github.com/freeipa/freeipa/pull/276
Author: tomaskrizek
 Title: #276: replica-conncheck: improve error msg + logging
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/276/head:pr276
git checkout pr276
From d46e1a38bb65e20439a6772fbba08df7c4fcef11 Mon Sep 17 00:00:00 2001
From: Tomas Krizek 
Date: Fri, 25 Nov 2016 17:23:29 +0100
Subject: [PATCH 1/2] replica-conncheck: improve error message during
 replicainstall

Replica conncheck may fail for other reasons then network
misconfiguration. For example, an incorrect admin password might be
provided. Since conncheck is ran as a separate script in quiet mode,
no insightful error message can be displayed.

https://fedorahosted.org/freeipa/ticket/6497
---
 ipaserver/install/replication.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index ba35c49..35066c2 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -105,7 +105,7 @@ def replica_conn_check(master_host, host_name, realm, check_ca,
 if result.returncode != 0:
 raise ScriptError(
 "Connection check failed!"
-"\nPlease fix your network settings according to error messages above."
+"\nSee /var/log/ipareplica-conncheck.log for more information."
 "\nIf the check results are not valid it can be skipped with --skip-conncheck parameter.")
 else:
 print("Connection check OK")

From 9ddf77ffb1eb5f996ceeb16e35c808524ee2c6c4 Mon Sep 17 00:00:00 2001
From: Tomas Krizek 
Date: Fri, 25 Nov 2016 17:27:16 +0100
Subject: [PATCH 2/2] replica-conncheck: improve message logging

Make sure all messages displayed on screen to the user can be found
in the log as well. The messages are also logged if the script is ran
in quiet mode.

https://fedorahosted.org/freeipa/ticket/6497
---
 install/tools/ipa-replica-conncheck | 100 +++-
 1 file changed, 53 insertions(+), 47 deletions(-)

diff --git a/install/tools/ipa-replica-conncheck b/install/tools/ipa-replica-conncheck
index 7ec1ef8..a06a2c2 100755
--- a/install/tools/ipa-replica-conncheck
+++ b/install/tools/ipa-replica-conncheck
@@ -47,7 +47,6 @@ from cryptography.hazmat.primitives import serialization
 
 CONNECT_TIMEOUT = 5
 RESPONDERS = [ ]
-QUIET = False
 CCACHE_FILE = None
 KRB5_CONFIG = None
 
@@ -60,7 +59,7 @@ class SshExec(object):
 def __call__(self, command, verbose=False):
 # Bail if ssh is not installed
 if self.cmd is None:
-print("WARNING: ssh not installed, skipping ssh test")
+root_logger.warning("WARNING: ssh not installed, skipping ssh test")
 return ('', '', 0)
 
 tmpf = tempfile.NamedTemporaryFile()
@@ -108,10 +107,6 @@ BASE_PORTS = [
  ]
 
 
-def print_info(msg):
-if not QUIET:
-print(msg)
-
 def parse_options():
 def ca_cert_file_callback(option, opt, value, parser):
 if not os.path.exists(value):
@@ -205,10 +200,6 @@ def parse_options():
 if not options.hostname:
 options.hostname = socket.getfqdn()
 
-if options.quiet:
-global QUIET
-QUIET = True
-
 return safe_options, options
 
 def logging_setup(options):
@@ -217,7 +208,8 @@ def logging_setup(options):
 if os.getegid() == 0 and options.log_to_file:
 log_file = paths.IPAREPLICA_CONNCHECK_LOG
 
-standard_logging_setup(log_file, debug=options.debug)
+standard_logging_setup(log_file, verbose=(not options.quiet),
+   debug=options.debug, console_format='%(message)s')
 
 def clean_responders(responders):
 if not responders:
@@ -328,13 +320,14 @@ def port_check(host, port_list):
 else:
 ports_failed.append(port)
 result = "FAILED"
-print_info("   %s (%d): %s" % (port.description, port.port, result))
+root_logger.info("   %s (%d): %s" % (port.description, port.port, result))
 
 if ports_udp_warning:
-print("The following UDP ports could not be verified as open: %s" \
-% ", ".join(str(port.port) for port in ports_udp_warning))
-print("This can happen if they are already bound to an application")
-print("and ipa-replica-conncheck cannot attach own UDP responder.")
+root_logger.warning(
+("The following UDP ports could not be verified as open: %s\n"
+ "This can happen if they are already bound to an application\n"
+ "and ipa-replica-conncheck cannot attach own UDP responder.")
+% ", ".join(str(port.port) for port in ports_udp_warning))
 
 if ports_failed:
 msg_ports = []
@@ -362,29 +355,34 @@ def main():
   "PKI-CA: Directory Service port"))
 
 if