当前位置: 首页>>代码示例>>Python>>正文


Python Entry.setValues方法代码示例

本文整理汇总了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'
开发者ID:Firstyear,项目名称:ds,代码行数:61,代码来源:ticket47676_test.py

示例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)
开发者ID:Firstyear,项目名称:lib389,代码行数:10,代码来源:effective_rights_test.py

示例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)
开发者ID:Firstyear,项目名称:lib389,代码行数:10,代码来源:effective_rights_test.py

示例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)
开发者ID:Firstyear,项目名称:lib389,代码行数:10,代码来源:dereference_test.py

示例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
开发者ID:nkinder,项目名称:scripts,代码行数:14,代码来源:winsyncssl.py

示例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
开发者ID:Firstyear,项目名称:lib389,代码行数:54,代码来源:tasks.py

示例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
开发者ID:Firstyear,项目名称:ds,代码行数:54,代码来源:ticket47560_test.py

示例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
开发者ID:ioggstream,项目名称:lib389,代码行数:35,代码来源:tasks.py

示例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
开发者ID:Firstyear,项目名称:lib389,代码行数:51,代码来源:tasks.py

示例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")
开发者ID:Firstyear,项目名称:lib389,代码行数:17,代码来源:krb5_create_test.py

示例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)
开发者ID:Firstyear,项目名称:lib389,代码行数:50,代码来源:tasks.py

示例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
开发者ID:Firstyear,项目名称:lib389,代码行数:60,代码来源:tasks.py

示例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
开发者ID:Firstyear,项目名称:lib389,代码行数:50,代码来源:tasks.py

示例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
开发者ID:Firstyear,项目名称:lib389,代码行数:45,代码来源:index.py

示例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)
开发者ID:ioggstream,项目名称:lib389,代码行数:22,代码来源:index.py


注:本文中的lib389.Entry.setValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。