From 4e634db2fb96f835a263fa6306fba7da559a5b3b Mon Sep 17 00:00:00 2001
From: Abhijeet Kasurde <akasurde@redhat.com>
Date: Tue, 23 Aug 2016 17:34:51 +0530
Subject: [PATCH] Handled empty hostname in server-del command

Fixes: https://fedorahosted.org/freeipa/ticket/6248

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
---
 ipaclient/plugins/server.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/ipaclient/plugins/server.py b/ipaclient/plugins/server.py
index 725a2ce..b45a6e8 100644
--- a/ipaclient/plugins/server.py
+++ b/ipaclient/plugins/server.py
@@ -3,7 +3,7 @@
 #
 
 from ipaclient.frontend import MethodOverride
-from ipalib import _
+from ipalib import _, errors
 from ipalib.plugable import Registry
 
 register = Registry()
@@ -12,6 +12,12 @@
 @register(override=True, no_fail=True)
 class server_del(MethodOverride):
     def interactive_prompt_callback(self, kw):
+        server_list = []
+        try:
+            server_list = kw['cn']
+        except Exception as e:
+            raise errors.ValidationError(name='cn', error=_(u'cn is required'))
+
         self.api.Backend.textui.print_plain(
             _("Removing %(servers)s from replication topology, "
-              "please wait...") % {'servers': ', '.join(kw['cn'])})
+              "please wait...") % {'servers': ', '.join(server_list)})
