URL: https://github.com/freeipa/freeipa/pull/372
Author: tiran
 Title: #372: Restore IPA 3.0 compatibility of copy-schema-to-ca.py
Action: opened

PR body:
"""
Apparently ipaplatform.paths is not available on IPA 3.x.

https://fedorahosted.org/freeipa/ticket/6540

Signed-off-by: Christian Heimes <chei...@redhat.com>
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/372/head:pr372
git checkout pr372
From fb896f46f0722113dd1345f5708685bafab06d6f Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Thu, 5 Jan 2017 12:46:50 +0100
Subject: [PATCH] Restore IPA 3.0 compatibility of copy-schema-to-ca.py

Apparently ipaplatform.paths is not available on IPA 3.x.

https://fedorahosted.org/freeipa/ticket/6540

Signed-off-by: Christian Heimes <chei...@redhat.com>
---
 install/share/copy-schema-to-ca.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/install/share/copy-schema-to-ca.py b/install/share/copy-schema-to-ca.py
index 4daed6f..b14c3dd 100755
--- a/install/share/copy-schema-to-ca.py
+++ b/install/share/copy-schema-to-ca.py
@@ -17,7 +17,6 @@
 
 from hashlib import sha1
 
-from ipaplatform.paths import paths
 from ipapython import ipautil
 from ipapython.ipa_log_manager import root_logger, standard_logging_setup
 from ipaserver.install.dsinstance import schema_dirname
@@ -35,6 +34,14 @@
     from ipaserver.install.cainstance import PKI_USER  #pylint: disable=E0611
 
 try:
+    from ipaplatform.paths import paths
+    USR_SHARE_IPA_DIR = paths.USR_SHARE_IPA_DIR
+    ETC_IPA = paths.ETC_IPA
+except (ImportError, AttributeError):
+    USR_SHARE_IPA_DIR = "/usr/share/ipa/"
+    ETC_IPA = "/etc/ipa"
+
+try:
     from ipaplatform import services
 except ImportError:
     from ipapython import services  # pylint: disable=no-name-in-module
@@ -66,7 +73,7 @@ def add_ca_schema():
     pki_pent = pwd.getpwnam(PKI_USER)
     ds_pent = pwd.getpwnam(DS_USER)
     for schema_fname in SCHEMA_FILENAMES:
-        source_fname = os.path.join(paths.USR_SHARE_IPA_DIR, schema_fname)
+        source_fname = os.path.join(USR_SHARE_IPA_DIR, schema_fname)
         target_fname = os.path.join(schema_dirname(SERVERID), schema_fname)
         if not os.path.exists(source_fname):
             root_logger.debug('File does not exist: %s', source_fname)
@@ -114,7 +121,7 @@ def main():
     standard_logging_setup(verbose=True)
 
     # In 3.0, restarting needs access to api.env
-    api.bootstrap_with_global_options(context='server', confdir=paths.ETC_IPA)
+    api.bootstrap_with_global_options(context='server', confdir=ETC_IPA)
 
     add_ca_schema()
     restart_pki_ds()
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to