本文整理匯總了Python中lib389.Entry.setValues方法的典型用法代碼示例。如果您正苦於以下問題:Python Entry.setValues方法的具體用法?Python Entry.setValues怎麽用?Python Entry.setValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lib389.Entry
的用法示例。
在下文中一共展示了Entry.setValues方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_ticket47676_skip_oc_at
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def test_ticket47676_skip_oc_at(topology):
'''
This test ADD an entry on MASTER1 where 47676 is fixed. Then it checks that entry is replicated
on MASTER2 (even if on MASTER2 47676 is NOT fixed). Then update on MASTER2.
If the schema has successfully been pushed, updating Master2 should succeed
'''
topology.master1.log.info("\n\n######################### ADD ######################\n")
# bind as 'cn=Directory manager'
topology.master1.log.info("Bind as %s and add the add the entry with specific oc" % DN_DM)
topology.master1.simple_bind_s(DN_DM, PASSWORD)
# Prepare the entry with multivalued members
entry = Entry(ENTRY_DN)
entry.setValues('objectclass', 'top', 'person', 'OCticket47676')
entry.setValues('sn', ENTRY_NAME)
entry.setValues('cn', ENTRY_NAME)
entry.setValues('postalAddress', 'here')
entry.setValues('postalCode', '1234')
members = []
for cpt in range(MAX_OTHERS):
name = "%s%d" % (OTHER_NAME, cpt)
members.append("cn=%s,%s" % (name, SUFFIX))
members.append(BIND_DN)
entry.setValues('member', members)
topology.master1.log.info("Try to add Add %s should be successful" % ENTRY_DN)
topology.master1.add_s(entry)
#
# Now check the entry as been replicated
#
topology.master2.simple_bind_s(DN_DM, PASSWORD)
topology.master1.log.info("Try to retrieve %s from Master2" % ENTRY_DN)
loop = 0
while loop <= 10:
try:
ent = topology.master2.getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)")
break
except ldap.NO_SUCH_OBJECT:
time.sleep(2)
loop += 1
assert loop <= 10
# Now update the entry on Master2 (as DM because 47676 is possibly not fixed on M2)
topology.master1.log.info("Update %s on M2" % ENTRY_DN)
mod = [(ldap.MOD_REPLACE, 'description', 'test_add')]
topology.master2.modify_s(ENTRY_DN, mod)
topology.master1.simple_bind_s(DN_DM, PASSWORD)
loop = 0
while loop <= 10:
ent = topology.master1.getEntry(ENTRY_DN, ldap.SCOPE_BASE, "(objectclass=*)")
if ent.hasAttr('description') and (ent.getValue('description') == 'test_add'):
break
time.sleep(1)
loop += 1
assert ent.getValue('description') == 'test_add'
示例2: add_group
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def add_group(topology):
"""Create a group for the user to have some rights to"""
log.info("Create a group entry: %s" % TEST_GROUP)
gentry = Entry(TEST_GROUP)
gentry.setValues("objectclass", "top", "extensibleobject")
gentry.setValues("cn", "testgroup")
topology.instance.add_s(gentry)
示例3: add_user
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def add_user(topology):
"""Create a user entry"""
log.info("Create a user entry: %s" % TEST_USER)
uentry = Entry(TEST_USER)
uentry.setValues("objectclass", "top", "extensibleobject")
uentry.setValues("uid", "test")
topology.instance.add_s(uentry)
示例4: user
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def user(topology):
"""Create user entries"""
for i in range(0, 2):
uentry = Entry('uid=test%s,%s' % (i, DEFAULT_SUFFIX))
uentry.setValues('objectclass', 'top', 'extensibleobject')
uentry.setValues('uid', 'test')
topology.standalone.add_s(uentry)
示例5: makeADUserEnt
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def makeADUserEnt(idnum):
id = str(idnum)
userid = 'testuser' + id
cn = 'Test User' + id
dn = 'cn=%s,%s,%s' % (cn, adusersubtree, suffix)
ent = Entry(dn)
ent.setValues('objectclass', aduserObjClasses)
ent.setValues('cn', cn)
ent.setValues('sn', 'User' + id)
ent.setValues('userPrincipalName', '%[email protected]%s' % (userid, realm))
ent.setValues('sAMAccountName', userid)
return ent
示例6: automemberExport
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def automemberExport(self, suffix=DEFAULT_SUFFIX, scope='sub',
fstr='objectclass=top', ldif_out=None, args=None):
'''
@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
'''
if not ldif_out:
raise ValueError("Missing ldif_out")
cn = 'task-' + time.strftime("%m%d%Y_%H%M%S", time.localtime())
dn = ('cn=%s,cn=automember export updates,cn=tasks,cn=config' % cn)
entry = Entry(dn)
entry.setValues('objectclass', 'top', 'extensibleObject')
entry.setValues('cn', cn)
entry.setValues('basedn', suffix)
entry.setValues('filter', fstr)
entry.setValues('scope', scope)
entry.setValues('ldif', ldif_out)
# start the task and possibly wait for task completion
try:
self.conn.add_s(entry)
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add Automember Export Updates task")
return -1
exitCode = 0
if args and args.get(TASK_WAIT, False):
(done, exitCode) = self.conn.tasks.checkTask(entry, True)
if exitCode:
self.log.error(
"Error: Automember Export Updates task (%s) exited with %d" %
(cn, exitCode))
else:
self.log.info(
"Automember Export Updates task (%s) completed successfully" %
(cn))
self.dn = dn
self.entry = entry
return exitCode
示例7: _test_ticket47560_setup
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def _test_ticket47560_setup():
"""
- Create entry cn=group,SUFFIX
- Create entry cn=member,SUFFIX
- Update 'cn=member,SUFFIX' to add "memberOf: cn=group,SUFFIX"
- Enable Memberof Plugins
"""
log.debug("-------- > _test_ticket47560_setup\n")
#
# By default the memberof plugin is disabled create
# - create a group entry
# - create a member entry
# - set the member entry as memberof the group entry
#
entry = Entry(group_DN)
entry.setValues('objectclass', 'top', 'groupOfNames', 'inetUser')
entry.setValues('cn', 'group')
try:
topology.standalone.add_s(entry)
except ldap.ALREADY_EXISTS:
log.debug("Entry %s already exists" % (group_DN))
entry = Entry(member_DN)
entry.setValues('objectclass', 'top', 'person', 'organizationalPerson', 'inetorgperson', 'inetUser')
entry.setValues('uid', 'member')
entry.setValues('cn', 'member')
entry.setValues('sn', 'member')
try:
topology.standalone.add_s(entry)
except ldap.ALREADY_EXISTS:
log.debug("Entry %s already exists" % (member_DN))
replace = [(ldap.MOD_REPLACE, 'memberof', group_DN)]
topology.standalone.modify_s(member_DN, replace)
#
# enable the memberof plugin and restart the instance
#
_enable_disable_mbo('on')
#
# check memberof attribute is still present
#
filt = 'uid=member'
ents = topology.standalone.search_s(member_DN, ldap.SCOPE_BASE, filt)
assert len(ents) == 1
ent = ents[0]
#print ent
value = ent.getValue('memberof')
#print "memberof: %s" % (value)
assert value == group_DN
示例8: syntaxValidate
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def syntaxValidate(self, suffix=DEFAULT_SUFFIX, fstr='objectclass=top', args=None):
'''
@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
'''
cn = 'task-' + time.strftime("%m%d%Y_%H%M%S", time.localtime())
dn = ('cn=%s,cn=syntax validate,cn=tasks,cn=config' % cn)
entry = Entry(dn)
entry.setValues('objectclass', 'top', 'extensibleObject')
entry.setValues('cn', cn)
entry.setValues('basedn', suffix)
entry.setValues('filter', fstr)
# start the task and possibly wait for task completion
try:
self.conn.add_s(entry)
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add Syntax Validate task")
return -1
exitCode = 0
if args and args.get(TASK_WAIT, False):
(done, exitCode) = self.conn.tasks.checkTask(entry, True)
if exitCode:
self.log.error("Error: Syntax Validate (%s) exited with %d" % (cn, exitCode))
else:
self.log.info("Syntax Validate task (%s) completed successfully" % (cn))
return exitCode
示例9: usnTombstoneCleanup
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def usnTombstoneCleanup(self, suffix=DEFAULT_SUFFIX, bename=None,
maxusn_to_delete=None, args=None):
'''
@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
'''
cn = 'task-' + time.strftime("%m%d%Y_%H%M%S", time.localtime())
dn = ('cn=%s,cn=USN tombstone cleanup task,cn=tasks,cn=config' % cn)
entry = Entry(dn)
entry.setValues('objectclass', 'top', 'extensibleObject')
entry.setValues('cn', cn)
if not bename:
entry.setValues('suffix', suffix)
else:
entry.setValues('backend', bename)
if maxusn_to_delete:
entry.setValues('maxusn_to_delete')
# start the task and possibly wait for task completion
try:
self.conn.add_s(entry)
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add USN tombstone cleanup task")
return -1
exitCode = 0
if args and args.get(TASK_WAIT, False):
(done, exitCode) = self.conn.tasks.checkTask(entry, True)
if exitCode:
self.log.error(
"Error: USN tombstone cleanup task (%s) exited with %d" %
(cn, exitCode))
else:
self.log.info(
"USN tombstone cleanup task (%s) completed successfully" %
(cn))
self.dn = dn
self.entry = entry
return exitCode
示例10: add_user
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def add_user(topology):
"""
Create a user entry
"""
log.info('Create a user entry: %s' % TEST_USER)
uentry = Entry(TEST_USER)
uentry.setValues('objectclass', 'top', 'extensibleobject')
uentry.setValues('uid', 'test')
topology.instance.add_s(uentry)
# This doesn't matter that we re-open the realm
krb = MitKrb5(realm=REALM)
krb.create_principal("test")
# We extract the kt so we can kinit from it
krb.create_keytab("test", "/tmp/test.keytab")
示例11: cleanAllRUV
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def cleanAllRUV(self, suffix=None, replicaid=None, force=None, args=None):
'''
@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
'''
if not replicaid:
raise ValueError("Missing required paramter: replicaid")
if not suffix:
raise ValueError("Missing required paramter: suffix")
cn = 'task-' + time.strftime("%m%d%Y_%H%M%S", time.localtime())
dn = ('cn=%s,cn=cleanallruv,cn=tasks,cn=config' % cn)
entry = Entry(dn)
entry.setValues('objectclass', 'top', 'extensibleObject')
entry.setValues('cn', cn)
entry.setValues('replica-base-dn', suffix)
entry.setValues('replica-id', replicaid)
if force:
entry.setValues('replica-force-cleaning', 'yes')
# start the task and possibly wait for task completion
try:
self.conn.add_s(entry)
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add cleanAllRUV task")
return (dn, -1)
exitCode = 0
if args and args.get(TASK_WAIT, False):
(done, exitCode) = self.conn.tasks.checkTask(entry, True)
if exitCode:
self.log.error("Error: cleanAllRUV task (%s) exited with %d" %
(cn, exitCode))
else:
self.log.info("cleanAllRUV task (%s) completed successfully" %
(cn))
self.dn = dn
self.entry = entry
return (dn, exitCode)
示例12: fixupTombstones
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def fixupTombstones(self, bename=None, args=None):
'''
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
'''
if not bename:
bename = DEFAULT_BENAME
# Verify the backend name
if bename:
ents = self.conn.mappingtree.list(bename=bename)
if len(ents) != 1:
raise ValueError("invalid backend name: %s" % bename)
cn = "fixupTombstone_" + time.strftime("%m%d%Y_%H%M%S",
time.localtime())
dn = "cn=%s,%s" % (cn, DN_TOMB_FIXUP_TASK)
entry = Entry(dn)
entry.setValues('objectclass', 'top', 'extensibleObject')
entry.setValues('cn', cn)
entry.setValues('backend', bename)
if args and args.get(TASK_TOMB_STRIP, False):
entry.setValues('stripcsn', 'yes')
# start the task and possibly wait for task completion
try:
self.conn.add_s(entry)
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add the fixup tombstone task")
return -1
exitCode = 0
if args and args.get(TASK_WAIT, False):
(done, exitCode) = self.conn.tasks.checkTask(entry, True)
if exitCode:
self.log.error(
"Error: tombstone fixup task %s for backend %s exited with %d"
% (cn, bename, exitCode))
else:
self.log.info(
"tombstone fixup task %s for backend %s completed successfully"
% (cn, bename))
self.dn = dn
self.entry = entry
return exitCode
示例13: upgradeDB
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def upgradeDB(self, nsArchiveDir=None, nsDatabaseType=None,
nsForceToReindex=None, args=None):
'''
@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
'''
if not nsArchiveDir:
raise ValueError("Missing required paramter: nsArchiveDir")
cn = 'task-' + time.strftime("%m%d%Y_%H%M%S", time.localtime())
dn = ('cn=%s,cn=upgradedb,cn=tasks,cn=config' % cn)
entry = Entry(dn)
entry.setValues('objectclass', 'top', 'extensibleObject')
entry.setValues('cn', cn)
entry.setValues('nsArchiveDir', nsArchiveDir)
if nsDatabaseType:
entry.setValues('nsDatabaseType', nsDatabaseType)
if nsForceToReindex:
entry.setValues('nsForceToReindex', 'True')
# start the task and possibly wait for task completion
try:
self.conn.add_s(entry)
except ldap.ALREADY_EXISTS:
self.log.error("Fail to add upgradedb task")
return -1
exitCode = 0
if args and args.get(TASK_WAIT, False):
(done, exitCode) = self.conn.tasks.checkTask(entry, True)
if exitCode:
self.log.error("Error: upgradedb task (%s) exited with %d" %
(cn, exitCode))
else:
self.log.info("Upgradedb task (%s) completed successfully" % (cn))
self.dn = dn
self.entry = entry
return exitCode
示例14: addIndex
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def addIndex(self, suffix, be_name, attr, indexTypes, matchingRules,
postReadCtrl=None):
"""Specify the suffix (should contain 1 local database backend),
the name of the attribute to index, and the types of indexes
to create e.g. "pres", "eq", "sub"
"""
msg_id = None
if be_name:
dn = ('cn=%s,cn=index,cn=%s,cn=ldbm database,cn=plugins,cn=config'
% (attr, be_name))
else:
entries_backend = self.conn.backend.list(suffix=suffix)
# assume 1 local backend
dn = "cn=%s,cn=index,%s" % (attr, entries_backend[0].dn)
if postReadCtrl:
add_record = [('nsSystemIndex', ['false']),
('cn', [attr]),
('objectclass', ['top', 'nsindex']),
('nsIndexType', indexTypes)]
if matchingRules:
add_record.append(('nsMatchingRule', matchingRules))
else:
entry = Entry(dn)
entry.setValues('objectclass', 'top', 'nsIndex')
entry.setValues('cn', attr)
entry.setValues('nsSystemIndex', "false")
entry.setValues('nsIndexType', indexTypes)
if matchingRules:
entry.setValues('nsMatchingRule', matchingRules)
if MAJOR >= 3 or (MAJOR == 2 and MINOR >= 7):
try:
if postReadCtrl:
pr = PostReadControl(criticality=True, attrList=['*'])
msg_id = self.conn.add_ext(dn, add_record, serverctrls=[pr])
else:
self.conn.add_s(entry)
except ldap.LDAPError as e:
raise e
return msg_id
示例15: addIndex
# 需要導入模塊: from lib389 import Entry [as 別名]
# 或者: from lib389.Entry import setValues [as 別名]
def addIndex(self, suffix, attr, indexTypes, matchingRules):
"""Specify the suffix (should contain 1 local database backend),
the name of the attribute to index, and the types of indexes
to create e.g. "pres", "eq", "sub"
"""
entries_backend = self.conn.backend.list(suffix=suffix)
# assume 1 local backend
dn = "cn=%s,cn=index,%s" % (attr, entries_backend[0].dn)
entry = Entry(dn)
entry.setValues('objectclass', 'top', 'nsIndex')
entry.setValues('cn', attr)
entry.setValues('nsSystemIndex', "false")
entry.setValues('nsIndexType', indexTypes)
if matchingRules:
entry.setValues('nsMatchingRule', matchingRules)
try:
self.conn.add_s(entry)
except ldap.ALREADY_EXISTS:
print "Index for attr %s for backend %s already exists" % (
attr, dn)