#50121 Ticket 49984 - python installer add option to create suffix entry
Closed 3 years ago by spichugi. Opened 5 years ago by mreynolds.
mreynolds/389-ds-base ticket49984  into  master

@@ -284,12 +284,17 @@ 

          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 @@ 

  

          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

@@ -157,14 +157,13 @@ 

              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 @@ 

                  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 @@ 

                  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 @@ 

          # 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', [

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

Currently, it doesn't reach the point because backends is an empty list (because suffix is '' in _validate_ds_2_config).

I think we should set the default suffix to 'dc=example,dc=com' if it is not set in INF file (as it should be according to the docs in INF file)

Also, should we also add the option to UI?

Currently, it doesn't reach the point because backends is an empty list (because suffix is '' in _validate_ds_2_config).

Sorry I don't understand your concern. That code is definitely reached when I run dscreate.

I think we should set the default suffix to 'dc=example,dc=com' if it is not set in INF file (as it should be according to the docs in INF file)

But suffix is a required property IIRC, so there's no need for a default suffix, right?

So there is the INF which fails to create the root entry

[backend-userroot]
# create_suffix_entry (bool)
# Description: Set this parameter to "True" to create a generic root node entry for the suffix in the database.
# Default value: False
create_suffix_entry = True

# require_index (bool)
# Description: Set this parameter to "True" to refuse unindexed searches in this database.
# Default value: False
;require_index = False

# sample_entries (str)
# Description: Set this parameter to 'yes' to add latest version of sample entries to this database.  Or, use '001003006' to use the 1.3.6 version sample entries.  Use this option, for example, to create a database for testing purposes.
# Default value: no
;sample_entries = no

# suffix (str)
# Description: Sets the root suffix stored in this database.  If you do not uncomment the suffix attribute the install process will NOT create the backend/suffix.  You can also create multiple backends/suffixes by duplicating this section.
# Default value: dc=example,dc=com
;suffix = dc=example,dc=com

Then we parse the INF file suffix part here - https://pagure.io/389-ds-base/blob/master/f/src/lib389/lib389/instance/setup.py#_160

And it sets suffix to '' instead of dc=example,dc=com
So we never reach this point - https://pagure.io/389-ds-base/blob/master/f/src/lib389/lib389/instance/setup.py#_185

Which results in an empty backends list here - https://pagure.io/389-ds-base/blob/master/f/src/lib389/lib389/instance/setup.py#_841

Suffix is always required to create a backend though, because it's needed to establish the mapping tree options. I think that a missing suffix should fail in _validate_ds_2_config, which from your report, it sounds like it's correctly doing :)

Suffix is always required to create a backend though, because it's needed to establish the mapping tree options. I think that a missing suffix should fail in _validate_ds_2_config, which from your report, it sounds like it's correctly doing :)

My point is that we have this section:

# suffix (str)
# Description: Sets the root suffix stored in this database.  If you do not uncomment the suffix attribute the install process will NOT create the backend/suffix.  You can also create multiple backends/suffixes by duplicating this section.
# Default value: dc=example,dc=com
;suffix = dc=example,dc=com

Which states that the Default value is dc=example,dc=com. Shouldn't we set it in the code if [backend-NAME] is specified but suffix is not?

rebased onto 0168d077fac7fcb623b12bfd1cc6f8e4f6c07d1c

5 years ago

Hey guys, so... The way we setup backends via the INF file is unique compared to the other settings/sections.

If you do not specify a suffix then the backend is not created. This is by design because the backend section is already present, so the only way to to say create the backend is to set the suffix. It is not a problem to leave the suffix commented as nothing will happen.

What I did do was remove the default suffix value from the INF file and I improved the description, so hopefully it will be less confusing.

I created https://pagure.io/freeipa/issue/7830 to track the issue. As temporary workaround I'm going to pin 389-ds version to 1.4.0.16

rebased onto a8fa9a9

5 years ago

Pull-Request has been merged by mreynolds

5 years ago

@mreynolds Do you have plans to release 1.4.0.21 with this fix on F28 and F29? IPA master is currently stuck on 1.4.0.16.

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/3180

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