#50845 Ticket 50787 - fix implementation of attr unique
Closed 3 years ago by spichugi. Opened 4 years ago by firstyear.
firstyear/389-ds-base 50787-plugin-cls-on-enable  into  master

@@ -78,6 +78,38 @@ 

      log.info("Successfully deleted the %s", plugin.dn)

  

  

+ def attruniq_enable(inst, basedn, log, args):

+     log = log.getChild('attruniq_enable')

+     plugins = AttributeUniquenessPlugins(inst)

+     plugin = plugins.get(args.NAME)

+     if plugin.status():

+         log.info("Plugin '%s' already enabled" % plugin.rdn)

+     else:

+         plugin.enable()

+         log.info("Successfully enabled the %s", plugin.dn)

+ 

+ 

+ def attruniq_disable(inst, basedn, log, args):

+     log = log.getChild('attruniq_disable')

+     plugins = AttributeUniquenessPlugins(inst)

+     plugin = plugins.get(args.NAME)

+     if not plugin.status():

+         log.info("Plugin '%s' already disabled" % plugin.rdn)

+     else:

+         plugin.disable()

+         log.info("Successfully disabled the %s", plugin.dn)

The one logging line uses DN while the one higher up uses RDN. Same for the first function. Should be consistent, right?

+ 

+ 

+ def attruniq_status(inst, basedn, log, args):

+     log = log.getChild('attruniq_status')

+     plugins = AttributeUniquenessPlugins(inst)

+     plugin = plugins.get(args.NAME)

+     if plugin.status() is True:

+         log.info("Plugin '%s' is enabled" % plugin.rdn)

+     else:

+         log.info("Plugin '%s' is disabled" % plugin.rdn)

+ 

+ 

@firstyear, just a dummy question instead of specifying the plugin RDN (e.g. uid-test) would it be possible to specify the attributename that is specified in the plugin entry ?

  def _add_parser_args(parser):

      parser.add_argument('NAME', help='Sets the name of the plug-in configuration record. (cn) You can use any string, '

                                       'but "attribute_name Attribute Uniqueness" is recommended.')
@@ -104,7 +136,7 @@ 

  def create_parser(subparsers):

      attruniq = subparsers.add_parser('attr-uniq', help='Manage and configure Attribute Uniqueness plugin')

      subcommands = attruniq.add_subparsers(help='action')

-     add_generic_plugin_parsers(subcommands, AttributeUniquenessPlugin)

+     # We can't use the add_generic_plugin_parsers as we need named sub instances.

  

      list = subcommands.add_parser('list', help='List available plugin configs')

      list.set_defaults(func=attruniq_list)
@@ -127,12 +159,12 @@ 

  

      enable = subcommands.add_parser('enable', help='enable plugin')

      enable.add_argument('NAME', help='Sets the name of the plug-in configuration record')

-     enable.set_defaults(func=generic_enable)

+     enable.set_defaults(func=attruniq_enable)

  

      disable = subcommands.add_parser('disable', help='disable plugin')

      disable.add_argument('NAME', help='Sets the name of the plug-in configuration record')

-     disable.set_defaults(func=generic_disable)

+     disable.set_defaults(func=attruniq_disable)

  

      status = subcommands.add_parser('status', help='display plugin status')

      status.add_argument('NAME', help='Sets the name of the plug-in configuration record')

-     status.set_defaults(func=generic_status)

+     status.set_defaults(func=attruniq_status)

Bug Description: The implementation of attribute unique relies
on a "plugin per config" which is different to most other
handlings. This creates an exception case to the standard
plugin framework in lib389 that was not correctly handled
in the CLI.

Fix Description: Fix the cli to have the correct customised
variants of the commands to support this plugin's behaviour.

dsconf localhost plugin attr-uniq status uid-test
Plugin 'uid-test' is disabled
dsconf localhost plugin attr-uniq enable uid-test
Successfully enabled the cn=uid-test,cn=plugins,cn=config
dsconf localhost plugin attr-uniq enable uid-test
Plugin 'uid-test' already enabled
dsconf localhost plugin attr-uniq status uid-test
Plugin 'uid-test' is enabled
dsconf localhost plugin attr-uniq disable uid-test
Successfully disabled the cn=uid-test,cn=plugins,cn=config
dsconf localhost plugin attr-uniq disable uid-test
Plugin 'uid-test' already disabled

https://pagure.io/389-ds-base/issue/50787

Author: William Brown william@blackhats.net.au

Review by: ???

@firstyear, just a dummy question instead of specifying the plugin RDN (e.g. uid-test) would it be possible to specify the attributename that is specified in the plugin entry ?

The one logging line uses DN while the one higher up uses RDN. Same for the first function. Should be consistent, right?

@mreynolds It's inconsistent in the generic_* versions, so we are "consistently inconsistent". I think to fix these "naming" outputs in beyond scope here,

@tbordaz No, because you can have multiple plugins doing uid uniq on the same attr via attribute set management, so you have to use the cn ....

rebased onto 493a664

4 years ago

Pull-Request has been merged by firstyear

4 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/3899

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago
Metadata