|
Lines 693-698
Link Here
|
| 693 |
|
693 |
|
| 694 |
|
694 |
|
| 695 |
def _remove_file(pathname): |
695 |
def _remove_file(pathname): |
|
|
696 |
ud.debug(ud.LISTENER, ud.ALL, 'replication: removing %s' % (pathname,)) |
| 696 |
try: |
697 |
try: |
| 697 |
os.remove(pathname) |
698 |
os.remove(pathname) |
| 698 |
except EnvironmentError as ex: |
699 |
except EnvironmentError as ex: |
|
Lines 827-833
Link Here
|
| 827 |
|
828 |
|
| 828 |
# add |
829 |
# add |
| 829 |
if new: |
830 |
if new: |
| 830 |
if os.path.exists(CURRENT_MODRDN): |
831 |
if os.path.exists(CURRENT_MODRDN) and not isinstance(l, LDIFObject): |
| 831 |
target_uuid_file = os.readlink(CURRENT_MODRDN) |
832 |
target_uuid_file = os.readlink(CURRENT_MODRDN) |
| 832 |
old_dn = _read_dn_from_file(CURRENT_MODRDN) |
833 |
old_dn = _read_dn_from_file(CURRENT_MODRDN) |
| 833 |
|
834 |
|
|
Lines 847-858
Link Here
|
| 847 |
new_dn = ldap.dn.str2dn(dn) |
848 |
new_dn = ldap.dn.str2dn(dn) |
| 848 |
new_parent = ldap.dn.dn2str(new_dn[1:]) |
849 |
new_parent = ldap.dn.dn2str(new_dn[1:]) |
| 849 |
new_rdn = ldap.dn.dn2str([new_dn[0]]) |
850 |
new_rdn = ldap.dn.dn2str([new_dn[0]]) |
|
|
851 |
|
| 852 |
delold = 0 |
| 853 |
for old_rdn in ldap.dn.str2dn(old_dn)[0]: |
| 854 |
if not old_rdn[0] in new: |
| 855 |
ud.debug(ud.LISTENER, ud.ALL, 'replication: new: attr %s not present' % (old_rdn[0],)) |
| 856 |
delold = 1 |
| 857 |
continue |
| 858 |
elif not old_rdn[1] in new[old_rdn[0]]: |
| 859 |
ud.debug(ud.LISTENER, ud.ALL, 'replication: new: val %s not present in attr %s' % (old_rdn[1], old_rdn[0])) |
| 860 |
delold = 1 |
| 861 |
continue |
| 862 |
|
| 850 |
ud.debug(ud.LISTENER, ud.PROCESS, 'replication: rename from %s to %s' % (old_dn, dn)) |
863 |
ud.debug(ud.LISTENER, ud.PROCESS, 'replication: rename from %s to %s' % (old_dn, dn)) |
| 851 |
l.rename_s(old_dn, new_rdn, new_parent, delold=1) |
864 |
l.rename_s(old_dn, new_rdn, new_parent, delold=delold) |
| 852 |
_remove_file(modrdn_cache) |
865 |
_remove_file(modrdn_cache) |
| 853 |
if not isinstance(l, LDIFObject): |
|
|
| 854 |
old = getOldValues(l, dn) |
| 855 |
_modify_object_from_old_and_new(l, dn, old, new) |
| 856 |
else: |
866 |
else: |
| 857 |
# the old object does not exists, so we have to re-create the new object |
867 |
# the old object does not exists, so we have to re-create the new object |
| 858 |
ud.debug(ud.LISTENER, ud.ALL, 'replication: the local target does not exist, so the object will be added: %s' % dn) |
868 |
ud.debug(ud.LISTENER, ud.ALL, 'replication: the local target does not exist, so the object will be added: %s' % dn) |
|
Lines 927-932
Link Here
|
| 927 |
reconnect = 1 |
937 |
reconnect = 1 |
| 928 |
connect(ldif=1) |
938 |
connect(ldif=1) |
| 929 |
handler(dn, new, listener_old, operation) |
939 |
handler(dn, new, listener_old, operation) |
|
|
940 |
if os.path.exists(LDIF_FILE): |
| 941 |
with open(LDIF_FILE, 'r') as fd: |
| 942 |
ud.debug(ud.LISTENER, ud.ERROR, 'ldif:\n%s' % fd.read()) |
| 930 |
|
943 |
|
| 931 |
|
944 |
|
| 932 |
def log_ldap(severity, msg, ex, dn=None): |
945 |
def log_ldap(severity, msg, ex, dn=None): |