Skip to content

Commit e5b5ab2

Browse files
committed
add run_rcu logic for ATP
1 parent b9691c6 commit e5b5ab2

File tree

3 files changed

+113
-6
lines changed

3 files changed

+113
-6
lines changed

core/src/main/java/oracle/weblogic/deploy/create/RCURunner.java

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import oracle.weblogic.deploy.util.ScriptRunnerException;
2020
import oracle.weblogic.deploy.util.StringUtils;
2121

22+
import org.python.core.PyDictionary;
23+
import org.python.core.PyString;
24+
2225
/**
2326
* This class does all the work to drop and recreate the RCU schemas besed on the domain type definition.
2427
*/
@@ -44,7 +47,13 @@ public class RCURunner {
4447
private static final String DB_ROLE = "SYSDBA";
4548
private static final String SCHEMA_PREFIX_SWITCH = "-schemaPrefix";
4649
private static final String COMPONENT_SWITCH = "-component";
50+
private static final String TABLESPACE_SWITCH = "-tablespace";
51+
private static final String TEMPTABLESPACE_SWITCH = "-tempTablespace";
4752
private static final String READ_STDIN_SWITCH = "-f";
53+
private static final String USE_SSL_SWITCH = "-useSSL";
54+
private static final String SERVER_DN_SWITCH = "-serverDN";
55+
private static final String SSLARGS = "-sslArgs";
56+
4857
private static final String SERVICE_TABLE_COMPONENT = "STB";
4958
private static final String WLS_COMPONENT = "WLS";
5059
private static final String WLS_RUNTIME_COMPONENT = "WLS_RUNTIME";
@@ -61,6 +70,7 @@ public class RCURunner {
6170
private String rcuDb;
6271
private String rcuPrefix;
6372
private List<String> rcuSchemas;
73+
private boolean ATP_DB = false;
6474

6575
/**
6676
* The constructor.
@@ -87,6 +97,53 @@ public RCURunner(String domainType, String oracleHome, String javaHome, String r
8797
}
8898
}
8999

100+
/**
101+
* The constructor.
102+
*
103+
* @param domainType the domain type
104+
* @param oracleHome the ORACLE_HOME location
105+
* @param javaHome the JAVA_HOME location
106+
* @throws CreateException if a parameter validation error occurs
107+
*/
108+
public RCURunner(String domainType, String oracleHome, String javaHome, PyDictionary rcuProperties)
109+
throws CreateException {
110+
111+
112+
String tnsAdmin = rcuProperties.get(new PyString("oracle.net.tns_admin")).toString();
113+
String keyStorePassword = rcuProperties.get(new PyString("javax.net.ssl.keyStorePassword")).toString();
114+
String trustStorePassword = rcuProperties.get(new PyString("javax.net.ssl.trustStorePassword")).toString();
115+
116+
StringBuffer sslArgs = new StringBuffer();
117+
sslArgs.append("oracle.net.tns_admin=");
118+
sslArgs.append(tnsAdmin);
119+
sslArgs.append(",oracle.net.ssl_version=1.2");
120+
sslArgs.append(",javax.net.ssl.trustStore=");
121+
sslArgs.append(tnsAdmin + "/truststore.jks");
122+
sslArgs.append("javax.net.ssl.trustStoreType=JKS");
123+
sslArgs.append(",javax.net.ssl.trustStorePassword=");
124+
sslArgs.append(trustStorePassword);
125+
sslArgs.append(",javax.net.ssl.keyStore=");
126+
sslArgs.append(tnsAdmin + "/keystore.jks");
127+
sslArgs.append(",javax.net.ssl.keyStoreType=JKS");
128+
sslArgs.append(",javax.net.ssl.keyStorePassword=");
129+
sslArgs.append(keyStorePassword);
130+
sslArgs.append(",oracle.jdbc.fanEnabled=false");
131+
sslArgs.append(",oracle.net.ssl_server_dn_match=true");
132+
133+
ATP_DB = true;
134+
135+
this.oracleHome = validateExistingDirectory(oracleHome, "ORACLE_HOME");
136+
this.javaHome = validateExistingDirectory(javaHome, "JAVA_HOME");
137+
this.rcuDb = rcuProperties.get(new PyString("tns.entry")).toString();
138+
this.rcuPrefix = rcuProperties.get(new PyString("rcu_prefix")).toString();
139+
this.rcuSchemas = validateNonEmptyListOfStrings(rcuSchemas, "rcu_schema_list");
140+
if (this.rcuSchemas.contains(SERVICE_TABLE_COMPONENT)) {
141+
LOGGER.warning("WLSDPLY-12000", CLASS, domainType, SERVICE_TABLE_COMPONENT);
142+
this.rcuSchemas.remove(SERVICE_TABLE_COMPONENT);
143+
}
144+
}
145+
146+
90147
/**
91148
* Run RCU to drop and recreate the RCU schemas.
92149
*
@@ -146,9 +203,19 @@ public void runRcu(String rcuSysPass, String rcuSchemaPass) throws CreateExcepti
146203
// Private helper methods //
147204
///////////////////////////////////////////////////////////////////////////
148205

206+
private void addATPEnv(Map<String, String> env) {
207+
if (ATP_DB) {
208+
env.put("RCU_SSL_MODE", "true");
209+
env.put("SKIP_CONNECTSTRING_VALIDATION", "true");
210+
env.put("RCU_SKIP_PRE_REQS", "ALL");
211+
}
212+
}
213+
214+
149215
private Map<String, String> getRcuDropEnv() {
150216
Map<String, String> env = new HashMap<>(1);
151217
env.put("JAVA_HOME", this.javaHome.getAbsolutePath());
218+
addATPEnv(env);
152219
return env;
153220
}
154221

@@ -203,6 +270,12 @@ private String[] getRcuCreateArgs() {
203270
for (String rcuSchema : rcuSchemas) {
204271
createArgs.add(COMPONENT_SWITCH);
205272
createArgs.add(rcuSchema);
273+
if (ATP_DB) {
274+
createArgs.add(TABLESPACE_SWITCH);
275+
createArgs.add("DATA");
276+
createArgs.add(TEMPTABLESPACE_SWITCH);
277+
createArgs.add("TEMP");
278+
}
206279
}
207280
createArgs.add(READ_STDIN_SWITCH);
208281

core/src/main/python/wlsdeploy/aliases/model_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@
286286
DRIVER_PARAMS_NET_FAN_ENABLED = 'oracle.jdbc.fanEnabled'
287287
ATP_RCU_PREFIX='rcu_prefix'
288288
ATP_RCU_SCHEMA_PASSWORD='rcu_schema_password'
289+
ATP_ADMIN_PASSWORD='rcu_admin_password'
289290
ATP_TNS_ENTRY='tns.entry'
290291

291292
ENABLED = 'Enabled'

core/src/main/python/wlsdeploy/tool/create/domain_creator.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_FAN_ENABLED
3131
from wlsdeploy.aliases.model_constants import ATP_RCU_PREFIX
3232
from wlsdeploy.aliases.model_constants import ATP_RCU_SCHEMA_PASSWORD
33+
from wlsdeploy.aliases.model_constants import ATP_ADMIN_PASSWORD
34+
3335
from wlsdeploy.aliases.model_constants import ATP_TNS_ENTRY
3436

3537
from wlsdeploy.aliases.model_constants import JDBC_DRIVER_PARAMS
@@ -215,14 +217,45 @@ def __run_rcu(self):
215217
domain_type = self.model_context.get_domain_type()
216218
oracle_home = self.model_context.get_oracle_home()
217219
java_home = self.model_context.get_java_home()
218-
rcu_db = self.model_context.get_rcu_database()
219-
rcu_prefix = self.model_context.get_rcu_prefix()
220-
rcu_sys_pass = self.model_context.get_rcu_sys_pass()
221-
rcu_schema_pass = self.model_context.get_rcu_schema_pass()
222220

221+
props_file = self.model_context.get_rcu_properties_file()
222+
if props_file:
223+
try:
224+
rcu_properties_map = variables.load_variables(props_file)
225+
# parse the tnsnames.ora file and retrieve the connection string
226+
tns_admin = rcu_properties_map[DRIVER_PARAMS_NET_TNS_ADMIN]
227+
tns_names = variables.load_variables( tns_admin + os.sep +
228+
'tnsnames.ora')
229+
230+
rcu_db = tns_names[rcu_properties_map[ATP_TNS_ENTRY]]
231+
232+
rcu_prefix = rcu_properties_map[ATP_RCU_PREFIX]
233+
rcu_schema_pass = rcu_properties_map[ATP_RCU_SCHEMA_PASSWORD]
234+
rcu_sys_pass = rcu_properties_map[ATP_ADMIN_PASSWORD]
235+
236+
keystore_pwd = rcu_properties_map[DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
237+
truststore_pwd = rcu_properties_map[DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
238+
239+
# Need to set for the connection proeprty for each datasource
240+
241+
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas)
242+
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
243+
244+
245+
except VariableException, ex:
246+
self.logger.severe('WLSDPLY-20004', _program_name, ex.getLocalizedMessage(), error=ex,
247+
class_name=_class_name, method_name=_method_name)
248+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
249+
raise ex
250+
251+
else:
252+
rcu_db = self.model_context.get_rcu_database()
253+
rcu_prefix = self.model_context.get_rcu_prefix()
254+
rcu_sys_pass = self.model_context.get_rcu_sys_pass()
255+
rcu_schema_pass = self.model_context.get_rcu_schema_pass()
223256

224-
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas)
225-
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
257+
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas)
258+
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
226259

227260
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
228261
return

0 commit comments

Comments
 (0)