使用本節中的指令碼建立自助解決方案以略過更新,以便在測試週期為 6 週的情況下每季更新 Oracle Enterprise Performance Management Cloud 環境。在此案例中,生產環境會在測試環境 6 週之後更新。
預設情況下,EPM Cloud 會將您的環境套用每月更新。您可以使用skipUpdate命令跳過將每月更新套用到環境或檢視目前略過更新要求。您可以使用本節中包含的指令碼自動手動執行 skipUpdate
命令。這些指令碼會自動執行略過更新程序,這樣每季套用更新時,會進行為期 6 週的測試週期。
Note:
範例案例:測試環境更新週期設定為 2 月 (24.02 更新)、5 月 (24.05 更新)、8 月 (24.08 更新) 和 11 月 (24.11 更新) 的第一個星期五。「生產環境」會在 3 月 (24.02 更新) 第 3 個星期五更新為在 2 月 (24.02 更新) 第 1 個星期五更新測試環境時使用的版本。生產環境的類似更新將在 6 月 (24.05 更新)、9 月 (24.08 更新) 和 12 月 (24.11 更新) 第 3 週進行。在此案例中,生產環境不會更新為目前的更新,而是更新為測試環境上目前的更新。
Windows 範例指令碼
透過複製下列指令碼以建立skip_update.ps1
。將它儲存至本機目錄。請參閱執行指令碼,瞭解如何執行此指令碼:
# Skip Update PowerShell script $inputproperties = ConvertFrom-StringData(Get-Content ./input.properties -raw) $username="$($inputproperties.username)" $password="$($inputproperties.password)" $url="$($inputproperties.url)" $updateversions="$($inputproperties.updateversions)" $podtype="$($inputproperties.podtype)" $proxyserverusername="$($inputproperties.proxyserverusername)" $proxyserverpassword="$($inputproperties.proxyserverpassword)" $proxyserverdomain="$($inputproperties.proxyserverdomain)" echo "Starting skip_update.ps1 script." $monthsarr = ("01","02","03","04","05","06","07","08","09","10","11","12") $global:monthsarrfromcurrent = @() $global:yearsarrfromcurrent = @() $updateversionsarr = $updateversions.Split(",") $currentyear=Get-Date -Format yy $currentmonth=Get-Date -Format MM $nextyear=[int]$currentyear+1 function populateFromCurrentArrays() { $startposition = 0 for ($i = 0; $i -le ($monthsarr.length - 1); $i++) { if (${currentmonth} -eq $monthsarr[$i]) { if (${podtype} -eq "prod") { if (${updateversionsarr} -contains ${currentmonth}) { $startposition=$i-2 } else { $startposition=$i-1 } } else { if (${updateversionsarr} -contains ${currentmonth}) { $startposition=$i } else { $startposition=$i-1 } } break } } if (${startposition} -lt 0) { $startposition=$startposition+12 } for ($i = 0; $i -le ($monthsarr.length - 1); $i++) { if (${i} -ge ${startposition}) { $global:monthsarrfromcurrent += $monthsarr[$i] $global:yearsarrfromcurrent += $currentyear } } for ($i = 0; $i -le ($monthsarr.length - 1); $i++) { if (${i} -lt ${startposition}) { $global:monthsarrfromcurrent += $monthsarr[$i] $global:yearsarrfromcurrent += $nextyear } } } function skipUpdateAdd($yearnumber, $monthnumber) { echo "Running: epmautomate.bat skipUpdate add version=${yearnumber}.${monthnumber} comment=`"adding skipUpdate`"" epmautomate skipUpdate add version=${yearnumber}.${monthnumber} comment="adding skipUpdate" } function processSkipUpdates() { $addcount = 0 $countlimit = 0 if (${podtype} -eq "prod") { $countlimit = 3 } else { $countlimit = 2 } if ((${proxyserverusername} -eq "") -And (${proxyserverpassword} -eq "") -And (${proxyserverdomain} -eq "")) { echo "Running: epmautomate.bat login ${username} ${password} ${url}" epmautomate login ${username} ${password} ${url} } else { echo "Running: epmautomate.bat login ${username} ${password} ${url} ProxyServerUserName=${proxyserverusername} ProxyServerPassword=${proxyserverpassword} ProxyServerDomain=${proxyserverdomain}" epmautomate login ${username} ${password} ${url} ProxyServerUserName=${proxyserverusername} ProxyServerPassword=${proxyserverpassword} ProxyServerDomain=${proxyserverdomain} } echo "Running: epmautomate.bat skipUpdate remove" epmautomate skipUpdate remove for ($i = 0; $i -le ($global:monthsarrfromcurrent.length - 1); $i++) { $match = 1 if (${addcount} -eq ${countlimit}) { echo "Update calls are completed. No more will be attempted." break } for ($j = 0; $j -le ($updateversionsarr.length - 1); $j++) { if ((${currentmonth} -eq $updateversionsarr[$j]) -And (${addcount} -gt 0)) { $match = 1 break } if (($global:monthsarrfromcurrent[$i] -eq $updateversionsarr[$j]) -And (${addcount} -eq 0)){ $match = 0 break } } if (${match} -eq 1) { skipUpdateAdd $global:yearsarrfromcurrent[$i] $global:monthsarrfromcurrent[$i] $addcount += 1 } } echo "Running: epmautomate.bat skipUpdate list" epmautomate skipUpdate list echo "Running: epmautomate.bat logout" epmautomate logout } function compareUpdateMonths($thismonth, $nextmonth) { $nextmonthorig=${nextmonth} if (${nextmonth} -lt ${thismonth}) { $nextmonth+=12 } $monthdiff = $nextmonth - $thismonth if (${monthdiff} -gt 4) { echo "There are more than 3 versions skipped from version ${thismonth} to version ${nextmonthorig}. Please correct updateversions in input.properties so that there are not more than three versions skipped between each update version. Exiting." exit 1 } } function validateUpdateVersions() { for ($i = 0; $i -le ($updateversionsarr.length - 1); $i++) { $nextint = $i + 1 $thisupdatemonth = $updateversionsarr[$i] $thisupdatemonthint=[int]$thisupdatemonth $nextupdatemonth=$updateversionsarr[$nextint] $nextupdatemonthint=[int]$nextupdatemonth if (${nextupdatemonth} -eq "") { $nextupdatemonth=$updateversionsarr[0] $nextupdatemonthint=[int]$nextupdatemonth } compareUpdateMonths $thisupdatemonthint $nextupdatemonthint } } validateUpdateVersions populateFromCurrentArrays processSkipUpdates
Linux/UNIX 範例指令碼
透過複製下列指令碼以建立skip_update.sh
。將它儲存至本機目錄。請參閱執行指令碼,瞭解如何執行此指令碼:
#!/bin/sh . ./input.properties echo "Starting skip_update.sh script." export JAVA_HOME=${javahome} declare -a monthsarr=(01 02 03 04 05 06 07 08 09 10 11 12) declare -a monthsarrfromcurrent declare -a yearsarrfromcurrent updateversionsarr=( $(echo "${updateversions}" | sed 's/,/ /g') ) currentyear=$(date +%y) nextyear=$((currentyear+1)) currentmonth=$(date +%m) populateFromCurrentArrays() { local startposition=0 for i in ${!monthsarr[@]} do if [[ "${currentmonth}" == "${monthsarr[$i]}" ]] then if [[ "${podtype}" == "prod" ]] then if [[ ${updateversionsarr[@]} =~ ${currentmonth} ]] then startposition=$((i-2)) else startposition=$((i-1)) fi break else if [[ ${updateversionsarr[@]} =~ ${currentmonth} ]] then startposition=$i else startposition=$((i-1)) fi break fi fi done if [[ ${startposition} -lt 0 ]] then startposition=$((startposition+12)) fi for i in ${!monthsarr[@]} do if [[ ${i} -ge ${startposition} ]] then monthsarrfromcurrent=("${monthsarrfromcurrent[@]}" "${monthsarr[$i]}") yearsarrfromcurrent=("${yearsarrfromcurrent[@]}" "${currentyear}") fi done for i in ${!monthsarr[@]} do if [[ ${i} -lt ${startposition} ]] then monthsarrfromcurrent=("${monthsarrfromcurrent[@]}" "${monthsarr[$i]}") yearsarrfromcurrent=("${yearsarrfromcurrent[@]}" "${nextyear}") fi done } skipUpdateAdd() { local yearnumber="$1" local monthnumber="$2" echo "Running: ${epmautomatescript} skipUpdate add version=${yearnumber}.${monthnumber} comment=\"adding skipUpdate\"" ${epmautomatescript} skipUpdate add version=${yearnumber}.${monthnumber} comment="adding skipUpdate" } processSkipUpdates() { local addcount=0 local countlimit=0 if [[ "${podtype}" == "prod" ]] then countlimit=3 else countlimit=2 fi if [[ "${proxyserverusername}" == "" ]] && [[ "${proxyserverpassword}" == "" ]] && [[ "${proxyserverdomain}" == "" ]] then echo "Running: ${epmautomatescript} login ${username} ${password} ${url}" ${epmautomatescript} login ${username} ${password} ${url} else echo "Running: ${epmautomatescript} login ${username} ${password} ${url} ProxyServerUserName=${proxyserverusername} ProxyServerPassword=${proxyserverpassword} ProxyServerDomain=${proxyserverdomain}" ${epmautomatescript} login ${username} ${password} ${url} ProxyServerUserName=${proxyserverusername} ProxyServerPassword=${proxyserverpassword} ProxyServerDomain=${proxyserverdomain} fi echo "Running: ${epmautomatescript} skipUpdate remove" ${epmautomatescript} skipUpdate remove for i in ${!monthsarrfromcurrent[@]} do local match=1 if [[ ${addcount} -eq ${countlimit} ]] then echo "Update add calls are completed. No more will be attempted." break fi for j in ${!updateversionsarr[@]} do if [[ "${currentmonth}" == "${updateversionsarr[$j]}" ]] && [[ ${addcount} -gt 0 ]] then match=1 break fi if [[ "${monthsarrfromcurrent[$i]}" == "${updateversionsarr[$j]}" ]] && [[ ${addcount} -eq 0 ]] then match=0 break fi done if [[ ${match} -eq 1 ]] then skipUpdateAdd ${yearsarrfromcurrent[$i]} "${monthsarrfromcurrent[$i]}" addcount=$((addcount+1)) fi done echo "Running: ${epmautomatescript} skipUpdate list" ${epmautomatescript} skipUpdate list echo "Running: ${epmautomatescript} logout" ${epmautomatescript} logout } compareUpdateMonths() { local thismonth=$1 local nextmonth=$2 local nextmonthorig=${nextmonth} if [[ ${nextmonth} -lt ${thismonth} ]] then nextmonth=$((nextmonth+12)) fi monthdiff=$((nextmonth-thismonth)) if [[ ${monthdiff} -gt 4 ]] then echo "There are more than 3 versions skipped from version ${thismonth} to version ${nextmonthorig}. Please correct updateversions in input.properties so that there are not more than three versions skipped between each update version. Exiting." exit 1 fi } validateUpdateVersions() { for i in ${!updateversionsarr[@]} do nextint=$((i+1)) thisupdatemonth="${updateversionsarr[$i]}" thisupdatemonthint=${thisupdatemonth#0} nextupdatemonth="${updateversionsarr[$nextint]}" nextupdatemonthint=${nextupdatemonth#0} if [[ ${nextupdatemonth} == "" ]] then nextupdatemonth="${updateversionsarr[0]}" nextupdatemonthint=${nextupdatemonth#0} fi compareUpdateMonths ${thisupdatemonthint} ${nextupdatemonthint} done } validateUpdateVersions populateFromCurrentArrays processSkipUpdates
伺服器端 Groovy 指令碼
透過複製下列指令碼並加以更新,以建立skip_update.groovy
Groovy 指令碼。請參閱執行指令碼,瞭解如何執行此指令碼:
更新這個 groovy 指令碼中的下列變數:
username
環境上的服務管理員使用者名稱,您想在這個環境上設定非每月更新節奏。password
服務管理員的密碼,或已加密之密碼檔案的名稱和位置。url
環境的 URL,您想在這個環境上設定非每月更新節奏。updateversions
EPM Cloud 更新清單 (逗號分隔),這些更新應套用至由 url
參數識別的環境。例如,updateversions=02,05,08,11
。
版本必須指定為兩位數;包括 01 月到 09 更新前面的 0。此指令碼會嘗試針對未包含在 updateversions
參數值中的更新執行 skipUpdate 命令。例如,如果您指定 updateversions=02,05,08,11
,指令碼會嘗試為 01 (一月)、03 (三月)、04 (四月)、06 (六月)、07 (七月)、09 (九月)、10 (十月) 和 12 (十二月) 更新設定略過更新旗標。在此案例中,EPM Cloud 更新 02 (二月)、05 (五月)、08 (八月) 和 11 (十一月) 將套用至環境。
podtype
EPM Cloud 環境類型。有效的值包括 test
和 prod
。proxyserverusername
向代理伺服器 (控制網際網路存取) 驗證安全階段作業時應輸入的使用者名稱。proxyserverpassword
向代理伺服器驗證使用者時應輸入的密碼。proxyserverdomain
為代理伺服器定義的網域名稱。Note:
如果您未使用代理伺服器,請勿為proxyserverusername
、proxyserverpassword
和 proxyserverdomain
參數指定任何值。import java.text.SimpleDateFormat String username = 'service_administrator' String password = 'examplePWD' String url = 'example_EPM_URL' String updateversions = '01,04,07,10' String podtype = 'test' String proxyserverusername = '' String proxyserverpassword = '' String proxyserverdomain = '' def currentdate = new Date() def yf = new SimpleDateFormat("yy") def mf = new SimpleDateFormat("MM") String[] monthsarr = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"] List<String> monthsarrfromcurrent = new ArrayList<>() List<String> yearsarrfromcurrent = new ArrayList<>() String currentyear = yf.format(currentdate) String nextyear = (currentyear.toInteger() + 1).toString() String currentmonth = mf.format(currentdate) String[] updateVersionsStringArr = updateversions.split(','); def updateversionsarr = new int[updateVersionsStringArr.length]; for(int i = 0; i < updateVersionsStringArr.length; i++) { updateversionsarr[i] = Integer.parseInt(updateVersionsStringArr[i]); } def LogMessage(String message) { def date = new Date() def sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss") println('[' + sdf.format(date) + '][GROOVY] ' + message); } def LogOperationStatus(EpmAutomateStatus opstatus) { def returncode = opstatus.getStatus() LogMessage(opstatus.getOutput()) LogMessage('return code: ' + returncode) } int CompareUpdateMonths(int thismonth, int nextmonth) { int nextmonthorig = nextmonth if (nextmonth < thismonth) { nextmonth = nextmonth + 12 } int monthdiff = nextmonth - thismonth if (monthdiff > 4) { LogMessage('There are more than 3 versions skipped from version ' + thismonth + ' to version ' + nextmonthorig + '. Please correct updateversions so that there are not more than three versions skipped between each update version. Exiting.') return 1 } return 0 } int ValidateUpdateMonths(int[] updateversionsarr) { for(int i = 0; i < updateversionsarr.length; i++) { int nextint = i + 1 String nextupdatemonth = "" int nextupdatemonthint = 0 String thisupdatemonth = updateversionsarr[i] int thisupdatemonthint = thisupdatemonth.toInteger() if (nextint < updateversionsarr.length) { nextupdatemonth = updateversionsarr[nextint] } else { nextupdatemonth = updateversionsarr[0] } nextupdatemonthint = nextupdatemonth.toInteger() int returncode = CompareUpdateMonths(thisupdatemonthint, nextupdatemonthint) if (returncode > 0) { return 1 } } return 0 } def SkipUpdateAdd(EpmAutomate automate, String yearnumber, String monthnumber) { String yeardotmonth = yearnumber + '.' + monthnumber LogMessage('Running: epmautomate skipUpdate add version=' + yeardotmonth + ' comment=\"adding skipUpdate\"') EpmAutomateStatus status = automate.execute('skipupdate','add','version=' + yeardotmonth,'comment=\"adding skipUpdate\"') LogOperationStatus(status) } LogMessage('Starting skip update processing') EpmAutomate automate = getEpmAutomate() // validate update months int returncode = ValidateUpdateMonths(updateversionsarr) if (returncode != 0) { return 1 } // populate arrays int startposition = 0 for(int i = 0; i < monthsarr.length; i++) { if (currentmonth == monthsarr[i]) { if (podtype.equals("prod")) { if (updateVersionsStringArr.contains(currentmonth)) { startposition = (i-2) } else { startposition = (i-1) } } else { if (updateVersionsStringArr.contains(currentmonth)) { startposition = i } else { startposition = (i-1) } } break } } if (startposition < 0) { startposition = startposition + 12 } for(int i = 0; i < monthsarr.length; i++) { if (i >= startposition) { monthsarrfromcurrent.add(monthsarr[i]) yearsarrfromcurrent.add(currentyear) } } for(int i = 0; i < monthsarr.length; i++) { if (i <= startposition) { monthsarrfromcurrent.add(monthsarr[i]) yearsarrfromcurrent.add(nextyear) } } // process skip updates LogMessage("Operation: encrypt " + password + " oracleKey password.epw") EpmAutomateStatus status = automate.execute('encrypt',password,"oracleKey","password.epw") LogOperationStatus(status) if ((proxyserverusername != null && proxyserverusername != '') && (proxyserverpassword != null && proxyserverpassword != '') && (proxyserverdomain != null && proxyserverdomain != '')) { LogMessage("Operation: login " + username + " password.epw " + url + " ProxyServerUserName=" + proxyserverusername + " ProxyServerPassword=" + proxyserverpassword + " ProxyServerDomain=" + proxyserverdomain) status = automate.execute('login',username,"password.epw",url,"ProxyServerUserName=" + proxyserverusername,"ProxyServerPassword=" + proxyserverpassword,"ProxyServerDomain=" + proxyserverdomain) LogOperationStatus(status) } else { LogMessage("Operation: login " + username + " password.epw " + url) status = automate.execute('login',username,"password.epw",url) LogOperationStatus(status) } LogMessage('Running: epmautomate skipUpdate remove') status = automate.execute('skipupdate','remove') LogOperationStatus(status) int addcount = 0 int countlimit = 0 if (podtype.equals("prod")) { countlimit = 3 } else { countlimit = 2 } for (int i = 0; i < monthsarrfromcurrent.size(); i++) { int match = 1 if (addcount == countlimit){ LogMessage('Update add calls are completed. No more will be attempted.') break } for(int j = 0; j < updateversionsarr.length; j++) { if ((Integer.parseInt(currentmonth) == updateversionsarr[j]) && (addcount > 0)) { match = 1 break } if ((Integer.parseInt(monthsarrfromcurrent.get(i)) == updateversionsarr[j]) && (addcount == 0)) { match = 0 break } } if (match == 1) { SkipUpdateAdd(automate, yearsarrfromcurrent.get(i), monthsarrfromcurrent.get(i)) addcount+=1 } } LogMessage('Running: epmautomate skipUpdate list') status = automate.execute('skipupdate','list') LogOperationStatus(status) println(status.getItemsList()) LogMessage('Running: epmautomate logout') status = automate.execute('logout') LogOperationStatus(status) LogMessage('Skip update processing completed')
建立 input.properties 檔案,以執行 skip_update
Windows 和 Linux/UNIX 指令碼
skip_update.ps1
或 skip_update.sh
,請建立 input.properties
檔案並根據您的環境資訊予以更新。將檔案儲存在本機目錄中。此檔案的內容因作業系統而異。
Windows
username=exampleAdmin password=examplePassword.epw url=exampleURL updateversions=01,04,07,10 podtype=test
Linux/UNIX
javahome=JAVA_HOME epmautomatescript=EPM_AUTOMATE_LOCATION username=exampleAdmin password=examplePassword.epw url=exampleURL updatemonths=02,05,08,11
Table 3-14 input.properties 參數
參數 | 描述 |
---|---|
javahome |
JAVA_HOME 位置。僅適用於 Linux/UNIX。 |
epmautomatescript |
EPM Automate 執行檔 (epmautomate.sh ) 的絕對路徑。僅適用於 Linux/UNIX。 |
username |
服務管理員。的使用者名稱 |
password |
服務管理員的密碼,或加密密碼檔案所在的名稱和位置。 |
url |
要設定非每月更新節奏之環境的 URL。 |
updateversions |
updateversions EPM Cloud 更新清單 (逗號分隔),這些更新應套用至由 url 參數識別的環境。例如,updateversions=02,05,08,11 。
版本必須指定為兩位數;包括 01 月到 09 更新前面的 0。此指令碼會嘗試針對未包含在 |
podtype |
EPM Cloud 環境類型。有效的值為 test 和 prod 。 |
執行指令碼
skip_update.ps1
或 skip_update.sh
。input.properties
檔案並將它儲存至 skip_update
指令碼所在的目錄。此檔案的內容因作業系統而異。請參閱建立 input.properties 檔案以執行 skip_update Windows 和 Linux/UNIX 指令碼.。
確保您在此目錄中具有寫入權限。至於 Windows,您可能需要使用以管理員身分執行選項來啟動 PowerShell,才能執行指令碼。
skip_update.ps1
。./skip_update.sh
。skip_update.groovy
Groovy 指令碼並根據需要予以更新。