From a8fa9a992fb114f4f36562c6391113da1979eb31 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Jan 14 2019 15:10:20 +0000 Subject: Ticket 49984 - python installer add option to create suffix entry Description: Making the top suffix entry should be optional, and not the fixed default behavior. Added a new option: create_suffix_entry True/False https://pagure.io/389-ds-base/issue/49984 Reviewed by: ? --- diff --git a/src/lib389/lib389/instance/options.py b/src/lib389/lib389/instance/options.py index a32ec8a..a1be9b6 100644 --- a/src/lib389/lib389/instance/options.py +++ b/src/lib389/lib389/instance/options.py @@ -284,12 +284,17 @@ class Backend2Base(Options2): super(Backend2Base, self).__init__(log) self._section = section - self._options['suffix'] = 'dc=example,dc=com' + self._options['suffix'] = '' self._type['suffix'] = str - self._helptext['suffix'] = ("Sets the root suffix stored in this database. If you do not uncomment the suffix " + + self._helptext['suffix'] = ("Sets the root suffix stored in this database. If you do not uncomment and set the suffix " + "attribute the install process will NOT create the backend/suffix. You can also " + "create multiple backends/suffixes by duplicating this section.") + self._options['create_suffix_entry'] = False + self._type['create_suffix_entry'] = bool + self._helptext['create_suffix_entry'] = ("Set this parameter to \"True\" to create a generic root node " + + "entry for the suffix in the database.") + self._options['sample_entries'] = "no" self._type['sample_entries'] = str self._helptext['sample_entries'] = ("Set this parameter to 'yes' to add latest version of sample " + @@ -299,6 +304,6 @@ class Backend2Base(Options2): self._options['require_index'] = False self._type['require_index'] = bool - self._helptext['require_index'] = "Sets this parameter to \"True\" to refuse unindexed searches in this database." + self._helptext['require_index'] = "Set this parameter to \"True\" to refuse unindexed searches in this database." # TODO - Add other backend settings diff --git a/src/lib389/lib389/instance/setup.py b/src/lib389/lib389/instance/setup.py index 97a3abc..c01eb77 100644 --- a/src/lib389/lib389/instance/setup.py +++ b/src/lib389/lib389/instance/setup.py @@ -157,14 +157,13 @@ class SetupDs(object): if section.startswith('backend-'): backend_options = Backend2Base(self.log, section) backend_options.parse_inf_config(config) - suffix = config.get(section, 'suffix', fallback='') if suffix != '': - be = {} - # Suffix + be = {} be[BACKEND_NAME] = section.replace('backend-', '') - be[BACKEND_SUFFIX] = config.get(section, 'suffix') + be[BACKEND_SUFFIX] = suffix + be['create_suffix_entry'] = config.get(section, 'create_suffix_entry', fallback=False) # Sample entries sample_entries = config.get(section, 'sample_entries', fallback='no') @@ -437,10 +436,10 @@ class SetupDs(object): backend['suffix'] = suffix break - # Add sample entries? + # Add sample entries or root suffix entry? if len(backends) > 0: while 1: - val = input("\nCreate sample entries in the suffix [no]: ".format(suffix)).rstrip().lower() + val = input("\nCreate sample entries in the suffix [no]: ").rstrip().lower() if val != "": if val == "no" or val == "n": break @@ -454,6 +453,23 @@ class SetupDs(object): else: break + if 'sample_entries' not in backend: + # Check if they want to create the root node entry instead + while 1: + val = input("\nCreate just the top suffix entry [no]: ").rstrip().lower() + if val != "": + if val == "no" or val == "n": + break + if val == "yes" or val == "y": + backend['create_suffix_entry'] = True + break + + # Unknown value + print ("Value \"{}\" is invalid, please use \"yes\" or \"no\"".format(val)) + continue + else: + break + # Are you ready? while 1: val = input('\nAre you ready to install? [no]: ').rstrip().lower() @@ -841,8 +857,9 @@ class SetupDs(object): # Load example data if needed. for backend in backends: is_sample_entries_in_props = "sample_entries" in backend + create_suffix_entry_in_props = backend.pop('create_suffix_entry', False) ds_instance.backends.create(properties=backend) - if not is_sample_entries_in_props: + if not is_sample_entries_in_props and create_suffix_entry_in_props: domain = create_base_domain(ds_instance, backend['nsslapd-suffix']) # Set basic ACI domain.add('aci', [