URL: https://github.com/freeipa/freeipa/pull/797
Author: flo-renaud
 Title: #797: ipa-replica-conncheck: handle ssh not installed
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/797/head:pr797
git checkout pr797
From 91f0fa915b5c2e0765bccc47d20517d6afa9351e Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <f...@redhat.com>
Date: Thu, 18 May 2017 17:01:19 +0200
Subject: [PATCH] ipa-replica-conncheck: handle ssh not installed

When ipa-replica-conncheck is run but ssh is not installed, the tool exits
with a stack trace. Properly handle the error by raising an Exception.
The tool will exit with the following output:
[...]
Check RPC connection to remote master
trying https://master.domain.com/ipa/session/json
Forwarding 'schema' to json server 'https://master.domain.com/ipa/session/json'
Retrying using SSH...
ERROR: Remote master check failed with the following error message:
Could not SSH to remote host, ssh not installed

https://pagure.io/freeipa/issue/6935
---
 install/tools/ipa-replica-conncheck | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/install/tools/ipa-replica-conncheck b/install/tools/ipa-replica-conncheck
index fdbd4f32d9..9680a50767 100755
--- a/install/tools/ipa-replica-conncheck
+++ b/install/tools/ipa-replica-conncheck
@@ -59,12 +59,12 @@ class SshExec(object):
         self.user = user
         self.addr = addr
         self.cmd = distutils.spawn.find_executable('ssh')
-
-    def __call__(self, command, verbose=False):
         # Bail if ssh is not installed
         if self.cmd is None:
-            root_logger.warning("WARNING: ssh not installed, skipping ssh test")
-            return ('', '', 0)
+            raise RuntimeError("Could not SSH to remote host, "
+                               "ssh not installed")
+
+    def __call__(self, command, verbose=False):
 
         tmpf = tempfile.NamedTemporaryFile()
         cmd = [
@@ -594,7 +594,12 @@ def main():
 
                 # Ticket 5812 Always qualify requests for admin
                 user = principal
-                ssh = SshExec(user, options.master)
+                try:
+                    ssh = SshExec(user, options.master)
+                except RuntimeError as e:
+                    raise RuntimeError(
+                        "Remote master check failed with the following "
+                        "error message:\n%s" % e)
 
                 root_logger.info("Check SSH connection to remote master")
                 result = ssh('echo OK', verbose=True)
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to