Example #1
0
def select_volume_bricks_to_bring_offline(mnode, volname):
    """Randomly selects bricks to bring offline without affecting the cluster
    from a non-tiered volume.

    Args:
        mnode (str): Node on which commands will be executed.
        volname (str): Name of the volume.

    Returns:
        list: On success returns list of bricks that can be brough offline.
            If volume doesn't exist or is a tiered volume returns empty list
    """
    volume_bricks_to_bring_offline = []

    # Check if volume is tiered
    if is_tiered_volume(mnode, volname):
        return volume_bricks_to_bring_offline

    # get volume type
    volume_type_info = get_volume_type_info(mnode, volname)
    volume_type = volume_type_info['volume_type_info']['typeStr']

    # get subvols
    subvols_dict = get_subvols(mnode, volname)
    volume_subvols = subvols_dict['volume_subvols']

    # select bricks from distribute volume
    if volume_type == 'Distribute':
        volume_bricks_to_bring_offline = []

    # select bricks from replicated, distributed-replicated volume
    elif (volume_type == 'Replicate'
          or volume_type == 'Distributed-Replicate'):
        # Get replica count
        volume_replica_count = (
            volume_type_info['volume_type_info']['replicaCount'])

        # Get quorum info
        quorum_info = get_client_quorum_info(mnode, volname)
        volume_quorum_info = quorum_info['volume_quorum_info']

        # Get list of bricks to bring offline
        volume_bricks_to_bring_offline = (
            get_bricks_to_bring_offline_from_replicated_volume(
                volume_subvols, volume_replica_count, volume_quorum_info))

    # select bricks from Disperse, Distribured-Disperse volume
    elif (volume_type == 'Disperse' or volume_type == 'Distributed-Disperse'):

        # Get redundancy count
        volume_redundancy_count = (
            volume_type_info['volume_type_info']['redundancyCount'])

        # Get list of bricks to bring offline
        volume_bricks_to_bring_offline = (
            get_bricks_to_bring_offline_from_disperse_volume(
                volume_subvols, volume_redundancy_count))

    return volume_bricks_to_bring_offline
Example #2
0
def select_hot_tier_bricks_to_bring_offline(mnode, volname):
    """Randomly selects bricks to bring offline without affecting the cluster
    from a hot tier.

    Args:
        mnode (str): Node on which commands will be executed.
        volname (str): Name of the volume.

    Returns:
        list: On success returns list of bricks that can be brough offline
            from hot tier. If volume doesn't exist or is a non tiered volume
            returns empty list.
    """
    hot_tier_bricks_to_bring_offline = []

    # Check if volume is tiered
    if not is_tiered_volume(mnode, volname):
        return hot_tier_bricks_to_bring_offline

    # get volume type
    volume_type_info = get_volume_type_info(mnode, volname)
    hot_tier_type = volume_type_info['hot_tier_type_info']['hotBrickType']

    # get subvols
    subvols_dict = get_subvols(mnode, volname)
    hot_tier_subvols = subvols_dict['hot_tier_subvols']

    # select bricks from distribute volume
    if hot_tier_type == 'Distribute':
        hot_tier_bricks_to_bring_offline = []

    # select bricks from replicated, distributed-replicated volume
    if (hot_tier_type == 'Replicate'
            or hot_tier_type == 'Distributed-Replicate'):
        # Get replica count
        hot_tier_replica_count = (
            volume_type_info['hot_tier_type_info']['hotreplicaCount'])

        # Get quorum info
        quorum_info = get_client_quorum_info(mnode, volname)
        hot_tier_quorum_info = quorum_info['hot_tier_quorum_info']

        # Get list of bricks to bring offline
        hot_tier_bricks_to_bring_offline = (
            get_bricks_to_bring_offline_from_replicated_volume(
                hot_tier_subvols, hot_tier_replica_count,
                hot_tier_quorum_info))

    return hot_tier_bricks_to_bring_offline