使用本节中的脚本可创建用于跳过更新的自助服务解决方案,以便 Oracle Enterprise Performance Management Cloud 环境按季度更新,并实施为期六周的测试周期。在这种情况下,在更新测试环境六周后更新生产环境。
默认情况下,EPM 云将每月更新应用于环境。您可以使用 skipUpdate 命令跳过向环境应用每月更新的过程或查看当前的跳过更新请求。可以使用本节包含的脚本自动运行 skipUpdate
命令。这些脚本自动执行跳过更新过程,以便每季度应用更新,并实施为期六周的测试周期。
Note:
示例方案:测试环境更新周期确定为二月的第一个星期五(24.02 更新)、五月的第一个星期五(24.05 更新)、八月的第一个星期五(24.08 更新)和十一月的第一个星期五(24.11 更新)。将在三月的第三个星期五(24.02 更新)使用在二月的第一个星期五(24.02 更新)更新测试环境所用版本更新生产环境。将在六月的第三周(24.05 更新)、九月的第三周(24.08 更新)和十二月的第三周(24.11 更新)对生产环境进行类似更新。在这种情况下,生产环境不是更新到当前更新,而是测试环境当前采用的更新。
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
:应该应用于 url
参数标识的环境的 EPM 云更新列表(以逗号分隔)。例如 updateversions=02,05,08,11
。
版本必须指定为两位数字;更新 01 到 09 包含前面的零。该脚本尝试为没有包含在 updateversions
参数值中的更新运行 skipUpdate 命令。例如,如果指定 updateversions=02,05,08,11
,则脚本尝试针对 01(一月)、03(三月)、04(四月)、06(六月)、07(七月)、09(九月)、10(十月)和 12(十二月)更新设置跳过更新标志。在这种情况下,EPM 云更新 02(二月)、05(五月)、08(八月)和 11(十一月)将应用于环境。
podtype
:EPM 云环境类型。有效值为 test
和 prod
。proxyserverusername
:用于在控制 Internet 访问的代理服务器中对安全会话进行身份验证的用户名。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 :应该应用于 url 参数标识的环境的 EPM 云更新列表(以逗号分隔)。例如 updateversions=02,05,08,11 。
版本必须指定为两位数字;更新 01 到 09 包含前面的零。该脚本尝试为没有包含在 |
podtype |
EPM 云环境类型。有效值为 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 脚本并根据需要对其进行更新。