mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Wrap up the raw_input() to user_input() for convenience and uniformity.
This commit is contained in:
committed by
Rob Crittenden
parent
72a3114a01
commit
f7ca405716
@@ -81,29 +81,16 @@ def main():
|
|||||||
if options.usage:
|
if options.usage:
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
cont = False
|
|
||||||
|
|
||||||
if (len(args) != 2):
|
if (len(args) != 2):
|
||||||
while (cont != True):
|
cn = ipautil.user_input("Group name", allow_empty = False)
|
||||||
cn = raw_input("Group name: ")
|
|
||||||
if (ipavalidate.String(cn, notEmpty=True)):
|
|
||||||
print "Please enter a value"
|
|
||||||
else:
|
|
||||||
cont = True
|
|
||||||
else:
|
else:
|
||||||
cn = args[1]
|
cn = args[1]
|
||||||
if (ipavalidate.String(cn, notEmpty=True)):
|
if (ipavalidate.String(cn, notEmpty=True)):
|
||||||
print "Please enter a value"
|
print "Please enter a value"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
cont = False
|
|
||||||
if not options.desc:
|
if not options.desc:
|
||||||
while (cont != True):
|
desc = ipautil.user_input("Description", allow_empty = False)
|
||||||
desc = raw_input("Description: ")
|
|
||||||
if (ipavalidate.String(desc, notEmpty=True)):
|
|
||||||
print "Please enter a value"
|
|
||||||
else:
|
|
||||||
cont = True
|
|
||||||
else:
|
else:
|
||||||
desc = options.desc
|
desc = options.desc
|
||||||
if (ipavalidate.String(desc, notEmpty=True)):
|
if (ipavalidate.String(desc, notEmpty=True)):
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ def main():
|
|||||||
groups = ""
|
groups = ""
|
||||||
|
|
||||||
match = False
|
match = False
|
||||||
cont = False
|
|
||||||
|
|
||||||
all_interactive = False
|
all_interactive = False
|
||||||
|
|
||||||
@@ -116,40 +115,23 @@ def main():
|
|||||||
all_interactive = True
|
all_interactive = True
|
||||||
|
|
||||||
if not options.gn:
|
if not options.gn:
|
||||||
while (cont != True):
|
givenname = ipautil.user_input("First name", allow_empty = False)
|
||||||
givenname = raw_input("First name: ")
|
|
||||||
if (ipavalidate.String(givenname, notEmpty=True)):
|
|
||||||
print "Please enter a value"
|
|
||||||
else:
|
|
||||||
cont = True
|
|
||||||
else:
|
else:
|
||||||
givenname = options.gn
|
givenname = options.gn
|
||||||
if (ipavalidate.String(givenname, notEmpty=True)):
|
if (ipavalidate.String(givenname, notEmpty=True)):
|
||||||
print "Please enter a value"
|
print "Please enter a value"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
cont = False
|
|
||||||
if not options.sn:
|
if not options.sn:
|
||||||
while (cont != True):
|
lastname = ipautil.user_input("Last name", allow_empty = False)
|
||||||
lastname = raw_input("Last name: ")
|
|
||||||
if (ipavalidate.String(lastname, notEmpty=True)):
|
|
||||||
print "Please enter a value"
|
|
||||||
else:
|
|
||||||
cont = True
|
|
||||||
else:
|
else:
|
||||||
lastname = options.sn
|
lastname = options.sn
|
||||||
if (ipavalidate.String(lastname, notEmpty=True)):
|
if (ipavalidate.String(lastname, notEmpty=True)):
|
||||||
print "Please enter a value"
|
print "Please enter a value"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
cont = False
|
|
||||||
if (len(args) != 2):
|
if (len(args) != 2):
|
||||||
while (cont != True):
|
username = ipautil.user_input_plain("Login name", allow_empty = False, allow_spaces = False)
|
||||||
username = raw_input("Login name: ")
|
|
||||||
if (ipavalidate.Plain(username, notEmpty=True, allowSpaces=False)):
|
|
||||||
print "Please enter a value"
|
|
||||||
else:
|
|
||||||
cont = True
|
|
||||||
else:
|
else:
|
||||||
username = args[1]
|
username = args[1]
|
||||||
if (ipavalidate.Plain(username, notEmpty=True, allowSpaces=False)):
|
if (ipavalidate.Plain(username, notEmpty=True, allowSpaces=False)):
|
||||||
@@ -180,32 +162,12 @@ def main():
|
|||||||
# Ask the questions we don't normally force. We don't require answers
|
# Ask the questions we don't normally force. We don't require answers
|
||||||
# for these.
|
# for these.
|
||||||
if all_interactive is True:
|
if all_interactive is True:
|
||||||
cont = False
|
|
||||||
if not options.gecos:
|
if not options.gecos:
|
||||||
while (cont != True):
|
gecos = ipautil.user_input("gecos")
|
||||||
gecos = raw_input("gecos []: ")
|
|
||||||
if (ipavalidate.String(gecos, notEmpty=False)):
|
|
||||||
print "Please enter a value"
|
|
||||||
else:
|
|
||||||
cont = True
|
|
||||||
cont = False
|
|
||||||
if not options.directory:
|
if not options.directory:
|
||||||
while (cont != True):
|
directory = ipautil.user_input_path("Home directory", "/home/" + username, allow_empty = True)
|
||||||
directory = raw_input("home directory [/home/"+username+"]: ")
|
|
||||||
if directory == "":
|
|
||||||
directory = "/home/"+username
|
|
||||||
if (ipavalidate.Path(directory, notEmpty=False)):
|
|
||||||
print "Please enter a value"
|
|
||||||
else:
|
|
||||||
cont = True
|
|
||||||
cont = False
|
|
||||||
if not options.shell:
|
if not options.shell:
|
||||||
while (cont != True):
|
shell = ipautil.user_input("Shell", "/bin/sh", allow_empty = False)
|
||||||
shell = raw_input("shell [/bin/sh]: ")
|
|
||||||
|
|
||||||
if len(shell) < 1:
|
|
||||||
shell = None
|
|
||||||
cont = True
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
gecos = options.gecos
|
gecos = options.gecos
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ def main():
|
|||||||
shell = ""
|
shell = ""
|
||||||
|
|
||||||
match = False
|
match = False
|
||||||
cont = False
|
|
||||||
|
|
||||||
options, args = parse_options()
|
options, args = parse_options()
|
||||||
|
|
||||||
@@ -141,46 +140,23 @@ def main():
|
|||||||
shell = options.shell
|
shell = options.shell
|
||||||
else:
|
else:
|
||||||
if not options.gn:
|
if not options.gn:
|
||||||
while (cont != True):
|
givenname = ipautil.user_input("First name", user.getValue('givenname'), allow_empty = False)
|
||||||
givenname = raw_input("First name: [%s] " % user.getValue('givenname'))
|
|
||||||
if (ipavalidate.String(givenname, notEmpty=False)):
|
|
||||||
print "Please enter a value"
|
|
||||||
else:
|
|
||||||
cont = True
|
|
||||||
if len(givenname) < 1:
|
|
||||||
givenname = None
|
|
||||||
cont = True
|
|
||||||
else:
|
else:
|
||||||
givenname = options.gn
|
givenname = options.gn
|
||||||
if (ipavalidate.String(givenname, notEmpty=True)):
|
if (ipavalidate.String(givenname, notEmpty=True)):
|
||||||
print "Please enter a value"
|
print "Please enter a value"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
cont = False
|
|
||||||
if not options.sn:
|
if not options.sn:
|
||||||
while (cont != True):
|
lastname = ipautil.user_input("Last name", user.getValue('sn'), allow_empty = False)
|
||||||
lastname = raw_input(" Last name: [%s] " % user.getValue('sn'))
|
|
||||||
if (ipavalidate.String(lastname, notEmpty=False)):
|
|
||||||
print "Please enter a value"
|
|
||||||
else:
|
|
||||||
cont = True
|
|
||||||
if len(lastname) < 1:
|
|
||||||
lastname = None
|
|
||||||
cont = True
|
|
||||||
else:
|
else:
|
||||||
lastname = options.sn
|
lastname = options.sn
|
||||||
if (ipavalidate.String(lastname, notEmpty=True)):
|
if (ipavalidate.String(lastname, notEmpty=True)):
|
||||||
print "Please enter a value"
|
print "Please enter a value"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
cont = False
|
|
||||||
if not options.mail:
|
if not options.mail:
|
||||||
while (cont != True):
|
mail = ipautil.user_input_email("E-mail address", user.getValue('mail'), allow_empty = True)
|
||||||
mail = raw_input("E-mail addr: [%s]" % user.getValue('mail'))
|
|
||||||
if (ipavalidate.Email(mail, notEmpty=False)):
|
|
||||||
print "E-mail must include a user and domain name"
|
|
||||||
else:
|
|
||||||
cont = True
|
|
||||||
else:
|
else:
|
||||||
mail = options.mail
|
mail = options.mail
|
||||||
if (ipavalidate.Email(mail)):
|
if (ipavalidate.Email(mail)):
|
||||||
@@ -189,32 +165,13 @@ def main():
|
|||||||
|
|
||||||
# Ask the questions we don't normally force. We don't require answers
|
# Ask the questions we don't normally force. We don't require answers
|
||||||
# for these.
|
# for these.
|
||||||
cont = False
|
|
||||||
if not options.gecos:
|
if not options.gecos:
|
||||||
while (cont != True):
|
gecos = ipautil.user_input("gecos", user.getValue('gecos'))
|
||||||
gecos = raw_input("gecos: [%s] " % user.getValue('gecos'))
|
|
||||||
if (ipavalidate.String(gecos, notEmpty=False)):
|
|
||||||
print "Please enter a value"
|
|
||||||
else:
|
|
||||||
cont = True
|
|
||||||
|
|
||||||
cont = False
|
|
||||||
if not options.directory:
|
if not options.directory:
|
||||||
while (cont != True):
|
directory = ipautil.user_input_path("Home directory", user.getValue('homeDirectory'))
|
||||||
directory = raw_input("home directory: [%s] " % user.getValue('homeDirectory'))
|
|
||||||
if (ipavalidate.Path(gecos, notEmpty=False)):
|
|
||||||
print "Valid path is required"
|
|
||||||
else:
|
|
||||||
cont = True
|
|
||||||
cont = False
|
|
||||||
if not options.shell:
|
if not options.shell:
|
||||||
while (cont != True):
|
shell = ipautil.user_input("Shell", user.getValue('loginshell'), allow_empty = False)
|
||||||
shell = raw_input("shell: [%s] " % user.getValue('loginshell'))
|
|
||||||
|
|
||||||
if len(shell) < 1:
|
|
||||||
shell = None
|
|
||||||
cont = True
|
|
||||||
cont = False
|
|
||||||
|
|
||||||
if givenname:
|
if givenname:
|
||||||
user.setValue('givenname', givenname)
|
user.setValue('givenname', givenname)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ try:
|
|||||||
import ipaclient.ipadiscovery
|
import ipaclient.ipadiscovery
|
||||||
import ipaclient.ipachangeconf
|
import ipaclient.ipachangeconf
|
||||||
import ipaclient.ntpconf
|
import ipaclient.ntpconf
|
||||||
from ipa.ipautil import run
|
from ipa.ipautil import run, user_input
|
||||||
from ipa import sysrestore
|
from ipa import sysrestore
|
||||||
from ipa import version
|
from ipa import version
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -70,13 +70,6 @@ def parse_options():
|
|||||||
|
|
||||||
return options
|
return options
|
||||||
|
|
||||||
def ask_for_confirmation(message):
|
|
||||||
yesno = raw_input(message + " [y/N]: ")
|
|
||||||
if not yesno or yesno.lower()[0] != "y":
|
|
||||||
return False
|
|
||||||
print "\n"
|
|
||||||
return True
|
|
||||||
|
|
||||||
def logging_setup(options):
|
def logging_setup(options):
|
||||||
# Always log everything (i.e., DEBUG) to the log
|
# Always log everything (i.e., DEBUG) to the log
|
||||||
# file.
|
# file.
|
||||||
@@ -124,7 +117,7 @@ def uninstall(options):
|
|||||||
print "The original nsswitch.conf configuration has been restored."
|
print "The original nsswitch.conf configuration has been restored."
|
||||||
print "You may need to restart services or reboot the machine."
|
print "You may need to restart services or reboot the machine."
|
||||||
if not options.on_master:
|
if not options.on_master:
|
||||||
if ask_for_confirmation("Do you want to reboot the machine?"):
|
if user_input("Do you want to reboot the machine?", False):
|
||||||
try:
|
try:
|
||||||
run(["/usr/bin/reboot"])
|
run(["/usr/bin/reboot"])
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
@@ -163,9 +156,7 @@ def main():
|
|||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
print "DNS discovery failed to determine your DNS domain"
|
print "DNS discovery failed to determine your DNS domain"
|
||||||
cli_domain = ""
|
cli_domain = user_input("Please provide the domain name of your IPA server (ex: example.com)", allow_empty = False)
|
||||||
while cli_domain == "":
|
|
||||||
cli_domain = raw_input("Please provide the domain name of your IPA server (ex: example.com): ")
|
|
||||||
ret = ds.search(domain=cli_domain, server=options.server)
|
ret = ds.search(domain=cli_domain, server=options.server)
|
||||||
if not cli_domain:
|
if not cli_domain:
|
||||||
if ds.getDomainName():
|
if ds.getDomainName():
|
||||||
@@ -180,9 +171,7 @@ def main():
|
|||||||
return ret
|
return ret
|
||||||
else:
|
else:
|
||||||
print "DNS discovery failed to find the IPA Server"
|
print "DNS discovery failed to find the IPA Server"
|
||||||
cli_server = ""
|
cli_server = user_input("Please provide your IPA server name (ex: ipa.example.com)", allow_empty = False)
|
||||||
while cli_server == "":
|
|
||||||
cli_server = raw_input("Please provide your IPA server name (ex: ipa.example.com): ")
|
|
||||||
ret = ds.search(domain=cli_domain, server=cli_server)
|
ret = ds.search(domain=cli_domain, server=cli_server)
|
||||||
if not cli_server:
|
if not cli_server:
|
||||||
if ds.getServerName():
|
if ds.getServerName():
|
||||||
@@ -203,7 +192,7 @@ def main():
|
|||||||
print "If you proceed with the installation, services will be configured to always"
|
print "If you proceed with the installation, services will be configured to always"
|
||||||
print "access the discovered server for all operation and will not fail over to"
|
print "access the discovered server for all operation and will not fail over to"
|
||||||
print "other servers in case of failure.\n"
|
print "other servers in case of failure.\n"
|
||||||
if not ask_for_confirmation("Do you want to proceed and configure the system with fixed values with no DNS discovery?"):
|
if not user_input("Do you want to proceed and configure the system with fixed values with no DNS discovery?", False):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
if options.realm_name and options.realm_name != ds.getRealmName():
|
if options.realm_name and options.realm_name != ds.getRealmName():
|
||||||
@@ -220,7 +209,7 @@ def main():
|
|||||||
print "BaseDN: "+cli_basedn
|
print "BaseDN: "+cli_basedn
|
||||||
|
|
||||||
print "\n"
|
print "\n"
|
||||||
if not options.unattended and not ask_for_confirmation("Continue to configure the system with these values?"):
|
if not options.unattended and not user_input("Continue to configure the system with these values?", False):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# Configure ipa.conf
|
# Configure ipa.conf
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import os, sys, traceback, readline
|
|||||||
import stat
|
import stat
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
from ipa import ipavalidate
|
||||||
from types import *
|
from types import *
|
||||||
|
|
||||||
import re
|
import re
|
||||||
@@ -482,6 +483,71 @@ def read_items_file(filename):
|
|||||||
if fd != sys.stdin: fd.close()
|
if fd != sys.stdin: fd.close()
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
def user_input(prompt, default = None, allow_empty = True):
|
||||||
|
if default == None:
|
||||||
|
while True:
|
||||||
|
ret = raw_input("%s: " % prompt)
|
||||||
|
if allow_empty or ret.strip():
|
||||||
|
return ret
|
||||||
|
|
||||||
|
if isinstance(default, basestring):
|
||||||
|
while True:
|
||||||
|
ret = raw_input("%s [%s]: " % (prompt, default))
|
||||||
|
if not ret and (allow_empty or default):
|
||||||
|
return default
|
||||||
|
elif ret.strip():
|
||||||
|
return ret
|
||||||
|
if isinstance(default, bool):
|
||||||
|
if default:
|
||||||
|
choice = "yes"
|
||||||
|
else:
|
||||||
|
choice = "no"
|
||||||
|
while True:
|
||||||
|
ret = raw_input("%s [%s]: " % (prompt, choice))
|
||||||
|
if not ret:
|
||||||
|
return default
|
||||||
|
elif ret.lower()[0] == "y":
|
||||||
|
return True
|
||||||
|
elif ret.lower()[0] == "n":
|
||||||
|
return False
|
||||||
|
if isinstance(default, int):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
ret = raw_input("%s [%s]: " % (prompt, default))
|
||||||
|
if not ret:
|
||||||
|
return default
|
||||||
|
ret = int(ret)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def user_input_email(prompt, default = None, allow_empty = False):
|
||||||
|
if default != None and allow_empty:
|
||||||
|
prompt += " (enter \"none\" for empty)"
|
||||||
|
while True:
|
||||||
|
ret = user_input(prompt, default, allow_empty)
|
||||||
|
if allow_empty and ret.lower() == "none":
|
||||||
|
return ""
|
||||||
|
if not ipavalidate.Email(ret, not allow_empty):
|
||||||
|
return ret.strip()
|
||||||
|
|
||||||
|
def user_input_plain(prompt, default = None, allow_empty = True, allow_spaces = True):
|
||||||
|
while True:
|
||||||
|
ret = user_input(prompt, default, allow_empty)
|
||||||
|
if not ipavalidate.Plain(ret, not allow_empty, allow_spaces):
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def user_input_path(prompt, default = None, allow_empty = True):
|
||||||
|
if default != None and allow_empty:
|
||||||
|
prompt += " (enter \"none\" for empty)"
|
||||||
|
while True:
|
||||||
|
ret = user_input(prompt, default, allow_empty)
|
||||||
|
if allow_empty and ret.lower() == "none":
|
||||||
|
return ""
|
||||||
|
if not ipavalidate.Path(ret, not allow_empty):
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
class AttributeValueCompleter:
|
class AttributeValueCompleter:
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ def main():
|
|||||||
if not ipautil.file_exists("/etc/ipa/ipa.conf"):
|
if not ipautil.file_exists("/etc/ipa/ipa.conf"):
|
||||||
print "This system does not appear to have IPA configured."
|
print "This system does not appear to have IPA configured."
|
||||||
print "Has ipa-server-install been run?"
|
print "Has ipa-server-install been run?"
|
||||||
yesno = raw_input("Continue with radius install [y/N]? ")
|
if not ipautil.user_input("Continue with radius install?", False)
|
||||||
if yesno.lower() != "y":
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
installutils.standard_logging_setup("iparadius-install.log", False)
|
installutils.standard_logging_setup("iparadius-install.log", False)
|
||||||
|
|||||||
@@ -145,8 +145,7 @@ def check_dirsrv():
|
|||||||
if serverids:
|
if serverids:
|
||||||
print ""
|
print ""
|
||||||
print "An existing Directory Server has been detected."
|
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 ipautil.user_input("Do you wish to remove it and create a new one?", False)
|
||||||
if not yesno or yesno.lower()[0] != "y":
|
|
||||||
print ""
|
print ""
|
||||||
print "Only a single Directory Server instance is allowed on an IPA"
|
print "Only a single Directory Server instance is allowed on an IPA"
|
||||||
print "server, the one used by IPA itself."
|
print "server, the one used by IPA itself."
|
||||||
@@ -189,12 +188,9 @@ def main():
|
|||||||
if host != config.host_name:
|
if host != config.host_name:
|
||||||
try:
|
try:
|
||||||
print "This replica was created for '%s' but this machine is named '%s'" % (host, config.host_name)
|
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]: ")
|
if not ipautil.user_input("This may cause problems. Continue?", True)
|
||||||
print ""
|
|
||||||
if not yesno or yesno.lower()[0] == "y":
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
print ""
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
config.repl_password = ipautil.ipa_generate_password()
|
config.repl_password = ipautil.ipa_generate_password()
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import traceback
|
|||||||
|
|
||||||
import krbV, ldap, getpass
|
import krbV, ldap, getpass
|
||||||
|
|
||||||
|
from ipa.ipautil import user_input
|
||||||
from ipaserver import certs, dsinstance, httpinstance, ipaldap, installutils
|
from ipaserver import certs, dsinstance, httpinstance, ipaldap, installutils
|
||||||
|
|
||||||
def get_realm_name():
|
def get_realm_name():
|
||||||
@@ -76,25 +77,15 @@ def choose_server_cert(server_certs):
|
|||||||
print "%d. %s" % (num, cert[0])
|
print "%d. %s" % (num, cert[0])
|
||||||
num += 1
|
num += 1
|
||||||
|
|
||||||
cert_num = 0
|
|
||||||
while 1:
|
while 1:
|
||||||
cert_input = raw_input("Certificate number [1]: ")
|
num = user_input("Certificate number", 1)
|
||||||
print ""
|
print ""
|
||||||
if cert_input == "":
|
if num < 1 or num > len(server_certs):
|
||||||
break
|
print "number out of range"
|
||||||
else:
|
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
|
break
|
||||||
return server_certs[cert_num]
|
|
||||||
|
|
||||||
|
return server_certs[num - 1]
|
||||||
|
|
||||||
def import_cert(dirname, pkcs12_fname, pkcs12_passwd, db_password):
|
def import_cert(dirname, pkcs12_fname, pkcs12_passwd, db_password):
|
||||||
cdb = certs.CertDB(dirname)
|
cdb = certs.CertDB(dirname)
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ def signal_handler(signum, frame):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def read_host_name(host_default):
|
def read_host_name(host_default):
|
||||||
host_ok = False
|
|
||||||
host_name = ""
|
host_name = ""
|
||||||
|
|
||||||
print "Enter the fully qualified domain name of the computer"
|
print "Enter the fully qualified domain name of the computer"
|
||||||
@@ -131,19 +130,15 @@ def read_host_name(host_default):
|
|||||||
print ""
|
print ""
|
||||||
if host_default == "":
|
if host_default == "":
|
||||||
host_default = "master.example.com"
|
host_default = "master.example.com"
|
||||||
while not host_ok:
|
while True:
|
||||||
host_input = raw_input("Server host name [" + host_default + "]: ")
|
host_name = user_input("Server host name", host_default, allow_empty = False)
|
||||||
print ""
|
print ""
|
||||||
if host_input == "":
|
|
||||||
host_name = host_default
|
|
||||||
else:
|
|
||||||
host_name = host_input
|
|
||||||
try:
|
try:
|
||||||
verify_fqdn(host_name)
|
verify_fqdn(host_name)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
raise e
|
raise e
|
||||||
else:
|
else:
|
||||||
host_ok = True
|
break
|
||||||
return host_name
|
return host_name
|
||||||
|
|
||||||
def resolve_host(host_name):
|
def resolve_host(host_name):
|
||||||
@@ -178,10 +173,8 @@ def verify_ip_address(ip):
|
|||||||
|
|
||||||
def read_ip_address(host_name):
|
def read_ip_address(host_name):
|
||||||
while True:
|
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":
|
if ip == "127.0.0.1" or ip == "::1":
|
||||||
print "The IPA Server can't use localhost as a valid IP"
|
print "The IPA Server can't use localhost as a valid IP"
|
||||||
continue
|
continue
|
||||||
@@ -213,13 +206,12 @@ def read_ds_user():
|
|||||||
print "A user account named 'dirsrv' already exists. This is the user id"
|
print "A user account named 'dirsrv' already exists. This is the user id"
|
||||||
print "that the Directory Server will run as."
|
print "that the Directory Server will run as."
|
||||||
print ""
|
print ""
|
||||||
yesno = raw_input("Do you want to use the existing 'dirsrv' account? [yes]: ")
|
if user_input("Do you want to use the existing 'dirsrv' account?", True):
|
||||||
print ""
|
|
||||||
if not yesno or yesno.lower()[0] != "n":
|
|
||||||
ds_user = "dirsrv"
|
ds_user = "dirsrv"
|
||||||
else:
|
else:
|
||||||
ds_user = raw_input("Which account name do you want to use for the DS instance? ")
|
|
||||||
print ""
|
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:
|
except KeyError:
|
||||||
ds_user = "dirsrv"
|
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 "The domain name has been calculated based on the host name."
|
||||||
print ""
|
print ""
|
||||||
if not unattended:
|
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 ""
|
print ""
|
||||||
if dn != "":
|
|
||||||
domain_name = dn
|
|
||||||
return domain_name
|
return domain_name
|
||||||
|
|
||||||
def read_realm_name(domain_name, unattended):
|
def read_realm_name(domain_name, unattended):
|
||||||
print "The kerberos protocol requires a Realm name to be defined."
|
print "The kerberos protocol requires a Realm name to be defined."
|
||||||
print "This is typically the domain name converted to uppercase."
|
print "This is typically the domain name converted to uppercase."
|
||||||
print ""
|
print ""
|
||||||
upper_dom = domain_name.upper()
|
|
||||||
if unattended:
|
if unattended:
|
||||||
realm_name = upper_dom
|
return domain_name.upper()
|
||||||
else:
|
realm_name = user_input("Please provide a realm name", domain_name.upper())
|
||||||
realm_name = raw_input("Please provide a realm name ["+upper_dom+"]: ")
|
upper_dom = realm_name.upper()
|
||||||
print ""
|
if upper_dom != realm_name:
|
||||||
if realm_name == "":
|
print "An upper-case realm name is required."
|
||||||
realm_name = upper_dom
|
if not user_input("Do you want to use " + upper_dom + " as realm name?", True):
|
||||||
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]: ")
|
|
||||||
print ""
|
print ""
|
||||||
if dom_realm and dom_realm.lower()[0] != "y":
|
print "An upper-case realm name is required. Unable to continue."
|
||||||
print "An upper-case realm name is required. Unable to continue."
|
sys.exit(1)
|
||||||
sys.exit(1)
|
else:
|
||||||
else:
|
realm_name = upper_dom
|
||||||
realm_name = upper_dom
|
print ""
|
||||||
return realm_name
|
return realm_name
|
||||||
|
|
||||||
|
|
||||||
def read_dm_password():
|
def read_dm_password():
|
||||||
print "Certain directory server operations require an administrative user."
|
print "Certain directory server operations require an administrative user."
|
||||||
print "This user is referred to as the Directory Manager and has full access"
|
print "This user is referred to as the Directory Manager and has full access"
|
||||||
@@ -284,10 +270,7 @@ def check_dirsrv(unattended):
|
|||||||
if serverids:
|
if serverids:
|
||||||
print ""
|
print ""
|
||||||
print "An existing Directory Server has been detected."
|
print "An existing Directory Server has been detected."
|
||||||
if unattended:
|
if unattended or user_input("Do you wish to remove it and create a new one?", False):
|
||||||
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":
|
|
||||||
print ""
|
print ""
|
||||||
print "Only a single Directory Server instance is allowed on an IPA"
|
print "Only a single Directory Server instance is allowed on an IPA"
|
||||||
print "server, the one used by IPA itself."
|
print "server, the one used by IPA itself."
|
||||||
@@ -354,8 +337,7 @@ def main():
|
|||||||
if options.uninstall:
|
if options.uninstall:
|
||||||
if not options.unattended:
|
if not options.unattended:
|
||||||
print "\nThis is a NON REVERSIBLE operation and will delete all data and configuration!\n"
|
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 user_input("Are you sure you want to continue with the uninstall procedure?", False)
|
||||||
if not yesno or yesno.lower() != "yes":
|
|
||||||
print ""
|
print ""
|
||||||
print "Aborting uninstall operation."
|
print "Aborting uninstall operation."
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user