コード例 #1
0
def list_definition(inst, basedn, log, args):
    """
        List automember definition if instance name
        is given else show all automember definitions.

        :param name: An instance 
        :type name: lib389.DirSrv

    """

    automembers = AutoMembershipDefinitions(inst)

    if args.name is not None:
        if args.json:
            print(automembers.get_all_attrs_json(args.name))
        else:
            automember = automembers.get(args.name)
            log.info(automember.display())
    else:
        all_definitions = automembers.list()
        if args.json:
            result = {'type': 'list', 'items': []}
        for definition in all_definitions:
            if args.json:
                result['items'].append(definition)
            else:
                log.info(definition.display())

        if args.json:
            print(json.dumps(result))
コード例 #2
0
ファイル: automember.py プロジェクト: vashirov/389-ds-base
def definition_list(inst, basedn, log, args):
    automembers = AutoMembershipDefinitions(inst)
    result = []
    result_json = []
    for definition in automembers.list():
        if args.json:
            result_json.append(json.loads(definition.get_all_attrs_json()))
        else:
            result.append(definition.rdn)
    if args.json:
        log.info(json.dumps({"type": "list", "items": result_json}, indent=4))
    else:
        if len(result) > 0:
            for i in result:
                log.info(i)
        else:
            log.info("No Automember definitions were found")
コード例 #3
0
def list_definition(inst, basedn, log, args):
    """
        List automember definition if instance name
        is given else show all automember definitions.

        :param name: An instance 
        :type name: lib389.DirSrv

    """

    automembers = AutoMembershipDefinitions(inst)

    if args.name is not None:
        automember = automembers.get(args.name)
        log.info(automember.display())
    else:
        all_definitions = automembers.list()

        for definition in all_definitions:
            log.info(definition.display())