summaryrefslogtreecommitdiffstats
path: root/ipa-server
diff options
context:
space:
mode:
Diffstat (limited to 'ipa-server')
-rw-r--r--ipa-server/ipa-install/ipa-replica-install10
-rw-r--r--ipa-server/ipa-install/ipa-server-certinstall19
-rw-r--r--ipa-server/ipa-install/ipa-server-install64
3 files changed, 31 insertions, 62 deletions
diff --git a/ipa-server/ipa-install/ipa-replica-install b/ipa-server/ipa-install/ipa-replica-install
index 31fd4ccd..ab66a838 100644
--- a/ipa-server/ipa-install/ipa-replica-install
+++ b/ipa-server/ipa-install/ipa-replica-install
@@ -145,8 +145,7 @@ def check_dirsrv():
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":
+ if not ipautil.user_input("Do you wish to remove it and create a new one?", False)
print ""
print "Only a single Directory Server instance is allowed on an IPA"
print "server, the one used by IPA itself."
@@ -189,12 +188,9 @@ def main():
if host != config.host_name:
try:
print "This replica was created for '%s' but this machine is named '%s'" % (host, config.host_name)
- yesno = raw_input("This may cause problems. Continue? [Y/n]: ")
- print ""
- if not yesno or yesno.lower()[0] == "y":
- pass
- else:
+ if not ipautil.user_input("This may cause problems. Continue?", True)
sys.exit(0)
+ print ""
except KeyboardInterrupt:
sys.exit(0)
config.repl_password = ipautil.ipa_generate_password()
diff --git a/ipa-server/ipa-install/ipa-server-certinstall b/ipa-server/ipa-install/ipa-server-certinstall
index 835af0aa..a0d11856 100644
--- a/ipa-server/ipa-install/ipa-server-certinstall
+++ b/ipa-server/ipa-install/ipa-server-certinstall
@@ -27,6 +27,7 @@ import traceback
import krbV, ldap, getpass
+from ipa.ipautil import user_input
from ipaserver import certs, dsinstance, httpinstance, ipaldap, installutils
def get_realm_name():
@@ -76,25 +77,15 @@ def choose_server_cert(server_certs):
print "%d. %s" % (num, cert[0])
num += 1
- cert_num = 0
while 1:
- cert_input = raw_input("Certificate number [1]: ")
+ num = user_input("Certificate number", 1)
print ""
- if cert_input == "":
- break
+ if num < 1 or num > len(server_certs):
+ print "number out of range"
else:
- try:
- num = int(cert_input)
- except ValueError:
- print "invalid number"
- continue
- if num > len(server_certs):
- print "number out of range"
- continue
- cert_num = num - 1
break
- return server_certs[cert_num]
+ return server_certs[num - 1]
def import_cert(dirname, pkcs12_fname, pkcs12_passwd, db_password):
cdb = certs.CertDB(dirname)
diff --git a/ipa-server/ipa-install/ipa-server-install b/ipa-server/ipa-install/ipa-server-install
index 8b5b831c..ce300cc7 100644
--- a/ipa-server/ipa-install/ipa-server-install
+++ b/ipa-server/ipa-install/ipa-server-install
@@ -120,7 +120,6 @@ def signal_handler(signum, frame):
sys.exit(1)
def read_host_name(host_default):
- host_ok = False
host_name = ""
print "Enter the fully qualified domain name of the computer"
@@ -131,19 +130,15 @@ def read_host_name(host_default):
print ""
if host_default == "":
host_default = "master.example.com"
- while not host_ok:
- host_input = raw_input("Server host name [" + host_default + "]: ")
+ while True:
+ host_name = user_input("Server host name", host_default, allow_empty = False)
print ""
- if host_input == "":
- host_name = host_default
- else:
- host_name = host_input
try:
verify_fqdn(host_name)
except Exception, e:
raise e
else:
- host_ok = True
+ break
return host_name
def resolve_host(host_name):
@@ -178,10 +173,8 @@ def verify_ip_address(ip):
def read_ip_address(host_name):
while True:
- ip = raw_input("Please provide the IP address to be used for this host name: ")
+ ip = user_input("Please provide the IP address to be used for this host name", allow_empty = False)
- if ip == "":
- continue
if ip == "127.0.0.1" or ip == "::1":
print "The IPA Server can't use localhost as a valid IP"
continue
@@ -213,13 +206,12 @@ def read_ds_user():
print "A user account named 'dirsrv' already exists. This is the user id"
print "that the Directory Server will run as."
print ""
- yesno = raw_input("Do you want to use the existing 'dirsrv' account? [yes]: ")
- print ""
- if not yesno or yesno.lower()[0] != "n":
+ if user_input("Do you want to use the existing 'dirsrv' account?", True):
ds_user = "dirsrv"
else:
- ds_user = raw_input("Which account name do you want to use for the DS instance? ")
print ""
+ ds_user = user_input_plain("Which account name do you want to use for the DS instance?", allow_empty = False, allow_spaces = False)
+ print ""
except KeyError:
ds_user = "dirsrv"
@@ -229,37 +221,31 @@ def read_domain_name(domain_name, unattended):
print "The domain name has been calculated based on the host name."
print ""
if not unattended:
- dn = raw_input("Please confirm the domain name ["+domain_name+"]: ")
+ domain_name = user_input("Please confirm the domain name", domain_name)
print ""
- if dn != "":
- domain_name = dn
return domain_name
def read_realm_name(domain_name, unattended):
print "The kerberos protocol requires a Realm name to be defined."
print "This is typically the domain name converted to uppercase."
print ""
- upper_dom = domain_name.upper()
+
if unattended:
- realm_name = upper_dom
- else:
- realm_name = raw_input("Please provide a realm name ["+upper_dom+"]: ")
- print ""
- if realm_name == "":
- realm_name = upper_dom
- else:
- upper_dom = realm_name.upper()
- if upper_dom != realm_name:
- print "An upper-case realm name is required."
- dom_realm = raw_input("Do you want to use "+upper_dom+" as realm name ? [yes]: ")
+ return domain_name.upper()
+ realm_name = user_input("Please provide a realm name", domain_name.upper())
+ upper_dom = realm_name.upper()
+ if upper_dom != realm_name:
+ print "An upper-case realm name is required."
+ if not user_input("Do you want to use " + upper_dom + " as realm name?", True):
print ""
- if dom_realm and dom_realm.lower()[0] != "y":
- print "An upper-case realm name is required. Unable to continue."
- sys.exit(1)
- else:
- realm_name = upper_dom
+ print "An upper-case realm name is required. Unable to continue."
+ sys.exit(1)
+ else:
+ realm_name = upper_dom
+ print ""
return realm_name
+
def read_dm_password():
print "Certain directory server operations require an administrative user."
print "This user is referred to as the Directory Manager and has full access"
@@ -284,10 +270,7 @@ def check_dirsrv(unattended):
if serverids:
print ""
print "An existing Directory Server has been detected."
- if unattended:
- sys.exit(1)
- yesno = raw_input("Do you wish to remove it and create a new one? [no]: ")
- if not yesno or yesno.lower()[0] != "y":
+ if unattended or user_input("Do you wish to remove it and create a new one?", False):
print ""
print "Only a single Directory Server instance is allowed on an IPA"
print "server, the one used by IPA itself."
@@ -354,8 +337,7 @@ def main():
if options.uninstall:
if not options.unattended:
print "\nThis is a NON REVERSIBLE operation and will delete all data and configuration!\n"
- yesno = raw_input("Are you sure you want to continue with the uninstall procedure?:[NO/yes] ")
- if not yesno or yesno.lower() != "yes":
+ if not user_input("Are you sure you want to continue with the uninstall procedure?", False)
print ""
print "Aborting uninstall operation."
sys.exit(1)