1
0
Эх сурвалжийг харах

Ticket 49997 RFE: ds-replcheck could validate suffix exists and it's replicated

Bug Description:

seen at customer site, as first request to ldap database is the RUV, if the suffix provided in the command line does not exist or it's not replicated, we have an error message that it's regarding the RUV:

ds-replcheck -D "cn=directory manager" -w secret12 -b "o=ipaca" -r ldap://ipamaster.germanparente.local:389 -m ldap://ipareplica.germanparente.local
Performing online report...
Connecting to servers...
Gathering Master's RUV...
Error: Failed to get Master RUV entry: {'desc': 'No such object'}

Fix Description:

add function to validate suffix exists and it's replicated

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

Author: German Parente <[email protected]>

Review by: ???
German Parente 7 жил өмнө
parent
commit
64ef80816b

+ 32 - 0
ldap/admin/src/scripts/ds-replcheck

@@ -809,6 +809,30 @@ def check_for_diffs(mentries, mglue, rentries, rglue, report, opts):
 
 
     return report
     return report
 
 
+def validate_suffix(ldapnode, suffix, hostname):
+   # Validate suffix exists
+   try:
+      master_basesuffix = ldapnode.search_s(suffix, ldap.SCOPE_BASE )
+   except ldap.NO_SUCH_OBJECT:
+      print("Error: Failed to validate suffix in {}. {} does not exist.".format(hostname, suffix))
+      return False
+   except ldap.LDAPError as e:
+      print("Error: failed to validate suffix in {} ({}). ".format(hostname, str(e)))
+      return False
+
+   # Check suffix is replicated
+   try:
+      replica_filter = "(&(objectclass=nsds5replica)(nsDS5ReplicaRoot=%s))" % suffix
+      master_replica = ldapnode.search_s("cn=config",ldap.SCOPE_SUBTREE,replica_filter)
+      if (len(master_replica) != 1):
+        print("Error: Failed to validate suffix in {}. {} is not replicated.".format(hostname, suffix))
+        return False
+   except ldap.LDAPError as e:
+      print("Error: failed to validate suffix in {} ({}). ".format(hostname, str(e)))
+      return False
+
+   return True
+
 
 
 def connect_to_replicas(opts):
 def connect_to_replicas(opts):
     ''' Start the paged results searches
     ''' Start the paged results searches
@@ -881,6 +905,14 @@ def connect_to_replicas(opts):
               "Please check your credentials and LDAP urls are correct.".format(str(e)))
               "Please check your credentials and LDAP urls are correct.".format(str(e)))
         exit(1)
         exit(1)
 
 
+    # Validate suffix
+    print ("Validating suffix ...")
+    if not validate_suffix(master, opts['suffix'], opts['mhost']):
+      exit(1)
+
+    if not validate_suffix(replica,opts['suffix'], opts['rhost']):
+      exit(1)
+
     # Get the RUVs
     # Get the RUVs
     print ("Gathering Master's RUV...")
     print ("Gathering Master's RUV...")
     try:
     try: