From 6efac348cdd4182d51d952d9b1bcf5b637c30890 Mon Sep 17 00:00:00 2001
From: Felipe Volpone <fbarreto@redhat.com>
Date: Thu, 27 Jul 2017 14:54:56 -0300
Subject: [PATCH] Changing how commands handles error when it can't connect to
 IPA server

Checking if env has the server attribute. If it doesn't, it means
that a ipa server was not configured.

https://pagure.io/freeipa/issue/6261
---
 ipalib/cli.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ipalib/cli.py b/ipalib/cli.py
index b1605c5ad3..93bd489e4f 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -1346,6 +1346,11 @@ def run(api):
     error = None
     try:
         (_options, argv) = api.bootstrap_with_global_options(context='cli')
+
+        if not hasattr(api.env, 'server'):
+            logger.error('IPA is not configured on this system.')
+            return
+
         for klass in cli_plugins:
             api.add_plugin(klass)
         api.finalize()
