Replication Tools

Usage example

from lib389.repltools import ReplTools

# Gather all the CSN strings from the access and verify all of those CSNs exist on all the other replicas.
# dirsrv_replicas - a list of DirSrv objects.  The list must begin with master replicas
# ignoreCSNs - an optional string of csns to be ignored
# if the caller knows that some csns can differ eg.: '57e39e72000000020000|vucsn-57e39e76000000030000'
ReplTools.checkCSNs([master1, master2], ignoreCSNs=None)

# Find and measure the convergence of entries from a replica, and
# print a report on how fast all the "ops" replicated to the other replicas.
# suffix - Replicated suffix
# ops - A list of "operations" to search for in the access logs
# replica - Dirsrv object where the entries originated
# all_replicas - A list of Dirsrv replicas
# It returns - The longest time in seconds for an operation to fully converge
longest_time = ReplTools.replConvReport(DEFAULT_SUFFIX, ops, master1, [master1, master2])

# Take a list of DirSrv Objects and check to see if all of the present
# replication agreements are idle for a particular backend
assert(ReplTools.replIdle([master1, master2], suffix=DEFAULT_SUFFIX))
defaultProperties = {
            REPLICATION_BIND_DN: "cn=replication manager,cn=config",
            REPLICATION_BIND_PW

# Create an entry that will be used to bind as replication manager
ReplTools.createReplManager(standalone,
                            repl_manager_dn=defaultProperties[REPLICATION_BIND_DN],
                            repl_manager_pw=defaultProperties[REPLICATION_BIND_PW])

Module documentation

class lib389.repltools.ReplTools[source]

Replication tools

static checkCSNs(dirsrv_replicas, ignoreCSNs=None)[source]

Gather all the CSN strings from the access and verify all of those CSNs exist on all the other replicas.

Parameters
  • dirsrv_replicas (list of lib389.DirSrv) – A list of DirSrv objects. The list must begin with master replicas

  • ignoreCSNs (str) – An optional string of csns to be ignored if the caller knows that some csns can differ eg.: ‘57e39e72000000020000|vucsn-57e39e76000000030000’

Returns

True if all the CSNs are present, otherwise False

static createReplManager(server, repl_manager_dn=None, repl_manager_pw=None)[source]

Create an entry that will be used to bind as replication manager.

Parameters
  • server (lib389.DirSrv) – An instance to connect to

  • repl_manager_dn (str) – DN of the bind entry. If not provided use the default one

  • repl_manager_pw (str) – Password of the entry. If not provide use the default one

Returns

None

Raises
  • KeyError - if can not find valid values of Bind DN and Pwd

  • LDAPError - if we fail to add the replication manager

static replConvReport(suffix, ops, replica, all_replicas)[source]

Find and measure the convergence of entries from a replica, and print a report on how fast all the “ops” replicated to the other replicas.

Parameters
  • suffix (str) – Replicated suffix

  • ops (list) – a list of “operations” to search for in the access logs

  • replica (lib389.DirSrv) – Instance where the entries originated

  • all_replicas (list of lib389.DirSrv) – Suppliers, hubs, consumers

Returns

The longest time in seconds for an operation to fully converge

static replIdle(replicas, suffix='dc=example,dc=com')[source]

Take a list of DirSrv Objects and check to see if all of the present replication agreements are idle for a particular backend

Parameters
  • replicas (list of lib389.DirSrv) – Suppliers, hubs, consumers

  • suffix (str) – Replicated suffix

Raises

LDAPError: if unable to search for the replication agreements

Returns

True if all the agreements are idle, otherwise False