Exemple #1
0
def test_promote_volcoll(setup_teardown_for_each_test):
    volcoll_resp = create_volcoll(volcoll_name1)
    voloume_name = nimosclientbase.get_unique_string(
        "VolumeCollectionTestCase-addtovolcoll")

    vol_resp = nimosclientbase.get_nimos_client().volumes.create(voloume_name,
                                                                 size=50)
    volume.vol_to_delete.append(vol_resp.attrs.get("id"))
    assert volcoll_resp is not None

    # associate the volume to volcoll
    vol_associate_resp = nimosclientbase.get_nimos_client().volumes.associate(
        id=vol_resp.attrs.get("id"), volcoll=volcoll_resp)
    assert vol_resp is not None
    # check
    assert vol_associate_resp.get("volcoll_name") == volcoll_name1
    assert vol_associate_resp.get("volcoll_id") == volcoll_resp.attrs.get("id")
    try:
        nimosclientbase.get_nimos_client().volume_collections.promote(
            id=volcoll_resp.attrs.get("id"))
    except exceptions.NimOSAPIError as ex:
        if "SM_ealready" in str(ex):
            log("Failed as expected. volcoll is already promoted")
        else:
            log(f"Failed with exception message : {str(ex)}")
            raise ex
def before_running_all_testcase(request):
    log("**** Starting Tests for Initiatorgroups Testcase *****\n")

    def after_running_all_testcase():
        log("**** Completed Tests for initiatorgroups Testcase *****\n")

    request.addfinalizer(after_running_all_testcase)
Exemple #3
0
def test_get_protection_schedules(setup_teardown_for_each_test):

    try:
        resp = create_protection_schedule(
            prot_schedule_name1,
            description="created by testcase",
            volcoll_or_prottmpl_id=protection_template_to_delete[0],
            volcoll_or_prottmpl_type="protection_template",
            num_retain=1)
        assert resp is not None
        get_resp = nimosclientbase.get_nimos_client().protection_schedules.get(
            id=resp.attrs.get("id"))
        assert get_resp is not None
        assert get_resp.attrs.get("id") == resp.attrs.get("id")

        # retreive all
        getall_resp = nimosclientbase.get_nimos_client(
        ).protection_schedules.list()
        assert getall_resp is not None
        # by default 6 protection schedule are on array
        assert getall_resp.__len__() >= 6
    except exceptions.NimOSAPIError as ex:
        if "SM_invalid_arg_value" in str(ex):
            log(f"Failed as expected. template name : {prot_template_name1}")
        else:
            log(f"Failed with exception message : {str(ex)}")
            raise ex
Exemple #4
0
def before_running_all_testcase(request):
    log("**** Starting Tests for protection_schedule TestCase *****\n")

    def after_running_all_testcase():
        log("**** Completed Tests for protection_schedule TestCase *****\n")

    request.addfinalizer(after_running_all_testcase)
Exemple #5
0
def before_running_all_testcase(request):
    log("**** Starting Tests for Volume TestCase *****\n")
    cleanup_old_volumes()

    def after_running_all_testcase():
        log("**** Completed Tests for Volume TestCase *****\n")
    request.addfinalizer(after_running_all_testcase)
Exemple #6
0
def test_get_softwareversionsdetails(setup_teardown_for_each_test):
    try:
        resp = nimosclientbase.get_nimos_client().software_versions.get()
        assert resp is not None
    except exceptions.NimOSAPIError as ex:
        log(f"Failed with exception message : {str(ex)}")
        raise ex
Exemple #7
0
def test_restore_online_volume(setup_teardown_for_each_test):
    try:
        snapshot_resp = None
        # first create volume
        vol_resp = create_volume(vol_name1, size=5)
        snapshot_name1 = nimosclientbase.get_unique_string(
            "volumetc-snapshot1")
        snapshot_resp = nimosclientbase.get_nimos_client().snapshots.create(
            name=snapshot_name1,
            vol_id=vol_to_delete[0],
            description="created by testcase",
            online=False,
            writable=False)
        assert snapshot_resp is not None
        # restore the volume
        vol_restore_resp = nimosclientbase.get_nimos_client().volumes.restore(
            base_snap_id=snapshot_resp.attrs.get("id"),
            id=vol_resp.attrs.get("id"))
        assert vol_restore_resp is not None
    except exceptions.NimOSAPIError as ex:
        if "SM_vol_not_offline_on_restore" in str(ex):
            log("Failed as expected. volume to restore is not offline")
        else:
            log(f"Failed with exception message : {str(ex)}")
            raise ex
