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)
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_show(inst, basedn, log, args): log = log.getChild('attruniq_show') plugins = AttributeUniquenessPlugins(inst) plugin = plugins.get(args.NAME) if not plugin.exists(): raise ldap.NO_SUCH_OBJECT("Entry %s doesn't exists" % args.name) if args and args.json: log.info(plugin.get_all_attrs_json()) else: log.info(plugin.display())
def apply(self, inst): aups = AttributeUniquenessPlugins(inst) try: aup = aups.create(properties={ 'cn': f'cn=attr_unique_{self.attr}_{self.uuid}', 'uniqueness-attribute-name': self.attr, 'uniqueness-subtrees': self.suffix, 'nsslapd-pluginEnabled': 'on', }) except ldap.ALREADY_EXISTS: # This is okay, move on. pass
def attruniq_list(inst, basedn, log, args): log = log.getChild('attruniq_list') plugins = AttributeUniquenessPlugins(inst) result = [] result_json = [] for plugin in plugins.list(): if args.json: result_json.append(json.loads(plugin.get_all_attrs_json())) else: result.append(plugin.rdn) if args.json: log.info(json.dumps({"type": "list", "items": result_json}, indent=4)) else: if len(result) > 0: for i in result: log.info(i) else: log.info("No Attribute Uniqueness plugin instances")
def attruniq_del(inst, basedn, log, args): log = log.getChild('attruniq_del') plugins = AttributeUniquenessPlugins(inst) plugin = plugins.get(args.NAME) plugin.delete() log.info("Successfully deleted the %s", plugin.dn)
def attruniq_edit(inst, basedn, log, args): log = log.getChild('attruniq_edit') plugins = AttributeUniquenessPlugins(inst) plugin = plugins.get(args.NAME) generic_object_edit(plugin, log, args, arg_to_attr)