Import Upstream version 4.12.4
This commit is contained in:
@@ -30,9 +30,10 @@ from ipaplatform.paths import paths
|
||||
from ipaserver.install import (replication, installutils, bindinstance,
|
||||
cainstance)
|
||||
from ipalib import api, errors
|
||||
from ipalib.util import has_managed_topology
|
||||
from ipapython import ipautil, ipaldap, version
|
||||
from ipapython.admintool import ScriptError
|
||||
from ipalib.constants import FQDN
|
||||
from ipalib.util import has_managed_topology, print_replication_status
|
||||
from ipapython import ipautil, ipaldap, version, config
|
||||
from ipapython.admintool import admin_cleanup_global_argv, ScriptError
|
||||
from ipapython.dn import DN
|
||||
|
||||
logger = logging.getLogger(os.path.basename(__file__))
|
||||
@@ -53,11 +54,10 @@ commands = {
|
||||
|
||||
|
||||
def parse_options():
|
||||
from optparse import OptionParser # pylint: disable=deprecated-module
|
||||
|
||||
parser = OptionParser(version=version.VERSION)
|
||||
parser = config.IPAOptionParser(version=version.VERSION)
|
||||
parser.add_option("-H", "--host", dest="host", help="starting host")
|
||||
parser.add_option("-p", "--password", dest="dirman_passwd", help="Directory Manager password")
|
||||
parser.add_option("-p", "--password", dest="dirman_passwd", sensitive=True,
|
||||
help="Directory Manager password")
|
||||
parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False,
|
||||
help="provide additional information")
|
||||
parser.add_option("-f", "--force", dest="force", action="store_true", default=False,
|
||||
@@ -65,23 +65,27 @@ def parse_options():
|
||||
parser.add_option("--from", dest="fromhost", help="Host to get data from")
|
||||
|
||||
options, args = parser.parse_args()
|
||||
admin_cleanup_global_argv(parser, options, sys.argv)
|
||||
|
||||
valid_syntax = False
|
||||
|
||||
if len(args):
|
||||
n = len(args) - 1
|
||||
for cmd in commands:
|
||||
for cmd, args_info in commands.items():
|
||||
if cmd == args[0]:
|
||||
v = commands[cmd]
|
||||
err = None
|
||||
if n < v[0]:
|
||||
err = v[3]
|
||||
elif n > v[1]:
|
||||
if n < args_info[0]:
|
||||
err = args_info[3]
|
||||
elif n > args_info[1]:
|
||||
err = "too many arguments"
|
||||
else:
|
||||
valid_syntax = True
|
||||
if err:
|
||||
parser.error("Invalid syntax: %s\nUsage: %s [options] %s" % (err, cmd, v[2]))
|
||||
parser.error(
|
||||
"Invalid syntax: %s\nUsage: %s [options] %s" % (
|
||||
err, cmd, args_info[2]
|
||||
)
|
||||
)
|
||||
|
||||
if not valid_syntax:
|
||||
cmdstr = " | ".join(commands.keys())
|
||||
@@ -132,19 +136,7 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose):
|
||||
|
||||
for entry in entries:
|
||||
print('%s' % entry.single_value.get('nsds5replicahost'))
|
||||
|
||||
if verbose:
|
||||
initstatus = entry.single_value.get('nsds5replicalastinitstatus')
|
||||
if initstatus is not None:
|
||||
print(" last init status: %s" % initstatus)
|
||||
print(" last init ended: %s" % str(
|
||||
ipautil.parse_generalized_time(
|
||||
entry.single_value['nsds5replicalastinitend'])))
|
||||
print(" last update status: %s" % entry.single_value.get(
|
||||
'nsds5replicalastupdatestatus'))
|
||||
print(" last update ended: %s" % str(
|
||||
ipautil.parse_generalized_time(
|
||||
entry.single_value['nsds5replicalastupdateend'])))
|
||||
print_replication_status(entry, verbose)
|
||||
|
||||
|
||||
def del_link(realm, replica1, replica2, dirman_passwd, force=False):
|
||||
@@ -343,7 +335,7 @@ def re_initialize(realm, options):
|
||||
if not options.fromhost:
|
||||
sys.exit("re-initialize requires the option --from <host name>")
|
||||
|
||||
thishost = installutils.get_fqdn()
|
||||
thishost = FQDN
|
||||
|
||||
try:
|
||||
repl = replication.get_cs_replication_manager(realm, options.fromhost,
|
||||
@@ -383,7 +375,7 @@ def force_sync(realm, thishost, fromhost, dirman_passwd):
|
||||
|
||||
def set_renewal_master(realm, replica):
|
||||
if not replica:
|
||||
replica = installutils.get_fqdn()
|
||||
replica = FQDN
|
||||
|
||||
ca = cainstance.CAInstance(realm)
|
||||
if ca.is_renewal_master(replica):
|
||||
@@ -434,7 +426,7 @@ def main():
|
||||
if options.host:
|
||||
host = options.host
|
||||
else:
|
||||
host = installutils.get_fqdn()
|
||||
host = FQDN
|
||||
|
||||
options.host = host
|
||||
|
||||
|
||||
Reference in New Issue
Block a user