レポート出力を'Cognos Analyticsサービスインスタンスのファイルシステムに保存する

Cognos Analyticsサービスインスタンスからのレポート出力ファイルをファイルシステムの場所に保存する。

レポート出力をファイルの場所に保存できるようにするには、以下の操作を行う必要があります:
  1. create_savetofilesystem_pvc.shスクリプトを使用して、必要な名前、ストレージ・クラス、サイズの永続ボリューム・クライム(PVC)を作成します。
  2. enable_savetofilesystem.shスクリプトでファイルシステムへの保存機能を有効にする。
  3. レポート出力ファイルの場所を追加します。
この機能を有効にした後、以下のオプション・アクションのいずれかを実行するとよいでしょう:

永続ボリューム・クレームの作成

Cognos Analyticsサービス・インスタンスがインストールされているネームスペースに、必要な名前、ストレージ・クラス、サイズのPVCを作成するには、create_savetofilesystem_pvc.shスクリプトを使用する。

概要

create_savetofilesystem_pvc.sh[-h] '-t tethered_namespace'-p pvc_name'-s pvc_storageclass'-g storage_size

オプション
-t tethered_namespace
Cognos Analyticsインスタンスがプロビジョニングされているテザーネームスペースまたはプロジェクト。
-p pvc_name
PVCの名称。
-s pvc_storageclass

ストレージ・クラスは Filesystem 型でなければならない。

-g ストレージサイズ
Gi単位のストレージサイズ。
-h
コンソールにヘルプを表示して終了する。

以下の例では、名前空間 'cpd-instanceに、名前 'fileoutput、ストレージ・クラス 'managed-nfsv3-storage、サイズ '200Gi の PVC を作成している。

./create_savetofilesystem_pvc.sh -t cpd-instance -p fileoutput -s managed-nfsv3-storage -g 200
スクリプト・ファイル

create_savetofilesystem_pvc.shスクリプトは、以下の内容のファイルである:

#!/usr/bin/env bash
#
# -----------------------------------------------------------------------------
#         Licensed Materials - Property of IBM
#
#         IBM Cognos Products: ca
#
#         (C) Copyright IBM Corp. 2024
#
#         US Government Users Restricted Rights - Use, duplication or disclosure restricted by
#         GSA ADP Schedule
# -----------------------------------------------------------------------------
#
#
set -e
#set -x
function usage {
    echo "$0: usage: $0 [-h] -t namespace -s storageclass -p persistentvolumeclaim"
    echo "-g storage_size [-v]"
}

function help {
    usage
    echo "-h                    Prints help to the console and exits."
    echo "-t                    Namespace in which Cognos Analytics is provisioned. (required)"
    echo "-s                    Storage class for creating persistent volume. (required)"
    echo "-p                    Name of the persistent volume claim. (required)"
    echo "-g                    Size of the storage, in Gi. (required)"
    echo "-v                    Enables verbose mode"
    echo ""
    exit 0
}

while getopts ":ht:s:p:g:v" opt; do
     case ${opt} in
     h)
        help
        ;;
     t)
        tethered_namespace=$OPTARG
        ;;
     s)
        storage_class=$OPTARG
        ;;
     p)
        pvc_name=$OPTARG
        ;;
     g)
        storage_size=$OPTARG
        ;;
     v)
        verbose_flag="true"
        ;;
     \?)
        usage
        exit 0
        ;;
     esac
done

if [[ -z ${tethered_namespace} ]]; then
    echo "A namespace must be provided"
    help
fi
if [[ -z ${storage_class} ]]; then
    echo "A storage class must be provided"
    help
fi
if [[ -z ${pvc_name} ]]; then
    echo "A persistent volume name must be provided"
    help
fi
if [[ -z ${storage_size} ]]; then
    echo "A storage size must be provided e.g. 100"
    help
fi

#verify oc command is available
command -v oc 2>&1 >/dev/null
if [ $? -ne 0 ]; then
  echo "Openshift Client oc command is not available."
  exit 1
fi
#verify cluster login is valid
echo "Verifying user logged in to cluster:"
oc whoami
if [ $? -ne 0 ]; then
        echo "Please login to cluster first.  Exiting..."
        exit 1
fi

oc cluster-info

echo "Current List of PVC's under namespace: $tethered_namespace"
oc get pvc -n $tethered_namespace

echo "Create PVC ${pvc_name} in ${tethered_namespace}.."

# Create a PVC
cat << EOF | oc create -f -
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ${pvc_name}
  namespace: ${tethered_namespace}
  labels:
    save_to_filesystem_support: true
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: ${storage_size}Gi
  storageClassName: ${storage_class}
  volumeMode: Filesystem
EOF
sleep 10

