<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <br>
    <div class="moz-cite-prefix">On 05/06/2015 02:47 PM, Ludwig Krispenz
      wrote:<br>
    </div>
    <blockquote cite="mid:554A0D63.50409@redhat.com" type="cite">
      <meta http-equiv="content-type" content="text/html;
        charset=windows-1252">
      <meta http-equiv="CONTENT-TYPE" content="text/html;
        charset=windows-1252">
      <p style="margin-bottom: 0in">Hi,<br>
        in recent posts about corrupted ruvs, there also was the error
        about failing cleanup, like:<br>
      </p>
      <p style="margin-bottom: 0in">ipa-replica-manage del
        vm-162.idm.lab.eng.brq.redhat.com</p>
      ..<br>
      Failed to cleanup vm-162.idm.lab.eng.brq.redhat.com entries: Not
      allowed on non-leaf entry<br>
      <br>
      in the access log we see<br>
      <p style="margin-bottom: 0in">[06/May/2015:14:19:11 +0200]conn=30
        op=17 SRCH
        base="cn=vm-162.idm.lab.eng.brq.redhat.com,cn=masters,cn=ipa,cn=etc,dc=idm,dc=lab,dc=eng,dc=brq,dc=redhat,dc=com"
scope=2

        filter="(objectClass=*)" attrs=ALL </p>
      [06/May/2015:14:19:11 +0200] conn=30 op=17 RESULT err=0 tag=101
      nentries=6 etime=0 notes=U<br>
      [06/May/2015:14:19:11 +0200] conn=30 op=18 DEL
dn="cn=vm-162.idm.lab.eng.brq.redhat.com,cn=masters,cn=ipa,cn=etc,dc=idm,dc=lab,dc=eng,dc=brq,dc=redhat,dc=com"<br>
      [06/May/2015:14:19:11 +0200] conn=30 op=18 RESULT err=66 tag=107
      nentries=0 etime=0<br>
      <br>
      which means that there was an attempt to remove the host before
      the services<br>
      <br>
      <p style="margin-bottom: 0in">in replica_cleanup we have:</p>
      <p style="margin-bottom: 0in"> <tt># delete master entry with all
          active services </tt></p>
      <tt>try:</tt><tt><br>
            dn = DN(('cn', replica), ('cn', 'masters'), ('cn', 'ipa'),</tt><tt>('cn',
        'etc'), self.suffix)</tt><tt><br>
            entries = self.conn.get_entries(dn, ldap.SCOPE_SUBTREE)</tt><tt><br>
            if entries:</tt><tt><br>
                entries.sort(key=len, reverse=True)</tt><tt><br>
                for entry in entries:</tt><tt><br>
                    self.conn.delete_entry(entry)</tt>
      <p style="margin-bottom: 0in">this intends to delete children
        befor the parent, as teh dns of children are longer, but
        get_entries does return a list of entries, not DNs, and so the
        sorting does not work as can be seen in this example:</p>
      <p style="margin-bottom: 0in"><tt>>>> list =
          [('123456','A'),('123','B'),('12345678','C')] </tt></p>
      <tt> </tt>
      <p style="margin-bottom: 0in"><tt>>>>
          list.sort(key=len,reverse=True) </tt></p>
      <tt> </tt>
      <p style="margin-bottom: 0in"><tt>>>> for l in list: </tt></p>
      <tt> </tt>
      <p style="margin-bottom: 0in"><tt>...     print l </tt></p>
      <tt> </tt>
      <p style="margin-bottom: 0in"><tt>... </tt></p>
      <tt> </tt>
      <p style="margin-bottom: 0in"><tt>('123456', 'A') </tt></p>
      <tt> </tt>
      <p style="margin-bottom: 0in"><tt>('123', 'B') </tt></p>
      <tt> </tt>
      <p style="margin-bottom: 0in"><tt>('12345678', 'C')</tt></p>
      <title></title>
      <meta name="GENERATOR" content="LibreOffice 3.5 (Linux)">
      <style type="text/css">
        <!--
                @page { margin: 0.79in }
                P { margin-bottom: 0.08in }
        -->
        </style> <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
    </blockquote>
    <br>
    A quick fix would be to use key=lambda x: len(x.dn) then.<br>
    <br>
    Tomas<br>
    <br>
    <br>
  </body>
</html>