Skip to content

Commit cc48e2a

Browse files
committed
JRF Domain Sample Enhancement
1 parent d287593 commit cc48e2a

File tree

12 files changed

+335
-3
lines changed

12 files changed

+335
-3
lines changed

kubernetes/samples/scripts/create-fmw-infrastructure-domain/create-domain.sh renamed to kubernetes/samples/scripts/create-fmw-infrastructure-domain/domain-home-on-pv/create-domain.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
# Initialize
2222
script="${BASH_SOURCE[0]}"
2323
scriptDir="$( cd "$( dirname "${script}" )" && pwd )"
24-
source ${scriptDir}/../common/utility.sh
25-
source ${scriptDir}/../common/validate.sh
24+
source ${scriptDir}/../../common/utility.sh
25+
source ${scriptDir}/../../common/validate.sh
2626

2727
function usage {
2828
echo usage: ${script} -o dir -i file [-e] [-v] [-h]
@@ -118,7 +118,7 @@ function initialize {
118118
validationError "The template file ${deleteJobInput} for deleting a WebLogic domain was not found"
119119
fi
120120

121-
dcrInput="${scriptDir}/../common/domain-template.yaml"
121+
dcrInput="${scriptDir}/../../common/domain-template.yaml"
122122
if [ ! -f ${dcrInput} ]; then
123123
validationError "The template file ${dcrInput} for creating the domain resource was not found"
124124
fi
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
#!/bin/bash
2+
# Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
#
5+
# Description:
6+
#
7+
# This script generates a domain by calling the WebLogic Deploy Tool (WDT)
8+
# bin/createDomain.sh script.
9+
#
10+
# It first installs WDT using the given download URLs, and then runs it using the
11+
# given Oracle home, WDT model file, WDT vars file, etc.
12+
#
13+
# Usage:
14+
#
15+
# Export customized values for the input shell environment variables as needed
16+
# before calling this script.
17+
#
18+
# Outputs:
19+
#
20+
# WDT install: WDT_DIR/weblogic-deploy/...
21+
#
22+
# Copy of wdt model: WDT_DIR/$(basename WDT_MODEL_FILE)
23+
# Copy of wdt vars: WDT_DIR/$(basename WDT_VAR_FILE)
24+
#
25+
# WDT logs: WDT_DIR/weblogic-deploy/logs/...
26+
# WDT stdout: WDT_DIR/createDomain.sh.out
27+
#
28+
# WebLogic domain home: DOMAIN_HOME_DIR
29+
# default: /shared/domains/<domainUID>
30+
#
31+
# Input environment variables:
32+
#
33+
# ORACLE_HOME Oracle home with a WebLogic install.
34+
# default: /u01/oracle
35+
#
36+
# WDT_MODEL_FILE Full path to WDT model file.
37+
# default: the directory that contains this script
38+
# plus "/wdt_model.yaml"
39+
#
40+
# WDT_VAR_FILE Full path to WDT variable file (java properties format).
41+
# default: the directory that contains this script
42+
# plus "/create-domain-inputs.yaml"
43+
#
44+
# WDT_INSTALL_ZIP_FILE Filename of WDT install zip.
45+
# default: weblogic-deploy.zip
46+
#
47+
# WDT_INSTALL_ZIP_URL URL for downloading WDT install zip
48+
# default: https://github.com/oracle/weblogic-deploy-tooling/releases/download/weblogic-deploy-tooling-0.24/$WDT_INSTALL_ZIP_FILE
49+
#
50+
# https_proxy Proxy for downloading WDT_INSTALL_ZIP_URL.
51+
# default: "http://www-proxy-hqdc.us.oracle.com:80"
52+
# (If set to empty the script will try with no proxy.)
53+
#
54+
# https_proxy2 Alternate proxy for downloading WDT_INSTALL_ZIP_URL
55+
# default: ""
56+
# (If set to empty the script will try with no proxy.)
57+
#
58+
# WDT_DIR Target location to install and run WDT, and to keep a copy of
59+
# $WDT_MODEL_FILE and $WDT_MODEL_VARS. Also the location
60+
# of WDT log files.
61+
# default: /shared/wdt
62+
#
63+
# DOMAIN_HOME_DIR Target location for generated domain.
64+
#
65+
66+
# Initialize globals
67+
68+
export ORACLE_HOME=${ORACLE_HOME:-/u01/oracle}
69+
70+
SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
71+
WDT_MODEL_FILE=${WDT_MODEL_FILE:-"$SCRIPTPATH/wdt_model.yaml"}
72+
WDT_VAR_FILE=${WDT_VAR_FILE:-"$SCRIPTPATH/create-domain-inputs.yaml"}
73+
74+
WDT_DIR=${WDT_DIR:-/shared/wdt}
75+
76+
WDT_INSTALL_ZIP_FILE="${WDT_INSTALL_ZIP_FILE:-weblogic-deploy.zip}"
77+
WDT_INSTALL_ZIP_URL=${WDT_INSTALL_ZIP_URL:-"https://github.com/oracle/weblogic-deploy-tooling/releases/download/weblogic-deploy-tooling-0.24/$WDT_INSTALL_ZIP_FILE"}
78+
79+
# using "-" instead of ":-" in case proxy vars are explicitly set to "".
80+
https_proxy=${https_proxy-""}
81+
https_proxy2=${https_proxy2-"http://www-proxy-hqdc.us.oracle.com:80"}
82+
83+
# Define functions
84+
85+
function setup_wdt_shared_dir {
86+
mkdir -p $WDT_DIR || return 1
87+
}
88+
89+
function install_wdt {
90+
#
91+
# Download $WDT_INSTALL_ZIP_FILE from $WDT_INSTALL_ZIP_URL into $WDT_DIR using
92+
# proxies https_proxy or https_proxy2, then unzip the zip file in $WDT_DIR.
93+
#
94+
95+
local save_dir=`pwd`
96+
cd $WDT_DIR || return 1
97+
98+
local curl_res=1
99+
for proxy in "${https_proxy}" "${https_proxy2}"; do
100+
echo @@ "Info: Downloading $WDT_INSTALL_ZIP_URL with https_proxy=\"$proxy\""
101+
https_proxy="${proxy}" \
102+
curl --silent --show-error --connect-timeout 10 -O -L $WDT_INSTALL_ZIP_URL
103+
curl_res=$?
104+
[ $curl_res -eq 0 ] && break
105+
done
106+
107+
if [ $curl_res -ne 0 ] || [ ! -f $WDT_INSTALL_ZIP_FILE ]; then
108+
cd $save_dir
109+
echo @@ "Error: Download failed or $WDT_INSTALL_ZIP_FILE not found."
110+
return 1
111+
fi
112+
113+
echo @@ "Info: Archive downloaded to $WDT_DIR/$WDT_INSTALL_ZIP_FILE, about to unzip via 'jar xf'."
114+
115+
jar xf $WDT_INSTALL_ZIP_FILE
116+
local jar_res=$?
117+
118+
cd $save_dir
119+
120+
if [ $jar_res -ne 0 ]; then
121+
echo @@ "Error: Install failed while unzipping $WDT_DIR/$WDT_INSTALL_ZIP_FILE"
122+
return $jar_res
123+
fi
124+
125+
if [ ! -d "$WDT_DIR/weblogic-deploy/bin" ]; then
126+
echo @@ "Error: Install failed: directory '$WDT_DIR/weblogic-deploy/bin' not found."
127+
return 1
128+
fi
129+
130+
chmod 775 $WDT_DIR/weblogic-deploy/bin/* || return 1
131+
132+
echo @@ "Info: Install succeeded, wdt install is in the $WDT_DIR/weblogic-deploy directory."
133+
return 0
134+
}
135+
136+
function run_wdt {
137+
#
138+
# Run WDT using WDT_VAR_FILE, WDT_MODEL_FILE, and ORACLE_HOME.
139+
# Output:
140+
# - result domain will be in DOMAIN_HOME_DIR
141+
# - logging output is in $WDT_DIR/createDomain.sh.out and $WDT_DIR/weblogic-deploy/logs
142+
# - WDT_VAR_FILE & WDT_MODEL_FILE will be copied to WDT_DIR.
143+
#
144+
145+
# Input files and directories.
146+
147+
local inputs_orig="$WDT_VAR_FILE"
148+
local model_orig="$WDT_MODEL_FILE"
149+
local oracle_home="$ORACLE_HOME"
150+
local wdt_bin_dir="$WDT_DIR/weblogic-deploy/bin"
151+
local wdt_createDomain_script="$wdt_bin_dir/createDomain.sh"
152+
153+
local domain_home_dir="$DOMAIN_HOME_DIR"
154+
if [ -z "${domain_home_dir}" ]; then
155+
local domain_dir="/shared/domains"
156+
local domain_uid=`egrep 'domainUID' $inputs_orig | awk '{print $2}'`
157+
local domain_home_dir=$domain_dir/$domain_uid
158+
fi
159+
160+
echo domain_home_dir = $domain_home_dir
161+
162+
# Output files and directories.
163+
164+
local inputs_final=$WDT_DIR/$(basename "$inputs_orig")
165+
local model_final=$WDT_DIR/$(basename "$model_orig")
166+
local out_file=$WDT_DIR/createDomain.sh.out
167+
local wdt_log_dir="$WDT_DIR/weblogic-deploy/logs"
168+
169+
echo @@ "Info: About to run WDT createDomain.sh"
170+
171+
for directory in wdt_bin_dir SCRIPTPATH WDT_DIR oracle_home; do
172+
if [ ! -d "${!directory}" ]; then
173+
echo @@ "Error: Could not find ${directory} directory ${!directory}."
174+
return 1
175+
fi
176+
done
177+
178+
for fil in inputs_orig model_orig wdt_createDomain_script; do
179+
if [ ! -f "${!fil}" ]; then
180+
echo @@ "Error: Could not find ${fil} file ${!fil}."
181+
return 1
182+
fi
183+
done
184+
185+
cp $model_orig $model_final || return 1
186+
cp $inputs_orig $inputs_final || return 1
187+
188+
local save_dir=`pwd`
189+
cd $WDT_DIR || return 1
190+
191+
echo @@ "Info: WDT createDomain.sh output will be in $out_file and $wdt_log_dir"
192+
193+
# domain_type can be WLS, JRF or RestrictedJRF
194+
$wdt_createDomain_script \
195+
-oracle_home $oracle_home \
196+
-domain_type JRF \
197+
-domain_home $domain_home_dir \
198+
-model_file $model_final \
199+
-variable_file $inputs_final > $out_file 2>&1
200+
201+
local wdt_res=$?
202+
203+
cd $save_dir
204+
205+
if [ $wdt_res -ne 0 ]; then
206+
cat $WDT_DIR/createDomain.sh.out
207+
echo @@ "Info: WDT createDomain.sh output is in $out_file and $wdt_log_dir"
208+
echo @@ "Error: WDT createDomain.sh failed."
209+
return 1
210+
fi
211+
212+
echo @@ "Info: WDT createDomain.sh succeeded."
213+
return 0
214+
}
215+
216+
# Run
217+
218+
setup_wdt_shared_dir || exit 1
219+
220+
install_wdt || exit 1
221+
222+
run_wdt || exit 1
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
#
5+
6+
# Perform preparation based on the specified cluster type
7+
8+
function usage {
9+
echo usage: ${script} -i file [-h]
10+
echo " -i Directory, must be specified."
11+
echo " -h Help"
12+
exit $1
13+
}
14+
15+
16+
while getopts "hi:" opt; do
17+
case $opt in
18+
i) externalFilesTmpDir="${OPTARG}"
19+
;;
20+
h) usage 0
21+
;;
22+
*) usage 1
23+
;;
24+
esac
25+
done
26+
27+
echo Preparing the model script
28+
# JRF does not support Dynamic Cluster Model
29+
cp ${externalFilesTmpDir}/wdt_model_configured.yaml ${externalFilesTmpDir}/wdt_model.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
domainInfo:
2+
AdminUserName: '@@FILE:/weblogic-operator/secrets/username@@'
3+
AdminPassword: '@@FILE:/weblogic-operator/secrets/password@@'
4+
ServerStartMode: prod
5+
topology:
6+
AdminServerName: '@@PROP:adminServerName@@'
7+
Name: '@@PROP:domainName@@'
8+
ProductionModeEnabled: '@@PROP:productionModeEnabled@@'
9+
Cluster:
10+
'@@PROP:clusterName@@':
11+
Server:
12+
'@@PROP:adminServerName@@':
13+
NetworkAccessPoint:
14+
T3Channel:
15+
ListenPort: '@@PROP:t3ChannelPort@@'
16+
PublicAddress: '@@PROP:t3PublicAddress@@'
17+
PublicPort: '@@PROP:t3ChannelPort@@'
18+
'@@PROP:managedServerNameBase@@1':
19+
Cluster: '@@PROP:clusterName@@'
20+
ListenPort: '@@PROP:managedServerPort@@'
21+
NumOfRetriesBeforeMsiMode: 0
22+
RetryIntervalBeforeMsiMode: 1
23+
JTAMigratableTarget:
24+
Cluster: '@@PROP:clusterName@@'
25+
UserPreferredServer: '@@PROP:managedServerNameBase@@1'
26+
'@@PROP:managedServerNameBase@@2':
27+
Cluster: '@@PROP:clusterName@@'
28+
ListenPort: '@@PROP:managedServerPort@@'
29+
NumOfRetriesBeforeMsiMode: 0
30+
RetryIntervalBeforeMsiMode: 1
31+
JTAMigratableTarget:
32+
Cluster: '@@PROP:clusterName@@'
33+
UserPreferredServer: '@@PROP:managedServerNameBase@@2'
34+
'@@PROP:managedServerNameBase@@3':
35+
Cluster: '@@PROP:clusterName@@'
36+
ListenPort: '@@PROP:managedServerPort@@'
37+
NumOfRetriesBeforeMsiMode: 0
38+
RetryIntervalBeforeMsiMode: 1
39+
JTAMigratableTarget:
40+
Cluster: '@@PROP:clusterName@@'
41+
UserPreferredServer: '@@PROP:managedServerNameBase@@3'
42+
MigratableTarget:
43+
'@@PROP:managedServerNameBase@@1 (migratable)':
44+
Cluster: '@@PROP:clusterName@@'
45+
UserPreferredServer: '@@PROP:managedServerNameBase@@1'
46+
'@@PROP:managedServerNameBase@@2 (migratable)':
47+
Cluster: '@@PROP:clusterName@@'
48+
UserPreferredServer: '@@PROP:managedServerNameBase@@2'
49+
'@@PROP:managedServerNameBase@@3 (migratable)':
50+
Cluster: '@@PROP:clusterName@@'
51+
UserPreferredServer: '@@PROP:managedServerNameBase@@3'
52+

0 commit comments

Comments
 (0)