86baa9
From a9b0d9b109d0f35adbf45ef8d158f276014c7c8b Mon Sep 17 00:00:00 2001
86baa9
From: Christian Heimes <cheimes@redhat.com>
86baa9
Date: Tue, 26 Mar 2019 20:09:27 +0100
86baa9
Subject: [PATCH] Don't fail if config-show does not return servers
86baa9
86baa9
When uninstalling a cluster and only hidden servers are left,
86baa9
config-show can return a result set without ipa_master_server entry.
86baa9
86baa9
Fixes: https://pagure.io/freeipa/issue/7892
86baa9
Signed-off-by: Christian Heimes <cheimes@redhat.com>
86baa9
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
86baa9
Reviewed-By: Francois Cami <fcami@redhat.com>
86baa9
---
86baa9
 ipaserver/install/ca.py     | 2 +-
86baa9
 ipaserver/plugins/pkinit.py | 2 +-
86baa9
 ipaserver/plugins/server.py | 2 +-
86baa9
 3 files changed, 3 insertions(+), 3 deletions(-)
86baa9
86baa9
diff --git a/ipaserver/install/ca.py b/ipaserver/install/ca.py
86baa9
index 716f3b3dc1fc81438b74d4fa393f7f17d6d2a802..09b3c09e758775de77cdf4ac5cae755183aa8f8c 100644
86baa9
--- a/ipaserver/install/ca.py
86baa9
+++ b/ipaserver/install/ca.py
86baa9
@@ -106,7 +106,7 @@ def uninstall_check(options):
86baa9
 
86baa9
     # skip the checks if the host is the last master
86baa9
     ipa_config = api.Command.config_show()['result']
86baa9
-    ipa_masters = ipa_config['ipa_master_server']
86baa9
+    ipa_masters = ipa_config.get('ipa_master_server', [])
86baa9
     if len(ipa_masters) <= 1:
86baa9
         return
86baa9
 
86baa9
diff --git a/ipaserver/plugins/pkinit.py b/ipaserver/plugins/pkinit.py
86baa9
index 8853938460073f69f6e6242c5ae5c362b3faf4f7..6d42a9af11f2079054e59416f3930fbae5b65555 100644
86baa9
--- a/ipaserver/plugins/pkinit.py
86baa9
+++ b/ipaserver/plugins/pkinit.py
86baa9
@@ -91,7 +91,7 @@ class pkinit_status(Search):
86baa9
         if server is not None:
86baa9
             servers = [server]
86baa9
         else:
86baa9
-            servers = ipa_master_config['ipa_master_server']
86baa9
+            servers = ipa_master_config.get('ipa_master_server', [])
86baa9
 
86baa9
         pkinit_servers = ipa_master_config.get('pkinit_server_server')
86baa9
         if pkinit_servers is None:
86baa9
diff --git a/ipaserver/plugins/server.py b/ipaserver/plugins/server.py
86baa9
index bfd1406ff826aea97195aa08ca35018e35cac18c..ee9c2ba7440dce276213bb97eaca621e1ef33efe 100644
86baa9
--- a/ipaserver/plugins/server.py
86baa9
+++ b/ipaserver/plugins/server.py
86baa9
@@ -482,7 +482,7 @@ class server_del(LDAPDelete):
86baa9
 
86baa9
         ipa_config = self.api.Command.config_show()['result']
86baa9
 
86baa9
-        ipa_masters = ipa_config['ipa_master_server']
86baa9
+        ipa_masters = ipa_config.get('ipa_master_server', [])
86baa9
 
86baa9
         # skip these checks if the last master is being removed
86baa9
         if len(ipa_masters) <= 1:
86baa9
-- 
86baa9
2.20.1
86baa9