ipa-nis-manage: add status option

https://fedorahosted.org/freeipa/ticket/5856

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Reviewed-By: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Petr Spacek 2016-04-25 16:56:08 +02:00 committed by Martin Basti
parent 65794fc71c
commit 9079d2f9c8
2 changed files with 24 additions and 6 deletions

View File

@ -47,7 +47,7 @@ nis_config_dn = DN(('cn', 'NIS Server'), ('cn', 'plugins'), ('cn', 'config'))
compat_dn = DN(('cn', 'Schema Compatibility'), ('cn', 'plugins'), ('cn', 'config'))
def parse_options():
usage = "%prog [options] <enable|disable>\n"
usage = "%prog [options] <enable|disable|status>\n"
usage += "%prog [options]\n"
parser = OptionParser(usage=usage, formatter=config.IPAFormatter())
@ -96,8 +96,8 @@ def main():
options, args = parse_options()
if len(args) != 1:
sys.exit("You must specify one action, either enable or disable")
elif args[0] != "enable" and args[0] != "disable":
sys.exit("You must specify one action: enable | disable | status")
elif args[0] not in {"enable", "disable", "status"}:
sys.exit("Unrecognized action [" + args[0] + "]")
standard_logging_setup(None, debug=options.debug)
@ -186,11 +186,25 @@ def main():
print(lde)
retval = 1
elif args[0] == "status":
nis_entry = get_entry(nis_config_dn, conn)
enabled = (nis_entry and
nis_entry.get(
'nsslapd-pluginenabled', '')[0].lower() == "on")
if enabled:
print("Plugin is enabled")
retval = 0
else:
print("Plugin is not enabled")
retval = 4
else:
retval = 1
if retval == 0:
print("This setting will not take effect until you restart Directory Server.")
if args[0] in {"enable", "disable"}:
print("This setting will not take effect until you restart "
"Directory Server.")
if args[0] == "enable":
print("The %s service may need to be started." % servicemsg)

View File

@ -20,13 +20,15 @@
.SH "NAME"
ipa\-nis\-manage \- Enables or disables the NIS listener plugin
.SH "SYNOPSIS"
ipa\-nis\-manage [options] <enable|disable>
ipa\-nis\-manage [options] <enable|disable|status>
.SH "DESCRIPTION"
Run the command with the \fBenable\fR option to enable the NIS plugin.
Run the command with the \fBdisable\fR option to disable the NIS plugin.
In both cases the user will be prompted to provide the Directory Manager's password unless option \fB\-y\fR is used.
Run the command with the \fBstatus\fR option to read status of the NIS plugin. Return code 0 indicates enabled plugin, return code 4 indicates disabled plugin.
In all cases the user will be prompted to provide the Directory Manager's password unless option \fB\-y\fR is used.
Directory Server will need to be restarted after the NIS listener plugin has been enabled.
@ -45,3 +47,5 @@ File containing the Directory Manager password
2 if the plugin is already in the required status (enabled or disabled)
3 if RPC services cannot be enabled.
4 if status command detected plugin in disabled state.