diff options
author | Mark McLoughlin <markmc@redhat.com> | 2008-01-22 08:03:06 +0000 |
---|---|---|
committer | Mark McLoughlin <markmc@redhat.com> | 2008-01-22 08:03:06 +0000 |
commit | ee7c818bde120f1f41c90e69e76f6800bfafbf14 (patch) | |
tree | f4cd1fd1047786219cc10e6c3fc035fd84cd44b8 | |
parent | 9827ffedb70eccb3f71e73ba5bb75700b9452660 (diff) | |
download | freeipa-ee7c818bde120f1f41c90e69e76f6800bfafbf14.tar.gz freeipa-ee7c818bde120f1f41c90e69e76f6800bfafbf14.tar.xz freeipa-ee7c818bde120f1f41c90e69e76f6800bfafbf14.zip |
Remove questions from ipaserver.dsinstance
Let's assume that all ipaserver.dsinstance could be used
somewhere where asking questions on stdout/stdin is not
approriate and re-factor the code to be suitable in
those situations too.
i.e. make check_existing_installation() return a list of
server IDs and make check_ports() return an (unsecure,
secure) tuple indication which ports are in use.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
-rw-r--r-- | ipa-server/ipa-install/ipa-server-install | 31 | ||||
-rw-r--r-- | ipa-server/ipaserver/dsinstance.py | 28 |
2 files changed, 34 insertions, 25 deletions
diff --git a/ipa-server/ipa-install/ipa-server-install b/ipa-server/ipa-install/ipa-server-install index 041917e29..95b7790e7 100644 --- a/ipa-server/ipa-install/ipa-server-install +++ b/ipa-server/ipa-install/ipa-server-install @@ -245,6 +245,33 @@ def read_admin_password(): admin_password = read_password("IPA admin") return admin_password +def check_dirsrv(): + serverids = ipaserver.dsinstance.check_existing_installation() + if serverids: + print "" + print "An existing Directory Server has been detected." + yesno = raw_input("Do you wish to remove it and create a new one? [no]: ") + if not yesno or yesno.lower()[0] != "y": + sys.exit(1) + + try: + service.stop("dirsrv") + except: + pass + + for serverid in serverids: + ipaserver.dsinstance.erase_ds_instance_data(serverid) + + (ds_unsecure, ds_secure) = ipaserver.dsinstance.check_ports() + if not ds_unsecure or not ds_secure: + print "IPA requires ports 389 and 636 for the Directory Server." + print "These are currently in use:" + if not ds_unsecure: + print "\t389" + if not ds_secure: + print "\t636" + sys.exit(1) + def uninstall(): ipaserver.ntpinstance.NTPInstance().uninstall() ipaserver.bindinstance.BindInstance().uninstall() @@ -280,9 +307,7 @@ def main(): print "To accept the default shown in brackets, press the Enter key." print "" - ipaserver.dsinstance.check_existing_installation() - ipaserver.dsinstance.check_ports() - + check_dirsrv() ds_user = "" realm_name = "" diff --git a/ipa-server/ipaserver/dsinstance.py b/ipa-server/ipaserver/dsinstance.py index b3a445d88..041003382 100644 --- a/ipa-server/ipaserver/dsinstance.py +++ b/ipa-server/ipaserver/dsinstance.py @@ -71,34 +71,18 @@ def erase_ds_instance_data(serverid): def check_existing_installation(): dirs = glob.glob("/etc/dirsrv/slapd-*") if not dirs: - return - print "" - print "An existing Directory Server has been detected." - yesno = raw_input("Do you wish to remove it and create a new one? [no]: ") - if not yesno or yesno.lower()[0] != "y": - sys.exit(1) + return [] - try: - service.stop("dirsrv") - except: - pass + serverids = [] for d in dirs: - serverid = os.path.basename(d).split("slapd-", 1)[1] - if serverid: - erase_ds_instance_data(serverid) + serverids.append(os.path.basename(d).split("slapd-", 1)[1]) + + return serverids def check_ports(): ds_unsecure = installutils.port_available(389) ds_secure = installutils.port_available(636) - if not ds_unsecure or not ds_secure: - print "IPA requires ports 389 and 636 for the Directory Server." - print "These are currently in use:" - if not ds_unsecure: - print "\t389" - if not ds_secure: - print "\t636" - sys.exit(1) - + return (ds_unsecure, ds_secure) INF_TEMPLATE = """ [General] |