pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0084-replicainstall-better-client-install-exception-handl.patch

ac7d03
From 9303e3d0912e60b2069f7c5bad6b816ed8b033ef Mon Sep 17 00:00:00 2001
ac7d03
From: Stanislav Laznicka <slaznick@redhat.com>
ac7d03
Date: Wed, 5 Apr 2017 09:57:44 +0200
ac7d03
Subject: [PATCH] replicainstall: better client install exception handling
ac7d03
ac7d03
The exception handling of client install inside replica installation
ac7d03
was rather promiscuous, hungrily eating any possible exception thrown
ac7d03
at it. Scoped down the try-except block and reduced its promiscuity.
ac7d03
This change should improve the future development experience debugging
ac7d03
this part of the code.
ac7d03
ac7d03
https://pagure.io/freeipa/issue/6183
ac7d03
ac7d03
Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
ac7d03
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
ac7d03
---
ac7d03
 ipaserver/install/server/replicainstall.py | 83 +++++++++++++++---------------
ac7d03
 1 file changed, 41 insertions(+), 42 deletions(-)
ac7d03
ac7d03
diff --git a/ipaserver/install/server/replicainstall.py b/ipaserver/install/server/replicainstall.py
ac7d03
index 383932b39b9ee99a7a5ce3275a5a7e02581b85b7..aa8e67f60b8abe591d55a907c409b584c74d4541 100644
ac7d03
--- a/ipaserver/install/server/replicainstall.py
ac7d03
+++ b/ipaserver/install/server/replicainstall.py
ac7d03
@@ -895,52 +895,51 @@ def install_check(installer):
ac7d03
 
ac7d03
 
ac7d03
 def ensure_enrolled(installer):
ac7d03
-    # Call client install script
ac7d03
-    service.print_msg("Configuring client side components")
ac7d03
+    args = [paths.IPA_CLIENT_INSTALL, "--unattended", "--no-ntp"]
ac7d03
+    stdin = None
ac7d03
+    nolog = []
ac7d03
+
ac7d03
+    if installer.domain_name:
ac7d03
+        args.extend(["--domain", installer.domain_name])
ac7d03
+    if installer.server:
ac7d03
+        args.extend(["--server", installer.server])
ac7d03
+    if installer.realm_name:
ac7d03
+        args.extend(["--realm", installer.realm_name])
ac7d03
+    if installer.host_name:
ac7d03
+        args.extend(["--hostname", installer.host_name])
ac7d03
+
ac7d03
+    if installer.password:
ac7d03
+        args.extend(["--password", installer.password])
ac7d03
+        nolog.append(installer.password)
ac7d03
+    else:
ac7d03
+        if installer.admin_password:
ac7d03
+            # Always set principal if password was set explicitly,
ac7d03
+            # the password itself gets passed directly via stdin
ac7d03
+            args.extend(["--principal", installer.principal or "admin"])
ac7d03
+            stdin = installer.admin_password
ac7d03
+        if installer.keytab:
ac7d03
+            args.extend(["--keytab", installer.keytab])
ac7d03
+
ac7d03
+    if installer.no_dns_sshfp:
ac7d03
+        args.append("--no-dns-sshfp")
ac7d03
+    if installer.ssh_trust_dns:
ac7d03
+        args.append("--ssh-trust-dns")
ac7d03
+    if installer.no_ssh:
ac7d03
+        args.append("--no-ssh")
ac7d03
+    if installer.no_sshd:
ac7d03
+        args.append("--no-sshd")
ac7d03
+    if installer.mkhomedir:
ac7d03
+        args.append("--mkhomedir")
ac7d03
+    if installer.force_join:
ac7d03
+        args.append("--force-join")
ac7d03
+
ac7d03
     try:
ac7d03
+        # Call client install script
ac7d03
+        service.print_msg("Configuring client side components")
ac7d03
         installer._enrollment_performed = True
ac7d03
-
ac7d03
-        args = [paths.IPA_CLIENT_INSTALL, "--unattended", "--no-ntp"]
ac7d03
-        stdin = None
ac7d03
-        nolog = []
ac7d03
-
ac7d03
-        if installer.domain_name:
ac7d03
-            args.extend(["--domain", installer.domain_name])
ac7d03
-        if installer.server:
ac7d03
-            args.extend(["--server", installer.server])
ac7d03
-        if installer.realm_name:
ac7d03
-            args.extend(["--realm", installer.realm_name])
ac7d03
-        if installer.host_name:
ac7d03
-            args.extend(["--hostname", installer.host_name])
ac7d03
-
ac7d03
-        if installer.password:
ac7d03
-            args.extend(["--password", installer.password])
ac7d03
-            nolog.append(installer.password)
ac7d03
-        else:
ac7d03
-            if installer.admin_password:
ac7d03
-                # Always set principal if password was set explicitly,
ac7d03
-                # the password itself gets passed directly via stdin
ac7d03
-                args.extend(["--principal", installer.principal or "admin"])
ac7d03
-                stdin = installer.admin_password
ac7d03
-            if installer.keytab:
ac7d03
-                args.extend(["--keytab", installer.keytab])
ac7d03
-
ac7d03
-        if installer.no_dns_sshfp:
ac7d03
-            args.append("--no-dns-sshfp")
ac7d03
-        if installer.ssh_trust_dns:
ac7d03
-            args.append("--ssh-trust-dns")
ac7d03
-        if installer.no_ssh:
ac7d03
-            args.append("--no-ssh")
ac7d03
-        if installer.no_sshd:
ac7d03
-            args.append("--no-sshd")
ac7d03
-        if installer.mkhomedir:
ac7d03
-            args.append("--mkhomedir")
ac7d03
-        if installer.force_join:
ac7d03
-            args.append("--force-join")
ac7d03
-
ac7d03
         ipautil.run(args, stdin=stdin, nolog=nolog, redirect_output=True)
ac7d03
         print()
ac7d03
-    except Exception:
ac7d03
+    except ipautil.CalledProcessError:
ac7d03
         raise ScriptError("Configuration of client side components failed!")
ac7d03
 
ac7d03
 
ac7d03
-- 
ac7d03
2.12.2
ac7d03