監査用のOld EPM Cloud環境の再作成

この項のスクリプトを使用して、Oracle Enterprise Performance Management Cloud環境の最新のスナップショットのライブラリを保持するためのセルフサービス・ソリューションを作成します。最新のスナップショットのライブラリをアップグレードおよび保持する目的に特化した環境が必要です。

EPM Cloudは、1回の月次サイクルのみについてスナップショットの互換性をサポートしています。メンテナンス・スナップショットは、テスト環境から本番環境に移行することも、この逆に移行することもできます。ただし、一部の顧客は、監査要件のために、最新の環境で複数年のスナップショットを復元し、短時間のうちにアプリケーションにアクセスすることが必要な場合があります。

このスクリプトは、使用可能なスナップショットを変換し、これらをEPM Cloudの最新のパッチ・レベルと互換性を持たせるために、毎月1回実行するようスケジュールする必要があります。本番環境内のすべての問題を確実に解決するために、月の第3金曜日の後にスクリプトを実行することをお薦めします。

注:

このスクリプトを使用して、Narrative ReportingAccount ReconciliationおよびOracle Enterprise Data Management Cloudのスナップショットを更新することはできません。

スクリプトの仕組み

顧客によって格納されるスクリプトごとに、アップグレード・スクリプトによってEPM自動化を使用して次のタスクが実行されます。
  1. input.propertiesファイル内の情報を使用して、環境にログインします
  2. recreateコマンドを使用して、環境を改善します
  3. 環境にスナップショットをインポートします
  4. 環境に対して日次メンテナンスを実行します。この結果、スナップショットがEPM Cloudの現在のパッチ・レベルと互換性を持つフォーマットに変換されます。
  5. Artifact Snapshot (メンテナンス・スナップショット)をフォルダにダウンロードします。snapshots/18.05からスナップショットをアップロードすることによって18.05環境を再作成した場合、Artifact Snapshotsnapshots/18.06にダウンロードされます。
  6. 古い環境の再作成の結果を電子メール・アドレス(指定してある場合)に送信します。

スクリプトの実行

  1. input.propertiesファイルを作成し、環境の情報を使用して更新します。ファイルをローカル・ディレクトリに保存します。このディレクトリは、ここではparentsnapshotdirectoryと呼びます。このファイルのコンテンツは、オペレーティング・システムによって異なります。

    このディレクトリの書込み権限があることを確認してください。Windowsの場合、スクリプトを実行できるよう、「管理者として実行」オプションを使用してPowerShellを開始する必要があります。

  2. upgradeSnapshots.ps1 (Windows PowerShell)またはupgradeSnapshots.sh (Linux/UNIX)スクリプトを作成し、input.propertiesが格納されているparentsnapshotdirectory内に保存します。
  3. サブディレクトリ(snapshotsなど)をparentsnapshotdirectory内に作成します。
  4. 前の手順で作成したディレクトリ(snapshots)内で、EPM Cloudの現在のパッチ・レベルと互換性を持たせるために変換する月次スナップショットのサブディレクトリを作成します。YY.MM形式でディレクトリに名前を付けます。たとえば、2018年5月のスナップショットを格納するためのディレクトリの場合は、18.05とします。
  5. スナップショットを適切なサブディレクトリにコピーします。たとえば、2018年5月のスナップショットはsnapshots/18.05にコピーします。
  6. スクリプトを起動します。
    • Linux/UNIX: ./upgradeSnapshots.shを実行します。
    • Windows PowerShell: upgradeSnapshots.ps1を実行します。

Windows

ここでのスクリプトをコピーすることにより、input.propertiesおよびupgradeSnapshots.ps1スクリプトを作成します。

input.propertiesの作成

username=exampleAdmin
userpassword=examplePassword
serviceurl=exapleURL
proxyserverusername=proxyServerUserName
proxyserverpassword=proxyPassword
proxyserverdomain=proxyDoamin
parentsnapshotdirectory=C:/some_directory/snapshots
emailtoaddress=exampleAdmin@oracle.com

input.propertiesの更新

注:

authentication at proxy serverがWindowsのネットワーク環境に対して有効でない場合、プロパティproxyserverusernameproxyserverpasswordおよびproxyserverdomaininput.propertiesファイルから削除します。

表3-8 input.propertiesのパラメータ

