[Freeipa-devel] [PATCH 4 of 8] Refactor some krbinstance templating code

Mark McLoughlin markmc at redhat.com
Fri Jan 11 12:00:41 UTC 2008


# HG changeset patch
# User Mark McLoughlin <markmc at redhat.com>
# Date 1200047785 0
# Node ID 47a30c3995b2198532255777511d96878fade079
# Parent  85547227bc31c8b12e0569f04ccfb77d2d986f27
Refactor some krbinstance templating code

Signed-off-by: Mark McLoughlin <markmc at redhat.com>

diff -r 85547227bc31 -r 47a30c3995b2 ipa-server/ipaserver/krbinstance.py
--- a/ipa-server/ipaserver/krbinstance.py	Fri Jan 11 10:36:25 2008 +0000
+++ b/ipa-server/ipaserver/krbinstance.py	Fri Jan 11 10:36:25 2008 +0000
@@ -262,32 +262,19 @@ class KrbInstance(service.Service):
     def __create_replica_instance(self):
         self.__create_instance(replica=True)
 
+    def __template_file(self, path):
+        template = os.path.join(ipautil.SHARE_DIR, os.path.basename(path) + ".template")
+        conf = ipautil.template_file(template, self.sub_dict)
+        fd = open(path, "w+")
+        fd.write(conf)
+        fd.close()
+
     def __create_instance(self, replica=False):
-        kdc_conf = ipautil.template_file(ipautil.SHARE_DIR+"kdc.conf.template", self.sub_dict)
-        kdc_fd = open("/var/kerberos/krb5kdc/kdc.conf", "w+")
-        kdc_fd.write(kdc_conf)
-        kdc_fd.close()
-
-        krb5_conf = ipautil.template_file(ipautil.SHARE_DIR+"krb5.conf.template", self.sub_dict)
-        krb5_fd = open("/etc/krb5.conf", "w+")
-        krb5_fd.write(krb5_conf)
-        krb5_fd.close()
-
-        # Windows configuration files
-        krb5_ini = ipautil.template_file(ipautil.SHARE_DIR+"krb5.ini.template", self.sub_dict)
-        krb5_fd = open("/usr/share/ipa/html/krb5.ini", "w+")
-        krb5_fd.write(krb5_ini)
-        krb5_fd.close()
-
-        krb_con = ipautil.template_file(ipautil.SHARE_DIR+"krb.con.template", self.sub_dict)
-        krb_fd = open("/usr/share/ipa/html/krb.con", "w+")
-        krb_fd.write(krb_con)
-        krb_fd.close()
-
-        krb_realm = ipautil.template_file(ipautil.SHARE_DIR+"krbrealm.con.template", self.sub_dict)
-        krb_fd = open("/usr/share/ipa/html/krbrealm.con", "w+")
-        krb_fd.write(krb_realm)
-        krb_fd.close()
+        self.__template_file("/var/kerberos/krb5kdc/kdc.conf")
+        self.__template_file("/etc/krb5.conf")
+        self.__template_file("/usr/share/ipa/html/krb5.ini")
+        self.__template_file("/usr/share/ipa/html/krb.con")
+        self.__template_file("/usr/share/ipa/html/krbrealm.con")
 
         if not replica:
             #populate the directory with the realm structure




More information about the Freeipa-devel mailing list