On 20.5.2016 15:03, Martin Babinsky wrote: > On 04/28/2016 05:15 PM, Petr Spacek wrote: >> On 28.4.2016 14:52, Abhijeet Kasurde wrote: >>> Hi Petr, >>> >>> On 04/25/2016 08:28 PM, Petr Spacek wrote: >>>> Hello, >>>> >>>> ipa-nis-manage: add status option >>>> >>>> https://bugzilla.redhat.com/show_bug.cgi?id=1329275 >>>> >>>> >>>> >>> Can you reword the error message here as well ? >>> >>> if len(args) != 1: >>> sys.exit("You must specify one action, either enable or disable") >>> >>> Thanks, >>> Abhijeet Kasurde >> >> Good catch! >> >> >> > > Hi Petr, > > please use upstream ticket provided by Petr Vobornik[1] in the commit message. > > Also I would rewrite > > """+ elif args[0] != "enable" and args[0] != "disable" and args[0] != > "status": > > """ > > in a more pythonic way: > > " elif args[0] not in {"enable", "disable", "status"}:" > > Otherwise the patch works as expected. > > [1] https://fedorahosted.org/freeipa/ticket/5856
Here you go. -- Petr^2 Spacek
From e966d141724127720e3b036027f91e8438e88f45 Mon Sep 17 00:00:00 2001 From: Petr Spacek <pspa...@redhat.com> Date: Mon, 25 Apr 2016 16:56:08 +0200 Subject: [PATCH] ipa-nis-manage: add status option https://fedorahosted.org/freeipa/ticket/5856 --- install/tools/ipa-nis-manage | 22 ++++++++++++++++++---- install/tools/man/ipa-nis-manage.1 | 8 ++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/install/tools/ipa-nis-manage b/install/tools/ipa-nis-manage index 948aa0046b6eeb0f68dd90390eaca6d5b6c8dba3..f70961309c34e48ea1b4c1b144c9c0df5860f667 100755 --- a/install/tools/ipa-nis-manage +++ b/install/tools/ipa-nis-manage @@ -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) diff --git a/install/tools/man/ipa-nis-manage.1 b/install/tools/man/ipa-nis-manage.1 index d60fda788fb7b97d6fa97544f63f346eb13e956a..93278487c1adb50f4ae49804d0214841e2bef30c 100644 --- a/install/tools/man/ipa-nis-manage.1 +++ b/install/tools/man/ipa-nis-manage.1 @@ -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. -- 2.5.5
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code