def test_delete_perf_policies(setup_teardown_for_each_test):
    try:
        # create one
        resp = create_perf_policy(perf_policy_name1,
                                  description="created by testcase",
                                  block_size=8192,
                                  app_category="db2")
        assert resp is not None
        # match the value
        get_resp = nimosclientbase.get_nimos_client().performance_policies.get(
            id=resp.attrs.get("id"))
        assert get_resp is not None
        assert get_resp.attrs.get("id") == performancepolicy_to_delete[0]
        assert get_resp.attrs.get("description") == "created by testcase"
        assert get_resp.attrs.get("block_size") == 8192
        assert get_resp.attrs.get("app_category") == "db2"

        # delete the policy
        delete_resp = nimosclientbase.get_nimos_client(
        ).performance_policies.delete(id=get_resp.attrs.get("id"))
        assert delete_resp.__len__() == 0
        performancepolicy_to_delete.remove(resp.attrs.get("id"))
    except exceptions.NimOSAPIError as ex:
        if "SM_perfpol_invalid_app_category" in str(ex):
            log("Failed as expected. Invalid app category provided.")
        else:
            log(f"Failed with exception message : {str(ex)}")
            raise ex
def before_running_all_testcase(request):
    log("**** Starting Tests for Performance Policies TestCase *****\n")

    def after_running_all_testcase():
        log("**** Completed Tests for Performance Policies TestCase *****\n")

    request.addfinalizer(after_running_all_testcase)
def before_running_all_testcase(request):
    log("**** Starting Tests for Snapcoll TestCase *****\n")

    def after_running_all_testcase():
        log("**** Completed Tests for Snapcoll TestCase *****\n")

    request.addfinalizer(after_running_all_testcase)
Exemple #11
0
def test_update_pools(setup_teardown_for_each_test):
    try:
        resp = nimosclientbase.get_nimos_client().pools.get()
        assert resp is not None
        desc_name = resp.attrs.get("description")
        name = resp.attrs.get("name")
        # update name
        update_resp = nimosclientbase.get_nimos_client().pools.update(
            resp.attrs.get("id"),
            description="modified by testcase",
            name="testcasename")
        assert update_resp is not None
        # assert it got updated
        assert update_resp.attrs.get("description") == "modified by testcase"
        assert update_resp.attrs.get("name") == "testcasename"
        # rename it back
        update_resp = nimosclientbase.get_nimos_client().pools.update(
            resp.attrs.get("id"),
            description=desc_name,
            name=name)
        assert update_resp is not None
    except Exception as ex:
        # fiji and below throws SM_eperm as exception
        if "SM_eperm" in str(ex):
            log("Failed as expected")
Exemple #12
0
def test_create_master_key(setup_teardown_for_each_test):
    try:
        resp = create_master_key(key_name_1, passphrase=passphrase)
        assert resp is not None
    except exceptions.NimOSAPIError as ex:
        log(f"Failed with exception message : {str(ex)}")
        raise ex
def test_delete_volume_in_volcoll_before_disassociating(
        setup_teardown_for_each_test):

    volcoll_resp = create_volcoll(volcoll_name1)
    voloume_name = nimosclientbase.get_unique_string(
        "VolumeCollectionTestCase-addtovolcoll")

    vol_resp = nimosclientbase.get_nimos_client().volumes.create(voloume_name,
                                                                 size=50)
    volume.vol_to_delete.append(vol_resp.attrs.get("id"))
    assert volcoll_resp is not None

    # associate the volume to volcoll
    vol_associate_resp = nimosclientbase.get_nimos_client().volumes.associate(
        id=vol_resp.attrs.get("id"), volcoll=volcoll_resp)
    assert vol_resp is not None
    # check
    assert vol_associate_resp.get("volcoll_name") == volcoll_name1
    assert vol_associate_resp.get("volcoll_id") == volcoll_resp.attrs.get("id")
    # try deleting the volcoll . this should fail as
    # volume has not been disassocited
    try:
        nimosclientbase.get_nimos_client().volumes.offline(
            id=vol_resp.attrs.get("id"))
        nimosclientbase.get_nimos_client().volumes.delete(
            id=vol_resp.attrs.get("id"))
    except exceptions.NimOSAPIError as ex:
        if "SM_vol_assoc_volcoll" in str(ex):
            log("Failed as expected with exception SM_vol_assoc_volcoll")
        else:
            log(f"Failed with exception message : {str(ex)}")
            raise ex
def test_update_initiatorgroup(setup_teardown_for_each_test):
    try:
        iscsi_initiators = [{
            "label":
            "itor1",
            "ip_address":
            "1.1.1.1",
            "iqn":
            "iqn.1992-01.com.example:storage.tape1.sys1.xyz"
        }]
        description = "modified by testcase"
        access_protocol = "iscsi"
        ig_resp = create_initiatorgroup(
            initiator_grp_name1,
            description="created by testcase",
            access_protocol=access_protocol,
        )
        # assert the values
        assert ig_resp is not None
        # update the target_subnet
        update_resp = nimosclientbase.get_nimos_client(
        ).initiator_groups.update(id=ig_resp.attrs.get("id"),
                                  description=description,
                                  iscsi_initiators=iscsi_initiators)
        assert update_resp is not None
    except exceptions.NimOSAPIError as ex:
        if "SM_invalid_arg_value" in str(ex):
            log(f"Failed as expected. Invalid param value")
        else:
            log(f"Failed with exception message : {str(ex)}")
            raise ex
