Changing the plan size of the Cognos Analytics service instance

Change the plan size of the Cognos® Analytics service instance after you already provisioned an instance of Cognos Analytics.

You can change the size of an existing instance without having to provision a new instance. For example, you provisioned an instance of Cognos Analytics and you later decide that you want to increase or decrease the size of the instance due to resource requirements.

Synopsis

scale_instance.sh [-h] -t tethered_namespace -p fixedminimum | small | small_mincpureq | medium | large

Options

-p fixedminimum | small | small_mincpureq | medium | large
The new size of the Cognos Analytics service instance.
-t tethered_namespace
Tethered namespace or project in which you intend to scale the instance.
-h
Prints help to the console and exits.

Example

The following example increases the size of your Cognos Analytics service instance to large:

./scale_instance.sh -t NAMESPACE -p large

Script file

The scale_instance.sh script is a file with the following contents:

#!/usr/bin/env bash
#
# -----------------------------------------------------------------------------
#         Licensed Materials - Property of IBM
#
#         IBM Cognos Products: ca
#
#         (C) Copyright IBM Corp. 2022
#
#         US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule
# -----------------------------------------------------------------------------
#
#

#set -e
#set -x

check_status=""

function isValidPlan {
    if [[ "$1" != "" ]] && [[ "$1" != "fixedminimum" ]] && [[ "$1" != "small" ]] && [[ "$1" != "small_mincpureq" ]] && [[ "$1" != "medium" ]] && [[ "$1" != "large" ]]; then
        echo "Invalid plan specified: $1."
        echo "Expected one of: fixedminimum, small, small_mincpureq, medium or large"
        exit 1
    fi
}

function usage {
    echo $0: usage: $0 [-h] -t tethered namespace -p plan-size
}

function help {
    usage
    echo "-h                    prints help to the console"
    echo "-t tethered namespace namespace to scale (required)"
    echo "-p plan size          plan size, one of fixedminimum, small, small_mincpureq, medium or large (required)"
    echo ""
    exit 0
}

while getopts ":ht:p:" opt; do
     case ${opt} in
     h)
        help
        ;;
     t)
        namespace=$OPTARG
        ;;
     p)
        plan_size=$OPTARG
        ;;
     \?)
        usage
        exit 0
        ;;
     esac
done

if [ -z $namespace ]; then
    echo "A tethered namespace must be provided"
    help
fi

if [ -z $plan_size ]; then
    echo "A plan size must be provided"
    help
fi

isValidPlan $plan_size

cr_name=$(oc -n ${namespace} get caserviceinstance --no-headers -o custom-columns=NAME:.metadata.name)

if [ -z $cr_name ]; then
    echo "Unable to find CAServiceInstance CR for namespace: ${namespace}"
    help
fi

echo "Scaling plan: ${cr_name} ..."
oc patch caserviceinstance ${cr_name} --type merge -p "{\"spec\":{\"plan_size\":\"${plan_size}\"}}" -n ${namespace}
check_status="Completed"

sleep 20

# Checking status of ca shutdown action
for i in {1..240};do
    caStatus=$(oc get caserviceinstance ${cr_name} -o jsonpath="{.status.caStatus}" -n ${namespace})

    if [[ ${caStatus} == ${check_status} ]];then
        echo "ca ${check_status} Successfully"
        break
    elif [[ ${caStatus} == "Failed" ]];then
        echo "ca ${caStatus}!"
        exit 1
    fi
    echo "ca Status: ${caStatus}"
    sleep 30
done