From 56063ae3732d7ec3d057d903250ec5004f5c4d6a Mon Sep 17 00:00:00 2001
From: Thomas Woerner <twoerner@redhat.com>
Date: Thu, 14 Sep 2017 13:29:56 +0200
Subject: [PATCH] library/ipadiscovery.py: Compatibilty to ipa 4.4 and later,
 new version check

freeipa 4.4 is the first version that supports all needed functions.
Therefore a check has been added to make sure that ipadiscovery fails for
versions before 4.4.

The python bindings of ipa versions before 4.6 are having a different
structure.
---
 library/ipadiscovery.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/library/ipadiscovery.py b/library/ipadiscovery.py
index 65a20597..cc150982 100644
--- a/library/ipadiscovery.py
+++ b/library/ipadiscovery.py
@@ -162,9 +162,16 @@ if NUM_VERSION < 30201:
 else:
     IPA_PYTHON_VERSION = NUM_VERSION
 from ipapython.dn import DN
-from ipaclient.install import ipadiscovery
-from ipalib.install.sysrestore import SYSRESTORE_STATEFILE
 from ipaplatform.paths import paths
+try:
+    from ipaclient.install import ipadiscovery
+except ImportError:
+    from ipaclient import ipadiscovery
+try:
+    from ipalib.install.sysrestore import SYSRESTORE_STATEFILE
+except ImportError:
+    from ipapython.sysrestore import SYSRESTORE_STATEFILE
+
 
 def get_cert_path(cert_path):
     """
-- 
GitLab