def test_delete_snapcoll_with_onlinesnapshot(setup_teardown_for_each_test):
    # should throw ex "SM_vol_has_online_snap"
    snapcoll_resp = create_snapcoll(snapcoll_name1,
                                    volcoll_id=volcoll.volcoll_to_delete[0],
                                    description="created by testcase",
                                    replicate=False,
                                    start_online=True)  # online snapshot
    assert snapcoll_resp is not None
    assert snapcoll_name1 == snapcoll_resp.attrs.get("name")
    assert "created by testcase" == snapcoll_resp.attrs.get("description")
    assert snapcoll_resp.attrs.get("replicate") is False
    # get the snapcoll
    snapcoll_resp = nimosclientbase.get_nimos_client(
    ).snapshot_collections.get(id=snapcoll_resp.attrs.get("id"))
    assert snapcoll_resp
    # try deleting it should throw exception
    try:
        delete_snapcoll()
        volume.delete_volume()
    except exceptions.NimOSAPIError as ex:
        if "SM_vol_has_online_snap" in str(ex):
            log("Failed as expected with exception : 'SM_vol_has_online_snap'")
            # offilne the snapshot
            snapshotlist = snapcoll_resp.attrs.get("snapshots_list")
            for snapid in snapshotlist:
                snapresp = nimosclientbase.get_nimos_client().snapshots.update(
                    id=snapid["id"], online=False)
                assert snapresp is not None
        else:
            log(f"Failed with exception message : {str(ex)}")
            raise ex
def setup_teardown_for_each_test(before_running_all_testcase, request):
    # setup operations before yield is called
    nimosclientbase.log_header(request.function.__name__)
    global vol_name1, snapcoll_name1, volcoll_name1
    volcoll_name1 = nimosclientbase.get_unique_string("snapcolltc-volcoll1")
    snapcoll_name1 = nimosclientbase.get_unique_string("snapcolltc-snapcoll1")
    vol_name1 = nimosclientbase.get_unique_string("snapcolltc-vol1")
    # 1st create a volcoll and 2nd associate a volume to volcoll
    volcoll_resp = volcoll.create_volcoll(volcoll_name1)
    assert volcoll_resp is not None
    # save the volcoll_id here
    volcoll_resp.attrs.get("id")
    # create and associate a volume
    volresp = volume.create_volume(vol_name1)
    try:
        nimosclientbase.get_nimos_client().volumes.update(
            id=volresp.attrs.get("id"),
            volcoll_id=volcoll_resp.attrs.get("id"))
    except exceptions.NimOSAPIError as ex:
        log(f"Failed with exception message : {str(ex)}")
        raise ex
    yield setup_teardown_for_each_test
    # teardown operations below
    delete_snapcoll()
    volume.delete_volume()
    volcoll.delete_volcoll()
    nimosclientbase.log_footer(request.function.__name__)
def before_running_all_testcase(request):
    log("**** Starting Tests for ReplicationPartner TestCase  *****\n")

    def after_running_all_testcase():
        log("**** Completed Tests for ReplicationPartner TestCase  *****\n")

    request.addfinalizer(after_running_all_testcase)
Exemple #18
0
def test_delete_clone_volume(setup_teardown_for_each_test):

    # first create volume
    clone_vol_name = nimosclientbase.get_unique_string("clone-volumetc")
    resp_vol = create_volume(vol_name1)
    vol_id = resp_vol.attrs.get("id")
    # clone a volume
    snap_resp = nimosclientbase.get_nimos_client().snapshots.create(
        name="test.volumeclone.snapshot", vol_id=vol_id)
    clonevol_resp = nimosclientbase.get_nimos_client().volumes.create(
        name=clone_vol_name,
        base_snap_id=snap_resp.attrs.get("id"),
        clone=True)
    # confirm
    assert clone_vol_name == clonevol_resp.attrs.get("name")
    assert clonevol_resp.attrs.get("size") == resp_vol.attrs.get("size")
    # try deleting parent volume . it should fail with
    # exception "SM_vol_has_clone"
    try:
        nimosclientbase.get_nimos_client().volumes.offline(vol_id)
        nimosclientbase.get_nimos_client().volumes.delete(vol_id)
    except exceptions.NimOSAPIError as ex:
        if "SM_vol_has_clone" in str(ex):
            log("Failed as expected. volume has clone")
            # cleanup
            nimosclientbase.get_nimos_client().volumes.offline(
                clonevol_resp.attrs.get("id"))
            nimosclientbase.get_nimos_client().volumes.delete(
                clonevol_resp.attrs.get("id"))
        else:
            log(f"Failed with exception message : {str(ex)}")
            raise ex