パラメータ 説明
username サービス管理者のユーザー名
userpassword サービス管理者のパスワード。
serviceurl このアクティビティに使用する環境のURL。
proxyserverusername インターネットへのアクセスを制御するプロキシ・サーバーとの安全なセッションを認証するユーザー名。
proxyserverpassword プロキシ・サーバーに対してユーザーを認証するパスワード。
proxyserverdomain プロキシ・サーバーに定義されているドメインの名前。
parentsnapshotdirectory 処理対象のスナップショットが格納されるディレクトリの親ディレクトリとして使用するディレクトリの絶対パス。ディレクトリの区切りとしてスラッシュ(/)を使用してください。
emailtoaddress オプションで、古い環境の再作成の結果が送信される電子メール・アドレス。この値が指定されている場合のみ、結果が電子メールで送信されます。

例: john.doe@example.com

注:

パスワードに特殊文字が含まれている場合は、特殊文字の処理を参照してください。

upgradeSnapshots.ps1の作成

このサンプル・スクリプトを使用して、upgradeSnapshots.ps1を作成します

# Script for recreating an old EPM Cloud environment

# read in key/value pairs from input.properties file
$inputproperties=ConvertFrom-StringData(Get-Content ./input.properties -raw)

# Global variables
$parentsnapshotdirectory="$($inputproperties.parentsnapshotdirectory)"
$username="$($inputproperties.username)"
$userpassword="$($inputproperties.userpassword)"
$serviceurl="$($inputproperties.serviceurl)"
$proxyserverusername="$($inputproperties.proxyserverusername)"
$proxyserverpassword="$($inputproperties.proxyserverpassword)"
$proxyserverdomain="$($inputproperties.proxyserverdomain)"
$emailtoaddress="$($inputproperties.emailtoaddress)"
$operationmessage="EPM Automate operation:"
$operationfailuremessage="EPM Automate operation failed:"
$operationsuccessmessage="EPM Automate operation completed successfully:"
$epmautomatescript="epmautomate.bat"

$workingdir="$pwd"
$logdir="$workingdir/logs/"
$logfile="$logdir/epmautomate-upgradesnapshots.log"

function LogMessage 
{
    $message=$args[0]
    $_mydate=$(get-date -f dd_MM_yy_HH_mm_ss)

    echo "[$_mydate] $message" >> $logfile
}

function LogAndEchoMessage
{
    $message=$args[0]
    $_mydate=$(get-date -f dd_MM_yy_HH_mm_ss)

    echo "[$_mydate] $message" | Tee-Object -Append -FilePath $logfile
}

function LogOutput
{
    $_mydate=$(get-date -f dd_MM_yy_HH_mm_ss)
    $op=$args[0]
    $opoutput=$args[1]
    $returncode=$args[2]

    #If error
    if ($returncode -ne 0) {
        $failmessage="[$_mydate] $operationfailuremessage $op"
        LogMessage $failmessage
        LogMessage $opoutput
        LogMessage "return code: $returncode"
    } else { 
        $successmessage="[$_mydate] $operationsuccessmessage $op"
        LogMessage $successmessage
        LogMessage $opoutput
        LogMessage "return code: $returncode"
    }
}

function ExecuteCommand
{
    $op=$args[0]
    $epmautomatecall="$epmautomatescript $op"
    $date=$(get-date -f dd_MM_yy_HH_mm_ss)

    LogMessage "$operationmessage $epmautomatecall"
    $operationoutput=iex "& $epmautomatecall" >> $logfile 2>&1
    LogOutput $op $operationoutput $LastExitCode
}

function ProcessCommand
{
    $command=$args[0]
    $date=$(get-date -f dd_MM_yy_HH_mm_ss)

    if (!([string]::IsNullOrWhitespace($command))) {
        if (!($command.StartsWith("#"))) {
            ExecuteCommand $command
        }
    }
}

