Example #1
0
def ui_add_capacity(osd_size_capacity_requested):
    """
    Add Capacity via UI

    Args:
        osd_size_capacity_requested (int): Requested osd size capacity

    Returns:
        new_storage_devices_sets_count (int) : Returns True if all OSDs are in Running state

    """
    osd_size_existing = get_osd_size()
    device_sets_required = int(osd_size_capacity_requested / osd_size_existing)
    old_storage_devices_sets_count = get_deviceset_count()
    new_storage_devices_sets_count = int(device_sets_required +
                                         old_storage_devices_sets_count)
    logger.info("Add capacity via UI")
    setup_ui = login_ui()
    add_ui_obj = AddReplaceDeviceUI(setup_ui)
    add_ui_obj.add_capacity_ui()
    close_browser(setup_ui)
    return new_storage_devices_sets_count
Example #2
0
    def test_add_capacity_internal(self, setup_ui):
        """
        Test Add Capacity on Internal cluster via UI

        """
        logger.info("Get osd pods before add capacity")
        osd_pods_before_add_capacity = get_osd_pods()
        osd_count = len(osd_pods_before_add_capacity)

        logger.info("Add capacity via UI")
        infra_ui_obj = AddReplaceDeviceUI(setup_ui)
        infra_ui_obj.add_capacity_ui()

        logging.info("Wait for osd pods to be in Running state")
        for osd_pods in TimeoutSampler(
            timeout=600,
            sleep=10,
            func=get_osd_pods,
        ):
            if len(osd_pods) == (osd_count + 3):
                break

        osd_pod_names = list()
        for osd_pod in osd_pods:
            wait_for_resource_state(
                resource=osd_pod, state=constants.STATUS_RUNNING, timeout=300
            )
            osd_pod_names.append(osd_pod.name)

        logger.info("Verify via ui, all osd pods in Running state")
        infra_ui_obj.verify_pod_status(pod_names=osd_pod_names)

        logger.info("Wait data re-balance to complete")
        ceph_cluster_obj = CephCluster()
        assert ceph_cluster_obj.wait_for_rebalance(
            timeout=5400
        ), "Data re-balance failed to complete"

        if config.ENV_DATA.get("encryption_at_rest"):
            osd_encryption_verification()
Example #3
0
def add_capacity(osd_size_capacity_requested):
    """
    Add storage capacity to the cluster

    Args:
        osd_size_capacity_requested(int): Requested osd size capacity

    Returns:
        new storage device set count (int) : Returns True if all OSDs are in Running state

    Note:
    "StoragedeviceSets->count" represents the set of 3 OSDs.
    That is, if there are 3 OSDs in the system then count will be 1.
    If there are 6 OSDs then count is 2 and so on.
    By changing this value,we can add extra devices to the cluster.
    For example, if we want to expand the cluster by 3 more osds in a cluster that already has 3 osds,
    we can set count as 2. So, with each increase of count by 1,
    we get 3 OSDs extra added to the cluster.
    This is how we are going to 'add capacity' via automation.
    As we know that OCS has 3 way replica. That is, same data is placed in 3 OSDs.
    Because of this, the total usable capacity for apps from 3 OSDs
    will be the size of one OSD (all osds are of same size).
    If we want to add more capacity to the cluster then we need to add 3 OSDs of same size
    as that of the original OSD. add_capacity needs to accept the 'capacity_to_add' as an argument.
    From this we need to arrive at storagedeviceSets -> count and then
    "Patch" this count to get the required capacity to add.
    To do so, we use following formula:
    storageDeviceSets->count = (capacity reqested / osd capacity ) + existing count storageDeviceSets

    """
    osd_size_existing = get_osd_size()
    device_sets_required = int(osd_size_capacity_requested / osd_size_existing)
    old_storage_devices_sets_count = get_deviceset_count()
    new_storage_devices_sets_count = int(device_sets_required +
                                         old_storage_devices_sets_count)
    lvpresent = localstorage.check_local_volume()
    ocp_version = get_ocp_version()
    platform = config.ENV_DATA.get("platform", "").lower()
    is_lso = config.DEPLOYMENT.get("local_storage")
    if (ocp_version == "4.7" and (platform == constants.AWS_PLATFORM
                                  or platform == constants.VSPHERE_PLATFORM)
            and (not is_lso)):
        logging.info("Add capacity via UI")
        setup_ui = login_ui()
        add_ui_obj = AddReplaceDeviceUI(setup_ui)
        add_ui_obj.add_capacity_ui()
        close_browser(setup_ui)
    else:
        if lvpresent:
            ocp_obj = OCP(kind="localvolume",
                          namespace=config.ENV_DATA["local_storage_namespace"])
            localvolume_data = ocp_obj.get(resource_name="local-block")
            device_list = localvolume_data["spec"]["storageClassDevices"][0][
                "devicePaths"]
            final_device_list = localstorage.get_new_device_paths(
                device_sets_required, osd_size_capacity_requested)
            device_list.sort()
            final_device_list.sort()
            if device_list == final_device_list:
                raise ResourceNotFoundError("No Extra device found")
            param = f"""[{{ "op": "replace", "path": "/spec/storageClassDevices/0/devicePaths",
                                                     "value": {final_device_list}}}]"""
            log.info(f"Final device list : {final_device_list}")
            lvcr = localstorage.get_local_volume_cr()
            log.info("Patching Local Volume CR...")
            lvcr.patch(
                resource_name=lvcr.get()["items"][0]["metadata"]["name"],
                params=param.strip("\n"),
                format_type="json",
            )
            localstorage.check_pvs_created(
                int(len(final_device_list) / new_storage_devices_sets_count))
        sc = get_storage_cluster()
        # adding the storage capacity to the cluster
        params = f"""[{{ "op": "replace", "path": "/spec/storageDeviceSets/0/count",
                    "value": {new_storage_devices_sets_count}}}]"""
        sc.patch(
            resource_name=sc.get()["items"][0]["metadata"]["name"],
            params=params.strip("\n"),
            format_type="json",
        )
    return new_storage_devices_sets_count