Indexes

Besides the predefined tasks (which described in a chapter below) you can create your own task objects with specifying a DN (https://github.com/389ds/389-ds-base/blob/master/src/lib389/lib389/_constants.py#L146)

Usage example

from lib389.tasks import Task

newtask = Task(instance, dn) # Should we create Tasks and put the precious to TasksLegacy?

newtask.create(rdn, properties, basedn)

# Check if the task is complete
assert(newtask.is_complete())

# Check task's exit code if task is complete, else None
if newtask.is_complete():
    exit_code = newtask.get_exit_code()

# Wait until task is complete
newtask.wait()

# If True,  waits for the completion of the task before to return
args = {TASK_WAIT: True}

# Some tasks ca be found only under old object. You can access them with this:
standalone.tasks.importLDIF(DEFAULT_SUFFIX, path_ro_ldif, args)
standalone.tasks.exportLDIF(DEFAULT_SUFFIX, benamebase=None, output_file=path_to_ldif, args)
standalone.tasks.db2bak(backup_dir, args)
standalone.tasks.bak2db(backup_dir, args)
standalone.tasks.reindex(suffix=None, benamebase=None, attrname=None, args)
standalone.tasks.fixupMemberOf(suffix=None, benamebase=None, filt=None, args)
standalone.tasks.fixupTombstones(bename=None, args)
standalone.tasks.automemberRebuild(suffix=DEFAULT_SUFFIX, scope='sub', filterstr='objectclass=top', args)
standalone.tasks.automemberExport(suffix=DEFAULT_SUFFIX, scope='sub', fstr='objectclass=top', ldif_out=None, args)
standalone.tasks.automemberMap(ldif_in=None, ldif_out=None, args)
standalone.tasks.fixupLinkedAttrs(linkdn=None, args)
standalone.tasks.schemaReload(schemadir=None, args)
standalone.tasks.fixupWinsyncMembers(suffix=DEFAULT_SUFFIX, fstr='objectclass=top', args)
standalone.tasks.syntaxValidate(suffix=DEFAULT_SUFFIX, fstr='objectclass=top', args)
standalone.tasks.usnTombstoneCleanup(suffix=DEFAULT_SUFFIX, bename=None, maxusn_to_delete=None, args)
standalone.tasks.sysconfigReload(configfile=None, logchanges=None, args)
standalone.tasks.cleanAllRUV(suffix=None, replicaid=None, force=None, args)
standalone.tasks.abortCleanAllRUV(suffix=None, replicaid=None, certify=None, args)
standalone.tasks.upgradeDB(nsArchiveDir=None, nsDatabaseType=None, nsForceToReindex=None, args)

Module documentation

class lib389.tasks.Tasks(conn)[source]
abortCleanAllRUV(suffix=None, replicaid=None, certify=None, args=None)[source]

@param replicaid - The replica ID to remove/clean @param certify - True/False - Certify the task was aborted on all

the replicas

@param args - is a dictionary that contains modifier of the task
wait: True/[False] - If True, waits for the completion of

the task before to return

@return tuple (task dn, and the exit code) @raise ValueError: If missing replicaid

automemberExport(suffix='dc=example,dc=com', scope='sub', fstr='objectclass=top', ldif_out=None, args=None)[source]
@param suffix - The suffix the task should examine - default is

“dc=example,dc=com”

@param scope - The scope of the search to find entries @param fstr - The search filter to find entries @param ldif_out - The name for the output LDIF file @param args - is a dictionary that contains modifier of the task

wait: True/[False] - If True, waits for the completion of

the task before to return

@return exit code @raise ValueError: if ldif_out is not provided

automemberMap(ldif_in=None, ldif_out=None, args=None)[source]

@param ldif_in - Entries to pass into the task for processing @param ldif_out - The resulting LDIF of changes from ldif_in @param args - is a dictionary that contains modifier of the task

wait: True/[False] - If True, waits for the completion

of the task before to return

@return exit code @raise ValueError: if ldif_out/ldif_in is not provided

automemberRebuild(suffix='dc=example,dc=com', scope='sub', filterstr='objectclass=top', args=None)[source]
@param suffix - The suffix the task should examine - defualt is

“dc=example,dc=com”

@param scope - The scope of the search to find entries @param fitlerstr - THe search filter to find entries @param args - is a dictionary that contains modifier of the task

wait: True/[False] - If True, waits for the completion of

the task before to return

@return exit code

bak2db(backup_dir=None, args=None)[source]

Restore a backup by creating a bak2db task

@param bename - ‘commonname’/’cn’ of the backend (e.g. ‘userRoot’) @param backup_dir - backup directory @param args - is a dictionary that contains modifier of the task

wait: True/[False] - If True, waits for the completion of

the task before to return

@return exit code

@raise ValueError: if bename name does not exist

checkTask(entry, dowait=False)[source]

check task status - task is complete when the nsTaskExitCode attr is set return a 2 tuple (true/false,code) first is false if task is running, true if done - if true, second is the exit code - if dowait is True, this function will block until the task is complete

cleanAllRUV(suffix=None, replicaid=None, force=None, args=None)[source]

@param replicaid - The replica ID to remove/clean @param force - True/False - Clean all the replicas, even if one is down @param args - is a dictionary that contains modifier of the task

wait: True/[False] - If True, waits for the completion of the

task before to return

@return tuple (task dn, and the exit code) @raise ValueError: If missing replicaid

db2bak(backup_dir=None, args=None)[source]

Perform a backup by creating a db2bak task

@param backup_dir - backup directory @param args - is a dictionary that contains modifier of the task

wait: True/[False] - If True, waits for the completion of the

task before to return

@return exit code

@raise ValueError: if bename name does not exist

exportLDIF(suffix=None, benamebase=None, output_file=None, args=None)[source]

Export in a LDIF format a given ‘suffix’ (or ‘benamebase’ that stores that suffix). It uses an internal task to acheive this request.

If ‘suffix’ and ‘benamebase’ are specified, it uses ‘benamebase’ first else ‘suffix’. If both ‘suffix’ and ‘benamebase’ are missing it raises ValueError

‘output_file’ is the output file of the export

@param suffix - suffix of the backend @param benamebase - ‘commonname’/’cn’ of the backend (e.g. ‘userRoot’) @param output_file - file that will contain the exported suffix in LDIF

format

@param args - is a dictionary that contains modifier of the export task
wait: True/[False] - If True, ‘export’ waits for the completion

of the task before to return

repl-info: True/[False] - If True, it adds the replication meta

data (state information, tombstones and RUV) in the exported file

@return None

@raise ValueError

fixupLinkedAttrs(linkdn=None, args=None)[source]
@param linkdn - The DN of linked attr config entry (if None all

possible configurations are checked)

@param args - Is a dictionary that contains modifier of the task
wait: True/[False] - If True, waits for the completion

of the task before to return

@return exit code

fixupMemberOf(suffix=None, benamebase=None, filt=None, args=None)[source]

Trigger a fixup task on ‘suffix’ (or ‘benamebase’ that stores that suffix) related to the entries ‘memberof’ of groups. It uses an internal task to acheive this request.

If ‘suffix’ and ‘benamebase’ are specified, it uses ‘benamebase’ first else ‘suffix’. If both ‘suffix’ and ‘benamebase’ are missing it raise ValueError

‘filt’ is a filter that will select all the entries (under ‘suffix’) that we need to evaluate/fix. If missing, the default value is “(|(objectclass=inetuser)(objectclass=inetadmin))”

@param suffix - suffix of the backend @param benamebase - ‘commonname’/’cn’ of the backend

(e.g. ‘userRoot’)

@param args - is a dictionary that contains modifier of the

fixupMemberOf task

wait: True/[False] - If True, waits for the completion of the

task before to return

@return exit code

@raise ValueError: if benamebase and suffix are specified, or can

not retrieve the suffix from the mapping tree entry

fixupTombstones(bename=None, args=None)[source]

Trigger a tombstone fixup task on the specified backend

@param bename - ‘commonname’/’cn’ of the backend (e.g. ‘userRoot’).

Optional.

@param args - is a dictionary that contains modifier of the task
wait: True/[False] - If True, waits for the completion of the

task before to return

@return exit code

@raise ValueError: if bename name does not exist

fixupWinsyncMembers(suffix='dc=example,dc=com', fstr='objectclass=top', args=None)[source]
@param suffix - The suffix the task should rebuild -

default is “dc=example,dc=com”

@param fstr - The search filter to find entries @param args - is a dictionary that contains modifier of the task

wait: True/[False] - If True, waits for the completion of

the task before to return

@return exit code

importLDIF(suffix=None, benamebase=None, input_file=None, args=None)[source]

Import from a LDIF format a given ‘suffix’ (or ‘benamebase’ that stores that suffix). It uses an internal task to acheive this request.

If ‘suffix’ and ‘benamebase’ are specified, it uses ‘benamebase’ first else ‘suffix’. If both ‘suffix’ and ‘benamebase’ are missing it raise ValueError

‘input_file’ is the ldif input file

@param suffix - suffix of the backend @param benamebase - ‘commonname’/’cn’ of the backend (e.g. ‘userRoot’) @param ldif_input - file that will contain the entries in LDIF format

to import

@param args - is a dictionary that contains modifier of the import task
wait: True/[False] - If True, ‘export’ waits for the completion

of the task before to return

@return None

@raise ValueError

reindex(suffix=None, benamebase=None, attrname=None, args=None, vlv=False)[source]

Reindex a ‘suffix’ (or ‘benamebase’ that stores that suffix) for a given ‘attrname’. It uses an internal task to acheive this request.

If ‘suffix’ and ‘benamebase’ are specified, it uses ‘benamebase’ first else ‘suffix’. If both ‘suffix’ and ‘benamebase’ are missing it raise ValueError

:param suffix - suffix of the backend :param benamebase - ‘commonname’/’cn’ of the backend (e.g. ‘userRoot’) :param attrname - attribute name :param args - is a dictionary that contains modifier of the reindex

task

wait: True/[False] - If True, ‘index’ waits for the completion

of the task before to return

:param vlv - this task is to reindex a VLV index

:return None

:raise ValueError - if invalid missing benamebase and suffix or invalid

benamebase

:raise LDAPError if unable to search for index names

schemaReload(schemadir=None, args=None)[source]

@param schemadir - The directory to look for schema files(optional) @param args - Is a dictionary that contains modifier of the task

wait: True/[False] - If True, waits for the completion of

the task before to return

@return exit code

syntaxValidate(suffix='dc=example,dc=com', fstr='objectclass=top', args=None)[source]
@param suffix - The suffix the task should validate -

default is “dc=example,dc=com”

@param fstr - The search filter to find entries @param args - is a dictionary that contains modifier of the task

wait: True/[False] - If True, waits for the completion of the

task before to return

@return exit code

sysconfigReload(configfile=None, logchanges=None, args=None)[source]
@param configfile - The sysconfig file:

/etc/sysconfig/dirsrv-localhost

@param logchanges - True/False - Tell the server to log the changes

made by the task

@param args - is a dictionary that contains modifier of the task
wait: True/[False] - If True, waits for the completion of the

task before to return

@return exit code @raise ValueError: If sysconfig file not provided

upgradeDB(nsArchiveDir=None, nsDatabaseType=None, nsForceToReindex=None, args=None)[source]

@param nsArchiveDir - The archive directory @param nsDatabaseType - The database type - default is “ldbm database” @param nsForceToReindex - True/False - force reindexing to occur @param args - is a dictionary that contains modifier of the task

wait: True/[False] - If True, waits for the completion of the

task before to return

@return exit code @raise ValueError: If missing nsArchiveDir

usnTombstoneCleanup(suffix='dc=example,dc=com', bename=None, maxusn_to_delete=None, args=None)[source]
@param suffix - The suffix the task should cleanup - default is

“dc=example,dc=com”

@param backend - The ‘backend’ the task should cleanup @param maxusn_to_delete - Maximum number of usn’s to delete @param args - is a dictionary that contains modifier of the task

wait: True/[False] - If True, waits for the completion of

the task before to return

@return exit code

class lib389.tasks.Task(instance, dn=None)[source]

A single instance of a task entry

Parameters
  • instance (lib389.DirSrv) – An instance

  • dn (str) – Entry DN

create(rdn=None, properties={}, basedn=None)[source]

Create a Task entry

Parameters
  • rdn (str) – RDN of the new entry

  • properties (dict) – Attributes for the new entry

  • basedn – Base DN of the new entry

Returns

DSLdapObject of the created entry

get_exit_code()[source]

Return task’s exit code if task is complete, else None.

get_task_log()[source]

Return task’s exit code if task is complete, else None.

get_task_warn()[source]

Return task’s warning code if task is complete, else None.

is_complete()[source]

Return True if task is complete, else False.

status()[source]

Return the decoded status of the task

wait(timeout=120)[source]

Wait until task is complete.