Lines 343-364
class FollowLogfile(object):
|
Link Here
|
---|
|
343 |
print "=" * 79 |
343 |
print "=" * 79 |
344 |
|
344 |
|
345 |
|
345 |
|
346 |
def wait_for(replication=True, replication_postrun=False, drs_replication=False, s4_connector=True, verbose=True): |
346 |
from enum import Enum |
|
|
347 |
class ReplicationType(Enum): |
348 |
LISTENER = 1 |
349 |
POSTRUN = 2 |
350 |
S4C_FROM_UCS = 3 |
351 |
S4C_TO_UCS = 4 |
352 |
DRS = 5 |
353 |
|
354 |
|
355 |
def wait_for_replication_from_master_openldap_to_local_samba(replication_postrun=False, ldap_filter=None, verbose=True): |
347 |
"""Wait for all kind of replications""" |
356 |
"""Wait for all kind of replications""" |
348 |
# the order matters! |
357 |
# the order matters! |
349 |
if replication or drs_replication: # does wait_for_drs_replication depend on wait_for_replication?! |
358 |
if replication_postrun: |
350 |
if replication_postrun: |
359 |
conditions = [(ReplicationType.LISTENER, 'postrun')] |
351 |
wait_for_replication_and_postrun(verbose) |
360 |
else: |
352 |
else: |
361 |
conditions = [(ReplicationType.LISTENER, True)] |
353 |
wait_for_replication(verbose) |
362 |
ucr = univention.config_registry.ConfigRegistry() |
354 |
from univention.testing.ucs_samba import wait_for_drs_replication, wait_for_s4connector |
363 |
ucr.load() |
355 |
if drs_replication: |
364 |
if ucr.get('samba4/ldap/base'): |
356 |
wait_for_drs_replication(drs_replication) |
365 |
conditions.append((ReplicationType.S4C_FROM_UCS, ldap_filter)) |
357 |
if s4_connector: |
366 |
if ucr.get('server/role') in ('domaincontroller_backup', 'domaincontroller_slave'): |
358 |
wait_for_s4connector(120) |
367 |
conditions.append((ReplicationType.DRS, ldap_filter)) |
|
|
368 |
wait_for(conditions, verbose=True) |
369 |
|
370 |
|
371 |
def wait_for_replication_from_local_samba_to_local_openldap(replication_postrun=False, ldap_filter=None, verbose=True): |
372 |
"""Wait for all kind of replications""" |
373 |
conditions = [] |
374 |
# the order matters! |
375 |
ucr = univention.config_registry.ConfigRegistry() |
376 |
ucr.load() |
377 |
if ucr.get('server/role') in ('domaincontroller_backup', 'domaincontroller_slave'): |
378 |
conditions.append((ReplicationType.DRS, ldap_filter)) |
379 |
if ucr.get('samba4/ldap/base'): |
380 |
conditions.append((ReplicationType.S4C_FROM_UCS, ldap_filter)) |
381 |
if replication_postrun: |
382 |
conditions.append((ReplicationType.LISTENER, 'postrun')) |
383 |
else: |
384 |
conditions.append((ReplicationType.LISTENER, True)) |
385 |
wait_for(conditions, verbose=True) |
359 |
|
386 |
|
360 |
|
387 |
|
361 |
def wait_for_replication(verbose=True): |
388 |
def wait_for(conditions=None, verbose=True): |
|
|
389 |
"""Wait for all kind of replications""" |
390 |
if not conditions: |
391 |
conditions = [] |
392 |
for replicationtype, detail in conditions: |
393 |
if replicationtype == ReplicationType.LISTENER: |
394 |
if detail == 'postrun': |
395 |
wait_for_listener_replication_and_postrun(verbose) |
396 |
else: |
397 |
wait_for_listener_replication(verbose) |
398 |
elif replicationtype == ReplicationType.S4C_FROM_UCS: |
399 |
wait_for_s4connector_replication() |
400 |
if detail: |
401 |
## TODO: search in Samba/AD with filter=detail |
402 |
pass |
403 |
elif replicationtype == ReplicationType.S4C_TO_UCS: |
404 |
wait_for_s4connector_replication() |
405 |
if detail: |
406 |
## TODO: search in OpenLDAP with filter=detail |
407 |
pass |
408 |
elif replicationtype == ReplicationType.DRS: |
409 |
from univention.testing.ucs_samba import wait_for_drs_replication |
410 |
wait_for_drs_replication(detail) |
411 |
|
412 |
|
413 |
def wait_for_listener_replication(verbose=True): |
362 |
sys.stdout.flush() |
414 |
sys.stdout.flush() |
363 |
time.sleep(1) # Give the notifier some time to increase its transaction id |
415 |
time.sleep(1) # Give the notifier some time to increase its transaction id |
364 |
if verbose: |
416 |
if verbose: |
Lines 380-392
def wait_for_replication(verbose=True):
|
Link Here
|
---|
|
380 |
raise LDAPReplicationFailed() |
432 |
raise LDAPReplicationFailed() |
381 |
|
433 |
|
382 |
|
434 |
|
383 |
def wait_for_replication_and_postrun(verbose=True): |
435 |
def wait_for_listener_replication_and_postrun(verbose=True): |
384 |
# Postrun function in listener modules are called after 15 seconds without any events |
436 |
# Postrun function in listener modules are called after 15 seconds without any events |
385 |
def get_lid(): |
437 |
def get_lid(): |
386 |
with open("/var/lib/univention-directory-listener/notifier_id", "r") as notifier_id: |
438 |
with open("/var/lib/univention-directory-listener/notifier_id", "r") as notifier_id: |
387 |
return int(notifier_id.readline()) |
439 |
return int(notifier_id.readline()) |
388 |
|
440 |
|
389 |
wait_for_replication(verbose=verbose) |
441 |
wait_for_listener_replication(verbose=verbose) |
390 |
if verbose: |
442 |
if verbose: |
391 |
print "Waiting for postrun..." |
443 |
print "Waiting for postrun..." |
392 |
lid = get_lid() |
444 |
lid = get_lid() |
Lines 410-416
def wait_for_replication_and_postrun(verbose=True):
|
Link Here
|
---|
|
410 |
raise LDAPReplicationFailed |
462 |
raise LDAPReplicationFailed |
411 |
|
463 |
|
412 |
|
464 |
|
413 |
def wait_for_connector_replication(): |
465 |
def wait_for_s4connector_replication(): |
414 |
print 'Waiting for connector replication' |
466 |
print 'Waiting for connector replication' |
415 |
import univention.testing.ucs_samba |
467 |
import univention.testing.ucs_samba |
416 |
try: |
468 |
try: |