def test_create_app_server(setup_teardown_for_each_test):
    try:
        resp = create_app_server(app_server_name_1, hostname="example.com")
        assert resp is not None
    except exceptions.NimOSAPIError as ex:
        log(f"Failed with exception message : {str(ex)}")
        raise ex
Exemple #20
0
def before_running_all_testcase(request):
    log("**** Starting Tests for FibreChannel Config TestCases *****\n")

    def after_running_all_testcase():
        log("**** Completed Tests for FibreChannel Config TestCases *****\n")

    request.addfinalizer(after_running_all_testcase)
def create_chap_user(user_name, password, **kwargs):
    resp = nimosclientbase.get_nimos_client().chap_users.create(
        name=user_name, password=password, **kwargs)
    chap_user_id = resp.attrs.get("id")
    chap_user_to_delete.append(chap_user_id)
    assert resp is not None
    log(f"Created chap user with name '{user_name} ' and Id '{chap_user_id}'")
    return resp
Exemple #22
0
def create_volume(vol_name, size=50, read_only="false"):
    resp = nimosclientbase.get_nimos_client().volumes.create(
        vol_name, size=size, read_only=read_only)
    vol_id = resp.attrs.get("id")
    vol_to_delete.append(vol_id)
    assert resp is not None
    log(f"Created volume with name '{vol_name}' and Id '{vol_id}'")
    return resp
Exemple #23
0
def before_running_all_testcase(request):
    log("**** Starting Tests for FibreChannel ports and "
        "session TestCases *****\n")

    def after_running_all_testcase():
        log("**** Completed Tests for FibreChannel ports "
            "and session TestCases *****\n")
    request.addfinalizer(after_running_all_testcase)
def create_user(user_name1, **kwargs):
    resp = nimosclientbase.get_nimos_client().users.create(name=user_name1,
                                                           **kwargs)
    user_id = resp.attrs.get("id")
    user_to_delete.append(user_id)
    assert resp is not None
    log(f"Creating testuser with name '{user_name1}' and ID '{user_id}'")
    return resp
def create_snapcoll(snapcoll_name, **kwargs):
    resp = nimosclientbase.get_nimos_client().snapshot_collections.create(
        name=snapcoll_name, **kwargs)
    snapcoll_id = resp.attrs.get("id")
    snapcoll_to_delete.append(snapcoll_id)
    assert resp is not None
    log(f"Created snapcoll with name '{snapcoll_name}' and Id '{snapcoll_id}'")
    return resp
def create_initiatorgroup(initiator_grp_name, **kwargs):
    resp = nimosclientbase.get_nimos_client().initiator_groups.create(
        name=initiator_grp_name, **kwargs)
    id = resp.attrs.get("id")
    initiatorgrp_to_delete.append(id)
    assert resp is not None
    log(f"created IG with name '{initiator_grp_name}' and Id '{id}'")
    return resp
Exemple #27
0
def create_master_key(master_key, **kwargs):
    resp = nimosclientbase.get_nimos_client().master_key.create(
        name=master_key, **kwargs)
    master_key_id = resp.attrs.get("id")
    master_key_to_delete.append(master_key_id)
    assert resp is not None
    log("Created master key with name "
        f"'{master_key}' and Id '{master_key_id}'")
    return resp
def test_replication_partners_endrow_beyond(setup_teardown_for_each_test):
    try:
        nimosclientbase.get_nimos_client().replication_partners.get(endRow=30)
    except exceptions.NimOSAPIError as ex:
        if "SM_end_row_beyond_total_rows" in str(ex):
            log("Failed as expected.no rows present")
        else:
            log(f"Failed with exception message : {str(ex)}")
            raise ex
def test_user_name_with_more_than_allowed_characters(
        setup_teardown_for_each_test):
    # only 32 char is allowed for user_name1.
    try:
        username = user_name1+user_name1+user_name1+user_name1 + \
            user_name1+user_name1+user_name1+user_name1
        create_user(username, password="******")
    except exceptions.NimOSAPIError:
        log(f"Failed as expected. invalid user_name : {username}")
Exemple #30
0
def create_folders(folder_name, **kwargs):
    resp = nimosclientbase.get_nimos_client().folders.create(name=folder_name,
                                                             **kwargs)
    folder_id = resp.attrs.get("id")
    folders_to_delete.append(folder_id)
    assert resp is not None
    log("Created folder with name " f"'{folder_name}' and Id '{folder_id}'")
    assert resp is not None
    return resp