check_status="Bound"
# Checking status of pvc
for i in {1..12};do
    pvcStatus=$(oc get pvc ${pvc_name} -o jsonpath="{.status.phase}" -n ${tethered_namespace})
    if [[ ${pvcStatus} == ${check_status} ]];then
        echo "pvc status:${pvcStatus} "
        break
    elif [[ ${pvcStatus} == "Pending" ]];then
        echo "pvc status: ${pvcStatus}! please check the PVC:$pvc_name Events.."
        EVENTS=$(oc describe pvc $pvc_name -n ${tethered_namespace} | grep 'Events')
        echo "$EVENTS"
        echo "Execute this command to delete PVC $pvc_name..."
        echo oc delete pvc $pvc_name -n $tethered_namespace
        exit 1
    fi
    sleep 30
done

echo "PVC $pvc_name added..."
oc get pvc $pvc_name -n $tethered_namespace

ファイルシステムへの保存機能を有効にする

Cognos AnalyticsインスタンスがプロビジョニングされているネームスペースのPVCで機能を有効にするには、enable_savetofilesystem.shスクリプトを使用します。 この機能を有効にすると、ネームスペース内の「Cognos Analyticsコンテナが再起動される。

概要

enable_savetofilesystem.sh[-h] '-t tethered_namespace'-p pvc_name[-v]。

オプション
-t tethered_namespace
Cognos Analyticsインスタンスがプロビジョニングされているテザーネームスペースまたはプロジェクト。
-p pvc_name
PVCの名称。
-v
冗長モードを使用可能にします。
-h
コンソールにヘルプを表示して終了する。

以下の例では、名前空間 'cpd-instance内の 'Cognos Analyticsインスタンス内の名前 'fileoutputの PVC に対して、ファイルシステムへの保存機能を有効にしている。

./enable_savetofilesystem.sh -t cpd-instance -p fileoutput
スクリプト・ファイル

enable_savetofilesystem.shスクリプトは、以下の内容のファイルである:

#!/usr/bin/env bash
#
# -----------------------------------------------------------------------------
#         Licensed Materials - Property of IBM
#
#         IBM Cognos Products: ca
#
#         (C) Copyright IBM Corp. 2024
#
#         US Government Users Restricted Rights - Use, duplication or disclosure restricted by
#         GSA ADP Schedule
# -----------------------------------------------------------------------------
#
#
set -e
#set -x
function usage {
    echo $0: usage: $0 [-h] -t tethered_namespace -p persistentvolumeclaim [-v]
}

function help {
    usage
    echo "-h                    Prints help to the console and exits."
    echo "-t                    Namespace in which Cognos Analytics is provisioned. (required)"
    echo "-p                    Name of the persistent volume claim. (required)"
    echo "-v                    Enables verbose mode."
    echo ""
    exit 0
}

while getopts ":ht:p:v" opt; do
     case ${opt} in
     h)
        help
        ;;
     t)
        tethered_namespace=$OPTARG
        ;;
     p)
        pvc_name=$OPTARG
        ;;
     v)
        verbose_flag="true"
        ;;
     \?)
        usage
        exit 0
        ;;
     esac
done

if [[ -z ${tethered_namespace} ]]; then
    echo "A namespace must be provided"
    help
fi
if [[ -z ${pvc_name} ]]; then
    echo "A pvc name must be provided"
    help
fi

#verify oc command is available
command -v oc 2>&1 >/dev/null
if [ $? -ne 0 ]; then
  echo "Openshift Client oc command is not available."
  exit 1
fi
#verify cluster login is valid
echo "Verifying user logged in to cluster:"
oc whoami
if [ $? -ne 0 ]; then
        echo "Please login to cluster first.  Exiting..."
        exit 1
fi
oc cluster-info

echo "Checking the PVC $pvc_name is in a Bound State..."
check_status="Bound"
# Checking status of pvc
for i in {1..12};do
    pvcStatus=$(oc get pvc ${pvc_name} -o jsonpath="{.status.phase}" -n ${tethered_namespace})
    if [[ ${pvcStatus} == ${check_status} ]];then
        echo "pvc status:${pvcStatus} "
        break
    elif [[ ${pvcStatus} == "Pending" ]];then
        echo "PVC status: ${pvcStatus}! Please check the PVC $pvc_name Events..."
        EVENTS=$(oc describe pvc $pvc_name -n ${tethered_namespace} | grep 'Events')
        echo "$EVENTS"
        echo "Execute this command to delete PVC $pvc_name..."
        echo oc delete pvc $pvc_name -n $tethered_namespace
        exit 1
    fi
    sleep 30
done

echo "Patching the CR to update the pvc...."
cr_name=$(oc -n ${tethered_namespace} get caserviceinstance --no-headers \
-o custom-columns=NAME:.metadata.name)
if [[ -z ${cr_name} ]]; then
    echo "Unable to find CAServiceInstance CR for namespace: ${tethered_namespace}"
    help
fi
echo "Adding cogSaveToFilesystem pvc name: ${pvc_name} to the Custom Resource ${cr_name}..."
oc patch caserviceinstance ${cr_name} --type merge \
-p "{\"spec\":{\"cogSaveToFilesystemPVCName\":\"${pvc_name}\"}}" -n ${tethered_namespace}
sleep 20

