DSE ldif

Usage example

from lib389.dseldif import DSEldif

dse_ldif = DSEldif(topo.standalone)

# Get a list of attribute values under a given entry
config_cn = dse_ldif.get(DN_CONFIG, 'cn')

# Add an attribute under a given entry
dse_ldif.add(DN_CONFIG, 'someattr', 'someattr_value')

# Replace attribute values with a new one under a given entry. It will remove all previous 'someattr' values
dse_ldif.replace(DN_CONFIG, 'someattr', 'someattr_value')

# Delete attributes under a given entry
dse_ldif.delete(DN_CONFIG, 'someattr')
dse_ldif.delete(DN_CONFIG, 'someattr', 'someattr_value')

Module documentation

class lib389.dseldif.DSEldif(instance, serverid=None)[source]

A class for working with dse.ldif file

Parameters

instance (lib389.DirSrv) – An instance

add(entry_dn, attr, value)[source]

Add an attribute under a given entry

Parameters
  • entry_dn (str) – a DN of entry we want to edit

  • attr (str) – an attribute name

  • value (str) – an attribute value

delete(entry_dn, attr, value=None)[source]

Delete attributes under a given entry

Parameters
  • entry_dn (str) – a DN of entry we want to edit

  • attr (str) – an attribute name

  • value (str) – an attribute value

get(entry_dn, attr, single=False)[source]

Return attribute values under a given entry

Parameters
  • entry_dn (str) – a DN of entry we want to get attribute from

  • attr (str) – an attribute name

  • single – Return a single value instead of a list

readNsState(suffix=None, flip=False)[source]

Look for the nsState attribute in replication configuration entries, then decode the base64 value and provide a dict of all stats it contains

Parameters

suffix (str) – specific suffix to read nsState from

replace(entry_dn, attr, value)[source]

Replace attribute values with a new one under a given entry

Parameters
  • entry_dn (str) – a DN of entry we want to edit

  • attr (str) – an attribute name

  • value (str) – an attribute value