forked from richm/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bug359261.py
108 lines (91 loc) · 2.45 KB
/
bug359261.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
from bug_harness import DSAdminHarness as DSAdmin
from dsadmin import Entry
import os
import sys
import time
import ldap
host1 = "localhost.localdomain"
host2 = host1
cfgport = 389
port1 = cfgport+30
port2 = cfgport+40
#os.environ['USE_DBX'] = "1"
m1replargs = {
'suffix': "dc=example,dc=com",
'bename': "userRoot",
'binddn': "cn=replrepl,cn=config",
'bindcn': "replrepl",
'bindpw': "replrepl"
}
m1 = DSAdmin.createAndSetupReplica({
'cfgdshost': host1,
'cfgdsport': cfgport,
'cfgdsuser': 'admin',
'cfgdspwd': 'admin',
'newrootpw': 'password',
'newhost': host1,
'newport': port1,
'newinst': 'm1',
'newsuffix': 'dc=example,dc=com',
'verbose': True,
'have_admin': True
}, m1replargs)
#del os.environ['USE_DBX']
#os.environ['USE_DBX'] = 1
m2replargs = {
'suffix': "dc=example,dc=com",
'bename': "userRoot",
'binddn': "cn=replrepl,cn=config",
'bindcn': "replrepl",
'bindpw': "replrepl"
}
#os.environ['USE_DBX'] = "1"
m2 = DSAdmin.createAndSetupReplica({
'cfgdshost': host2,
'cfgdsport': cfgport,
'cfgdsuser': 'admin',
'cfgdspwd': 'admin',
'newrootpw': 'password',
'newhost': host2,
'newport': port2,
'newinst': 'm2',
'newsuffix': 'dc=example,dc=com',
'verbose': True,
'have_admin': True
}, m2replargs)
#del os.environ['USE_DBX']
initfile = ''
if os.environ.has_key('SERVER_ROOT'):
initfile = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot,m1.inst)
else:
initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get('PREFIX', '/usr')
m1.importLDIF(initfile, '', "userRoot", True)
print "create agreements and init consumers . . ."
agmtm1tom2 = m1.setupAgreement(m2, m1replargs)
agmtm2tom1 = m2.setupAgreement(m1, m2replargs)
print "starting replication . . ."
m1.startReplication(agmtm1tom2)
print "Replication started"
print "add a ou=Clovis entry"
dn = "ou=Clovis,dc=example,dc=com"
ent = Entry(dn)
ent.setValues('objectclass', 'top', 'organizationalUnit', 'nsView')
ent.setValues('nsviewfilter', '(l=Clovis)')
m1.add_s(ent)
m2.waitForEntry(ent)
print "add a ou=Finance entry"
dn = "ou=Finance,ou=Clovis,dc=example,dc=com"
ent = Entry(dn)
ent.setValues('objectclass', 'top', 'organizationalUnit', 'nsView')
ent.setValues('nsviewfilter', '(departmentNumber=finance)')
m1.add_s(ent)
m2.waitForEntry(ent)
print "Delete ou=Finance"
m1.delete_s(dn)
print "wait for delete to propagate"
time.sleep(5)
print "Search for ou=finance on m2"
try:
ent = m2.getEntry(dn, ldap.SCOPE_BASE)
except ldap.NO_SUCH_OBJECT:
print "Entry %s was deleted" % dn