check_status="Completed"
# Checking status of ca reconcile action
for i in {1..240};do
    caStatus=$(oc get caserviceinstance ${cr_name} \
    -o jsonpath="{.status.caStatus}" -n ${tethered_namespace})
    if [[ ${caStatus} == ${check_status} ]];then
        echo "ca ${check_status} Successfully"
        break
    elif [[ ${caStatus} == "Failed" ]];then
        echo "ca ${caStatus}!"
        echo "Remove cogSaveToFilesystemPVCName value from custom resource to revert change"
        oc patch caserviceinstance ${cr_name} -n ${tethered_namespace} --type=json \
        --patch "[{"op": "remove", "path":"/spec/cogSaveToFilesystemPVCName"}]"
        exit 1
    fi
    echo "ca Status: ${caStatus}"
    sleep 30
done

レポート出力ファイルの場所の追加

インスタンス管理者はファイルの場所を設定する必要があります。

レポートを実行またはスケジュールする際に、レポート配信方法としてレポートを外部ファイルとして保存を選択した場合、レポート出力ファイルはこの場所に保存されます。

詳細については、「Cognos Analyticsドキュメントの「 Saving report output files outside ofIBM Cognossoftware」トピックの手順のステップ3を参照してください。

ファイルシステムへの保存機能を無効にする

Cognos AnalyticsインスタンスがプロビジョニングされているネームスペースのPVCでこの機能を無効にするには、disable_savetofilesystem.shスクリプトを使用します。 この機能を無効にすると、ネームスペース内の「Cognos Analyticsコンテナは再起動される。

概要

disable_savetofilesystem.sh[-h] '-t tethered_namespace[-v]。

オプション
-t tethered_namespace
Cognos Analyticsインスタンスがプロビジョニングされているテザーネームスペースまたはプロジェクト。
-v
冗長モードを使用可能にします。
-h
コンソールにヘルプを表示して終了する。

次の例は、名前空間 'cpd-instanceのインスタンス 'Cognos Analyticsファイルシステムへの保存機能を無効にします。

./disable_savetofilesystem.sh -t cpd-instance
スクリプト・ファイル

disable_savetofilesystem.shスクリプトは、以下の内容のファイルである:

#!/usr/bin/env bash
#
# -----------------------------------------------------------------------------
#         Licensed Materials - Property of IBM
#
#         IBM Cognos Products: ca
#
#         (C) Copyright IBM Corp. 2024
#
#         US Government Users Restricted Rights - Use, duplication or disclosure restricted by
#         GSA ADP Schedule
# -----------------------------------------------------------------------------
#
#
set -e
#set -x
function usage {
    echo $0: usage: $0 [-h] -t tethered_namespace -p persistentvolumeclaim [-v]
}

function help {
    usage
    echo "-h                    Prints help to the console and exits."
    echo "-t                    Namespace in which Cognos Analytics is provisioned. (required)"
    echo "-v                    Enables verbose mode."
    echo ""
    exit 0
}

while getopts ":ht:v" opt; do
     case ${opt} in
     h)
        help
        ;;
     t)
        tethered_namespace=$OPTARG
        ;;
     v)
        verbose_flag="true"
        ;;
     \?)
        usage
        exit 0
        ;;
     esac
done

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

#verify oc command is available
command -v oc 2>&1 >/dev/null
if [ $? -ne 0 ]; then
  echo "Openshift Client oc command is not available."
  exit 1
fi
#verify cluster login is valid
echo "Verifying user logged in to cluster:"
oc whoami
if [ $? -ne 0 ]; then
        echo "Please login to cluster first.  Exiting..."
        exit 1
fi
oc cluster-info

echo "Verify CR in namespace to remove the cogSaveToFilesystemPVCName ..."
cr_name=$(oc -n ${tethered_namespace} get caserviceinstance --no-headers \
-o custom-columns=NAME:.metadata.name)
if [[ -z ${cr_name} ]]; then
    echo "Unable to find CAServiceInstance CR for namespace: ${tethered_namespace}"
    help
fi
echo "Patching custom resource to revert changes done..."
oc patch caserviceinstance ${cr_name} -n ${tethered_namespace} --type=json \
--patch "[{"op": "remove", "path": "/spec/cogSaveToFilesystemPVCName"}]"
sleep 20

check_status="Completed"
# Checking status of ca reconcile action
for i in {1..240};do
    caStatus=$(oc get caserviceinstance ${cr_name} \
    -o jsonpath="{.status.caStatus}" -n ${tethered_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

PVCサイズの管理

Cognos Analyticsインスタンス・サービスからレポート出力ファイルを保存するためのPVCを以下の手順で拡大することができます:
  1. 同じネームスペースで、create_savetofilesystem_pvc.shを使用して2つ目のPVCを作成する。
  2. このPVCに新しい名前を付けて、enable_savetofilesystem.shスクリプトを実行する。
  3. オプション:古いPVCのコンテンツを新しいPVCにコピーしたい場合は、古いPVCと新しいPVCをマウントし、コンテンツをコピーするジョブをネームスペースに作成します。
  4. オプション:古いPVCにレポート出力を残したくない場合は、これを削除してください。