예제 #1
0
def test_migrate_openldap_slapdd(topology_st):
    """

    :id: e9748040-90a0-4d69-bdde-007104f75cc5
    :setup: Data directory with an openldap config directory.
    :steps:
        1. Parse the configuration
        2. Execute a full migration plan

    :expectedresults:
        1. Success
        2. Success
    """

    inst = topology_st.standalone
    config_path = os.path.join(DATADIR1, 'slapd.d')
    config = olConfig(config_path)
    ldifs = {
        "dc=example,dc=com": os.path.join(DATADIR1,
                                          'example_com.slapcat.ldif'),
        "dc=example,dc=net": os.path.join(DATADIR1,
                                          'example_net.slapcat.ldif'),
    }

    migration = Migration(inst, config.schema, config.databases, ldifs)

    print("==== migration plan ====")
    print(migration.__unicode__())
    print("==== end migration plan ====")

    migration.execute_plan()
예제 #2
0
def test_migrate_openldap_hdb(topology_st):
    """Attempt a migration with HDB and no overlay configuration folder.

    :id: 377dbdee-7138-47d9-a518-9e0b0f4d8622
    :setup: Data directory with an openldap config with HDB database.
    :steps:
        1. Parse the configuration
        2. Execute a full migration plan

    :expectedresults:
        1. Success
        2. Success
    """

    inst = topology_st.standalone
    config_path = os.path.join(DATADIR1, 'slapd.d')
    config = olConfig(config_path)
    ldifs = {}

    migration = Migration(config, inst, ldifs)

    print("==== migration plan ====")
    print(migration.__unicode__())
    print("==== end migration plan ====")

    migration.execute_plan()
예제 #3
0
def test_migrate_openldap_memberof(topology_st):
    """Attempt a migration with memberof configured, and ensure it migrates

    :id: f59f4c6a-7c85-40d1-91ee-dccbc0bd7ef8
    :setup: Data directory with an openldap config with memberof
    :steps:
        1. Parse the configuration
        2. Execute a full migration plan
        3. Assert memberof was configured

    :expectedresults:
        1. Success
        2. Success
        3. Success
    """

    inst = topology_st.standalone
    config_path = os.path.join(DATADIR1, 'slapd.d')
    config = olConfig(config_path)

    for overlay in config.databases[0].overlays:
        print("==================================================")
        print("%s" % overlay.otype)
        print("==================================================")
        assert overlay.otype != olOverlayType.UNKNOWN

    ldifs = {}

    migration = Migration(inst, config.schema, config.databases, ldifs)

    print("==== migration plan ====")
    print(migration.__unicode__())
    print("==== end migration plan ====")

    migration.execute_plan()
    # End test, should suceed with no exceptions.

    memberof = MemberOfPlugin(inst)
    assert memberof.status()
예제 #4
0
def test_migrate_openldap_slapdd_skip_elements(topology_st):
    """

    :id: d5e16aeb-6810-423b-b5e0-f89e0596292e
    :setup: Data directory with an openldap config directory.
    :steps:
        1. Parse the configuration
        2. Execute a migration with skipped elements

    :expectedresults:
        1. Success
        2. Success
    """

    inst = topology_st.standalone
    config_path = os.path.join(DATADIR1, 'slapd.d')
    config = olConfig(config_path)
    ldifs = {
        "dc=example,dc=com": os.path.join(DATADIR1,
                                          'example_com.slapcat.ldif'),
    }

    # 1.3.6.1.4.1.5322.13.1.1 is namedObject, so check that isn't there

    migration = Migration(
        inst,
        config.schema,
        config.databases,
        ldifs,
        skip_schema_oids=['1.3.6.1.4.1.5322.13.1.1'],
        skip_overlays=[olOverlayType.UNIQUE],
    )

    print("==== migration plan ====")
    print(migration.__unicode__())
    print("==== end migration plan ====")

    migration.execute_plan()
예제 #5
0
def import_openldap_schema_file(inst, basedn, log, args):
    log = log.getChild('import_openldap_schema_file')
    log.debug(f"Parsing {args.schema_file} ...")
    olschema = olSchema([args.schema_file], log)
    migration = Migration(inst, olschema)
    if args.confirm:
        migration.execute_plan(log)
        log.info("🎉 Schema migration complete!")
    else:
        migration.display_plan_review(log)
        log.info("No actions taken. To apply migration plan, use '--confirm'")