function Init
{
    $logdirexists=Test-Path $logdir
    if (!($logdirexists)) {
        mkdir $logdir 2>&1 | out-null
    }

    # removing existing epmautomate debug logs
    rm ./*.log

    $logfileexists=Test-Path $logfile
    # remove existing log file
    if ($logfileexists) {
        rm $logfile
    }
}

function GetNextDate
{
    $latestyearmonth=$args[0]
    LogMessage "latest year.month: $latestyearmonth"
    $latestyear,$latestmonth=$latestyearmonth.split('\.')
    LogMessage "latest year: $latestyear"
    LogMessage "latest month: $latestmonth"
    $intlatestyear=[int]$latestyear
    $intlatestmonth=[int]$latestmonth

    if ($intlatestmonth -eq 12) {
        $intnextmonth=1
        $intnextyear=$intlatestyear+1
    } else {
        $intnextmonth=$intlatestmonth+1
        $intnextyear=$intlatestyear
    }

    $nextyear="{0:D2}" -f $intnextyear
    $nextmonth="{0:D2}" -f $intnextmonth

    echo "$nextyear.$nextmonth"
}

function ProcessSnapshot
{
    $snapshotfile=$args[0]
    LogMessage "snapshotfile: $snapshotfile"
    $nextdate=$args[1]
    LogMessage "nextdate: $nextdate"
    $snapshotfilename=$snapshotfile.split('/')[-1]
    LogMessage "snapshotfilename: $snapshotfilename"
    $snapshotname=$snapshotfilename.split('.')[0]
    LogMessage "snapshotname: $snapshotname"

    ProcessCommand "login $username $userpassword $serviceurl $proxyserverusername $proxyserverpassword $proxyserverdomain"
    ProcessCommand "recreate -f"
    ProcessCommand "uploadfile $snapshotfile"
    ProcessCommand "importsnapshot $snapshotname"
    ProcessCommand "runDailyMaintenance skipNext=true -f"
    ProcessCommand "downloadfile 'Artifact Snapshot'"
    ProcessCommand "deletefile $snapshotname"
    ProcessCommand "logout"

    $nextdatedirexists=Test-Path $parentsnapshotdirectory/$nextdate
    if (!($nextdatedirexists)) {
        mkdir $parentsnapshotdirectory/$nextdate 2>&1 | out-null
    }

    LogMessage "Renaming 'Artifact Snapshot.zip' to $snapshotname.zip and moving to $parentsnapshotdirectory/$nextdate"
    mv $workingdir/'Artifact Snapshot.zip' $workingdir/$snapshotname.zip >> $logfile 2>&1
    mv $workingdir/$snapshotname.zip $parentsnapshotdirectory/$nextdate >> $logfile 2>&1
}

function callSendMail
{
    $logfile=$logfile -replace "\\", "/"
    $elements=$logfile.split('/')
    $logfilename=$elements[-1]

    if (${emailtoaddress} -match "@") {
        epmautomate.bat login ${username} ${userpassword} ${serviceurl}
        epmautomate.bat uploadFile "$logfile"
        epmautomate.bat sendMail $emailtoaddress "Recreating An Old EPM Cloud Environment results" Body="The results of recreating an old EPM Cloud Environment are attached." Attachments=$logfilename
        epmautomate.bat deleteFile "$logfilename"
        epmautomate.bat logout
    }
}

#----- main body of processing
date
Init
LogAndEchoMessage "Starting upgrade snapshots processing"
$snapshotdirs=@(Get-ChildItem -Directory "$parentsnapshotdirectory" -name)
LogMessage "snapshot directories: $snapshotdirs"
$latestreleasedate=$snapshotdirs[-1]
LogMessage "latest release date: $latestreleasedate"
$latestreleasesnapshotdir="$parentsnapshotdirectory/$latestreleasedate"
LogMessage "latest release snapshot dir: $latestreleasesnapshotdir"
$nextdate=$(GetNextDate "$latestreleasedate")
$snapshotfiles=@(Get-ChildItem -File "$latestreleasesnapshotdir")
if ($snapshotfiles.length -eq 0) {
    LogAndEchoMessage "No snapshot files found in directory $latestreleasesnapshotdir. Exiting script."
    exit
}
foreach ($snapshotfile in $snapshotfiles) {
    LogAndEchoMessage "Processing snapshotfile: $snapshotfile"
    ProcessSnapshot $latestreleasesnapshotdir/$snapshotfile $nextdate
}
LogAndEchoMessage "Upgrade snapshots processing completed"
date
callSendMail

Linux/UNIX

次のスクリプトをコピーしてupgradeSnapshots.shおよびinput.propertiesを作成します。

Linux/UNIXのinput.propertiesの作成

注:

インターネットにアクセスするためにプロキシ・サーバーを使用するようネットワークが構成されていない場合、input.propertiesファイルからプロパティproxyserverusernameproxyserverpasswordおよびproxyserverdomainを削除します。

username=exampleAdmin
userpassword=examplePassword
serviceurl=exapleURL
proxyserverusername=
proxyserverpassword=
proxyserverdomain=
jdkdir=/home/user1/jdk160_35
epmautomatescript=/home/exampleAdmin/epmautomate/bin/epmautomate.sh
parentsnapshotdirectory=/home/exampleAdmin/some_directory/snapshots
emailtoaddress=exampleAdmin@oracle.com

input.propertiesの更新

表3-9 input.propertiesのパラメータ

パラメータ 説明
username サービス管理者のユーザー名
userpassword サービス管理者のパスワード。
serviceurl このアクティビティに使用する環境のURL。
proxyserverusername インターネットへのアクセスを制御するプロキシ・サーバーとの安全なセッションを認証するユーザー名。
proxyserverpassword プロキシ・サーバーに対してユーザーを認証するパスワード。
proxyserverdomain プロキシ・サーバーに定義されているドメインの名前。
jdkdir JAVA_HOMEの場所。
epmautomatescript EPM自動化の実行可能ファイル(epmautomate.sh)の絶対パス。
parentsnapshotdirectory 処理対象のスナップショットが格納されるディレクトリの親ディレクトリとして使用するディレクトリの絶対パス。
emailtoaddress オプションで、古い環境の再作成の結果が送信される電子メール・アドレス。

注:

パスワードに特殊文字が含まれている場合は、特殊文字の処理を参照してください。

upgradeSnapshots.shの作成

このサンプル・スクリプトを使用して、upgradeSnapshots.shを作成します

#!/bin/sh

. ./input.properties
workingdir=$(pwd)
logdir="${workingdir}/logs"
logfile=epmautomate-upgradesnapshots.log
operationmessage="EPM Automate operation:"
operationfailuremessage="EPM Automate operation failed:"
operationsuccessmessage="EPM Automate operation completed successfully:"
logdebugmessages=true

if [ ! -d ${jdkdir} ]
then 
    echo "Could not locate JDK/JRE. Please set value for "jdkdir" property in input.properties file to a valid JDK/JRE location."
    exit
fi

if [ ! -f ${epmautomatescript} ]
then 
    echo "Could not locate EPM Automate script. Please set value for "epmautomatescript" property in the input.properties file."
    exit
fi

export JAVA_HOME=${jdkdir}

debugmessage() {
    # logdebugmessages is defined (or not) in testbase input.properties
    if [ "${logdebugmessages}" = "true" ]
    then
        logmessage "$1"
    fi
}

logmessage() 
{
    local message=$1
    local _mydate=$(date)

    echo "[$_mydate] ${message}" >> "$logdir/$logfile"
}

echoandlogmessage() 
{
    local message=$1
    local _mydate=$(date)

    echo "[$_mydate] ${message}" | tee -a ${logdir}/${logfile}
}

logoutput()
{
    date=`date`
    op="$1"
    opoutput="$2"
    returncode="$3"

    #If error
    #if grep -q "EPMAT-" <<< "$2"
    if [ $returncode -ne 0 ]
    then
        failmessage="[${date}] ${operationfailuremessage} ${op}"
        logmessage "${failmessage}"
        logmessage "${opoutput}"
        logmessage "return code: ${returncode}"
    else
        successmessage="${operationsuccessmessage} ${op}"
        logmessage "${successmessage}"
        logmessage "${opoutput}"
        logmessage "return code: ${returncode}"
    fi
}

getLatestReleaseSnapshotDir()
{
    local snapshotdirs=$(find ${parentsnapshotdirectory} -type d | sort)
    debugmessage "snapshot directories: ${snapshotdirs}"
    local latestreleasesnapshotdir=$(echo ${snapshotdirs##*$\n} | rev | cut -d' ' -f1 | rev)
    debugmessage "latest release snapshot dir: ${latestreleasesnapshotdir}"
    echo "${latestreleasesnapshotdir}"
}

getNextDate()
{
    local thisyearmonth=$1
    local thisyear=$(echo ${thisyearmonth} | cut -d'.' -f1)
    local thismonth=$(echo ${thisyearmonth} | cut -d'.' -f2)

    intthismonth=$(bc <<< ${thismonth})
    intthisyear=$(bc <<< ${thisyear})

    if [ ${intthismonth} -eq 12 ]
    then
        local intnextmonth=1
        local intnextyear=$((intthisyear+1))
    else 
        local intnextmonth=$((intthismonth+1))
        local intnextyear=${intthisyear}
    fi
    
    nextmonth=$(printf "%02d\n" ${intnextmonth})
    nextyear=$(printf "%02d\n" ${intnextyear})

    debugmessage "next date: ${nextyear}.${nextmonth}"

    echo "${nextyear}.${nextmonth}"
}

init()
{
    if [ ! -d "$logdir" ]
    then
        mkdir $logdir
    fi

    # removing existing epmautomate debug logs
    if ls ./*.log >/dev/null 2>&1
    then
       rm ./*.log
    fi

    # remove existing log files
    if [ -f "${logdir}/${logfile}" ]
    then
        rm ${logdir}/${logfile}
    fi
}

processCommand()
{
    op="$1"
    date=`date`

    logmessage "$operationmessage $op"
    operationoutput=`eval "$epmautomatescript $op"`
    logoutput "$op" "$operationoutput" "$?"
}

processSnapshot()
{
    local snapshotfile="$1"
    local nextdate="$2"
    local snapshotname=$(echo "${snapshotfile}" | rev | cut -d'/' -f1 | rev | cut -d'.' -f1)

    processCommand "login ${username} ${userpassword} ${serviceurl} ${proxyserverusername} ${proxyserverpassword}"
    processCommand "recreate -f"
    processCommand "uploadfile ${snapshotfile}"
    processCommand "importsnapshot \"${snapshotname}\""
    processCommand "runDailyMaintenance skipNext=true -f"
    processCommand "downloadfile \"Artifact Snapshot\""
    processCommand "deletefile \"${snapshotname}\""
    processCommand "logout"

    if [ ! -d ${parentsnapshotdirectory}/${nextdate} ]
    then
        mkdir ${parentsnapshotdirectory}/${nextdate}
    fi
runDailyMaintenance -f
    logmessage "Renaming \"Artifact Snapshot.zip\" to ${snapshotname}.zip and moving to ${parentsnapshotdirectory}/${nextdate}"
    mv "${workingdir}/Artifact Snapshot.zip" "${workingdir}/${snapshotname}.zip" >> "$logdir/$logfile" 2>&1
    mv "${workingdir}/${snapshotname}.zip" ${parentsnapshotdirectory}/${nextdate} >> "$logdir/$logfile" 2>&1
}

callSendMail() {

    if [[ "${emailtoaddress}" == *"@"* ]]
    then
        ${epmautomatescript} login ${username} ${userpassword} ${serviceurl}
        ${epmautomatescript} uploadFile "$logdir/$logfile"
        ${epmautomatescript} sendMail $emailtoaddress "Recreating An Old EPM Cloud Environment results" Body="The results of recreating an old EPM Cloud Environment are attached" Attachments=$logfile
        ${epmautomatescript} deleteFile "$logfile"
        ${epmautomatescript} logout
    fi
}

#----- main body of processing
date
echoandlogmessage "Starting upgrade snapshots processing"
init
latestreleasesnapshotdir=$(getLatestReleaseSnapshotDir)
latestreleasedate=$(echo "${latestreleasesnapshotdir}" | rev | cut -d'/' -f1 | rev)
debugmessage "latest release date: ${latestreleasedate}"
nextdate=$(getNextDate ${latestreleasedate})

snapshotfiles=$(find ${latestreleasesnapshotdir} -type f -name \*.zip | tr "\n" "|")
if [ ${#snapshotfiles} -eq 0 ]
then
    echoandlogmessage "No snapshot files found in directory ${latestreleasesnapshotdir}"
fi

IFS="|"
for snapshotfile in $snapshotfiles
do
    echoandlogmessage "Processing snapshotfile: ${snapshotfile}"
    processSnapshot ${snapshotfile} ${nextdate}
done
unset IFS
echoandlogmessage "Upgrade snapshots processing completed."
callSendMail