Skip to content

Commit 324753e

Browse files
authored
Various RCU related update (#1193)
* wdt-636 Remove the use of getDatabaseDefaults during JRF domain creation, unify the logic for atp, ssl and regular oracle db for rcu datasources connection parameters setup. * minor refactoring * no more need to update password from getDatabaseDefaults - operator mii use case since we are populated the password from the model or cli * temporary * testing for MDS * ATP refactor 1 * ATP refactoring 2 * add AGL * refactoring * Move RCUDbInfo to under resources section and rename as RCUConfiguration * refactor to use RCUConfiguraion * Fix wlst path issue * refactoring * correct NPE in rcudbinfo_helper * refactor * bug * cleanup * remove RCUConfiguration * fix keystores password encrypted property for datasource * fix atp wallet extraction * Remove new sections, user can use sparse model in regular resources/JDBCSystemResource section for more flexibility and robustness * doc update * doc update * doc change * cleanup * doc update * doc update * Fix aliases failure, remove obsolete code * remove obsolete comment * correct obsolete import * clean up
1 parent 45b5d15 commit 324753e

File tree

11 files changed

+835
-345
lines changed

11 files changed

+835
-345
lines changed

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

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

22+
import org.python.core.PyClass;
2223
import org.python.core.PyDictionary;
2324
import org.python.core.PyString;
2425

@@ -135,47 +136,54 @@ public static RCURunner createRunner(String domainType, String oracleHome, Strin
135136
* @param javaHome the JAVA_HOME location
136137
* @param rcuSchemas the list of RCU schemas to create (this list should not include STB)
137138
* @param rcuVariables a comma separated list of key=value variables
138-
* @param rcuProperties dictionary of ATP specific arguments
139+
* @param connectionProperties dictionary of ATP specific arguments
139140
* @throws CreateException if a parameter validation error occurs
140141
*/
141-
public static RCURunner createAtpRunner(String domainType, String oracleHome, String javaHome,
142-
String rcuPrefix, List<String> rcuSchemas, String rcuVariables,
143-
PyDictionary rcuProperties) throws CreateException {
144-
145-
String rcuDb = "jdbc:oracle:thin:@" + get(rcuProperties, "tns.alias");
142+
public static RCURunner createAtpRunner(String domainType, String oracleHome, String javaHome, String rcuDb,
143+
List<String> rcuSchemas, String rcuPrefix, String rcuVariables,
144+
String databaseType, PyDictionary runnerMap,
145+
PyDictionary connectionProperties) throws CreateException {
146146

147147
RCURunner runner = new RCURunner(domainType, oracleHome, javaHome, rcuDb, rcuPrefix, rcuSchemas, rcuVariables);
148148

149-
String tnsAdmin = get(rcuProperties, "oracle.net.tns_admin");
150-
String keyStorePassword = get(rcuProperties, "javax.net.ssl.keyStorePassword");
151-
String trustStorePassword = get(rcuProperties, "javax.net.ssl.trustStorePassword");
152-
153149
StringBuilder sslArgs = new StringBuilder();
154-
sslArgs.append("oracle.net.tns_admin=");
155-
sslArgs.append(tnsAdmin);
156-
sslArgs.append(",oracle.net.ssl_version=1.2");
157-
sslArgs.append(",javax.net.ssl.trustStore=");
158-
sslArgs.append(tnsAdmin);
159-
sslArgs.append("/truststore.jks");
160-
sslArgs.append(",javax.net.ssl.trustStoreType=JKS");
161-
sslArgs.append(",javax.net.ssl.trustStorePassword=");
162-
sslArgs.append(trustStorePassword);
163-
sslArgs.append(",javax.net.ssl.keyStore=");
164-
sslArgs.append(tnsAdmin);
165-
sslArgs.append("/keystore.jks");
166-
sslArgs.append(",javax.net.ssl.keyStoreType=JKS");
167-
sslArgs.append(",javax.net.ssl.keyStorePassword=");
168-
sslArgs.append(keyStorePassword);
169-
sslArgs.append(",oracle.jdbc.fanEnabled=false");
170-
sslArgs.append(",oracle.net.ssl_server_dn_match=false");
171-
172-
runner.atpDB = true;
150+
151+
for (Object connectionProperty: connectionProperties.keys()) {
152+
if (sslArgs.length() != 0) {
153+
sslArgs.append(',');
154+
}
155+
sslArgs.append(connectionProperty.toString());
156+
sslArgs.append('=');
157+
PyDictionary valueObject = (PyDictionary)connectionProperties
158+
.get(new PyString(connectionProperty.toString()));
159+
sslArgs.append(valueObject.get(new PyString("Value")));
160+
}
161+
162+
163+
addExtraSSLPropertyFromMap(runnerMap, connectionProperties, sslArgs, "javax.net.ssl.keyStorePassword");
164+
addExtraSSLPropertyFromMap(runnerMap, connectionProperties, sslArgs, "javax.net.ssl.trustStorePassword");
165+
166+
167+
runner.atpDB = true; // "ATP".equals(databaseType); // or scan if there are any 'ssl' in properties ?
173168
runner.atpSSlArgs = sslArgs.toString();
174-
runner.atpAdminUser = get(rcuProperties, "atp.admin.user");
175-
runner.atpDefaultTablespace = get(rcuProperties, "atp.default.tablespace");
176-
runner.atpTemporaryTablespace = get(rcuProperties, "atp.temp.tablespace");
169+
170+
runner.atpAdminUser = get(runnerMap, "atp.admin.user");
171+
runner.atpDefaultTablespace = get(runnerMap, "atp.default.tablespace");
172+
runner.atpTemporaryTablespace = get(runnerMap, "atp.temp.tablespace");
173+
177174
return runner;
178175
}
176+
177+
private static void addExtraSSLPropertyFromMap(PyDictionary runnerMap, PyDictionary connectionProperties,
178+
StringBuilder sslArgs, String key) {
179+
if (!connectionProperties.has_key(new PyString(key)) &&
180+
!get(runnerMap, key).equals("None")) {
181+
sslArgs.append(",");
182+
sslArgs.append(key);
183+
sslArgs.append(get(runnerMap, key));
184+
}
185+
}
186+
179187
/**
180188
* Build an RCU runner for an SSL database.
181189
*
@@ -276,6 +284,7 @@ public void runRcu(String rcuSysPass, String rcuSchemaPass) throws CreateExcepti
276284
}
277285
// RCU is stupid and RCU drop exits with exit code 1 if the schemas do not exist...sigh
278286
//
287+
279288
if (exitCode != 0 && !isSchemaNotExistError(runner)) {
280289
CreateException ce = new CreateException("WLSDPLY-12002", CLASS, exitCode, runner.getStdoutFileName());
281290
LOGGER.throwing(CLASS, METHOD, ce);

core/src/main/python/create.py

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
from wlsdeploy.util.weblogic_helper import WebLogicHelper
4949
from wlsdeploy.tool.create import atp_helper
5050
from wlsdeploy.tool.create import ssl_helper
51+
from wlsdeploy.aliases.model_constants import DOMAIN_INFO
52+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_TNS_ADMIN
5153

5254
wlst_helper.wlst_functions = globals()
5355

@@ -237,43 +239,47 @@ def validate_rcu_args_and_model(model_context, model, archive_helper, aliases):
237239

238240
has_atpdbinfo = 0
239241
has_ssldbinfo = 0
240-
domain_info = model[model_constants.DOMAIN_INFO]
241-
if domain_info is not None:
242-
if model_constants.RCU_DB_INFO in domain_info:
243-
rcu_db_info = RcuDbInfo(model_context, aliases, domain_info[model_constants.RCU_DB_INFO])
244-
has_tns_admin = rcu_db_info.has_tns_admin()
245-
has_regular_db = rcu_db_info.is_regular_db()
246-
has_atpdbinfo = rcu_db_info.has_atpdbinfo()
247-
has_ssldbinfo = rcu_db_info.has_ssldbinfo()
248-
249-
if archive_helper and not has_regular_db:
250-
System.setProperty('oracle.jdbc.fanEnabled', 'false')
251-
252-
# 1. If it does not have the oracle.net.tns_admin specified, then extract to domain/atpwallet
253-
# 2. If it is plain old regular oracle db, do nothing
254-
# 3. If it deos not have tns_admin in the model, then the wallet must be in the archive
255-
if not has_tns_admin:
256-
wallet_path = archive_helper.extract_atp_wallet()
257-
if wallet_path:
258-
# update the model to add the tns_admin
259-
model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
260-
model_constants.DRIVER_PARAMS_NET_TNS_ADMIN] = wallet_path
261-
else:
262-
__logger.severe('WLSDPLY-12411', error=None, class_name=_class_name, method_name=_method_name)
263-
cla_helper.clean_up_temp_files()
264-
tool_exit.end(model_context, ExitCode.ERROR)
265-
266-
else:
267-
if model_context.get_domain_typedef().required_rcu():
268-
if not model_context.get_rcu_database() or not model_context.get_rcu_prefix():
269-
__logger.severe('WLSDPLY-12408', model_context.get_domain_type(), CommandLineArgUtil.RCU_DB_SWITCH,
270-
CommandLineArgUtil.RCU_PREFIX_SWITCH)
271-
cla_helper.clean_up_temp_files()
272-
tool_exit.end(model_context, ExitCode.ERROR)
242+
243+
if model_constants.DOMAIN_INFO in model and model_constants.RCU_DB_INFO in model[model_constants.DOMAIN_INFO]:
244+
rcu_db_info = RcuDbInfo(model_context, aliases, model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO])
245+
has_tns_admin = rcu_db_info.has_tns_admin()
246+
is_regular_db = rcu_db_info.is_regular_db()
247+
has_atpdbinfo = rcu_db_info.has_atpdbinfo()
248+
has_ssldbinfo = rcu_db_info.has_ssldbinfo()
249+
250+
_validate_atp_wallet_in_archive(archive_helper, is_regular_db, has_tns_admin, model,
251+
model_context)
252+
else:
253+
if model_context.get_domain_typedef().required_rcu():
254+
if not model_context.get_rcu_database() or not model_context.get_rcu_prefix():
255+
__logger.severe('WLSDPLY-12408', model_context.get_domain_type(), CommandLineArgUtil.RCU_DB_SWITCH,
256+
CommandLineArgUtil.RCU_PREFIX_SWITCH)
257+
cla_helper.clean_up_temp_files()
258+
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
273259

274260
return has_atpdbinfo, has_ssldbinfo
275261

276262

263+
def _validate_atp_wallet_in_archive(archive_helper, is_regular_db, has_tns_admin, model, model_context):
264+
if archive_helper and not is_regular_db:
265+
# 1. If it does not have the oracle.net.tns_admin specified, then extract to domain/atpwallet
266+
# 2. If it is plain old regular oracle db, do nothing
267+
# 3. If it deos not have tns_admin in the model, then the wallet must be in the archive
268+
if not has_tns_admin:
269+
wallet_path = archive_helper.extract_atp_wallet()
270+
if wallet_path:
271+
# update the model to add the tns_admin
272+
model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
273+
model_constants.DRIVER_PARAMS_NET_TNS_ADMIN] = wallet_path
274+
else:
275+
__logger.severe('WLSDPLY-12411', error=None, class_name=_class_name, method_name=_method_name)
276+
cla_helper.clean_up_temp_files()
277+
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
278+
279+
if not is_regular_db:
280+
System.setProperty('oracle.jdbc.fanEnabled', 'false')
281+
282+
277283
def _get_domain_path(model_context, model):
278284
"""
279285
Returns the domain home path.
@@ -332,16 +338,17 @@ def main(args):
332338
archive_helper = ArchiveHelper(archive_file_name, domain_path, __logger, ExceptionType.CREATE)
333339

334340
has_atp, has_ssl = validate_rcu_args_and_model(model_context, model_dictionary, archive_helper, aliases)
335-
336341
# check if there is an atpwallet and extract in the domain dir
337342
# it is to support non JRF domain but user wants to use ATP database
338-
if not has_atp and archive_helper:
343+
if has_atp and archive_helper:
339344
archive_helper.extract_atp_wallet()
340345

341346
creator = DomainCreator(model_dictionary, model_context, aliases)
342347
creator.create()
343348

344349
if has_atp:
350+
# if extracted_wallet_path is not None:
351+
# model_dictionary[DOMAIN_INFO][DRIVER_PARAMS_NET_TNS_ADMIN] = extracted_wallet_path
345352
rcu_properties_map = model_dictionary[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO]
346353
rcu_db_info = RcuDbInfo(model_context, aliases, rcu_properties_map)
347354
atp_helper.fix_jps_config(rcu_db_info, model_context)

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@
2828
RCU_PREFIX = 'rcu_prefix'
2929
RCU_SCHEMA_PASSWORD = 'rcu_schema_password'
3030
RCU_ADMIN_PASSWORD = 'rcu_admin_password'
31+
RCU_DEFAULT_TBLSPACE = 'rcu_default_tablespace'
32+
RCU_TEMP_TBLSPACE = 'rcu_temp_tablespace'
3133
RCU_DB_USER = 'rcu_db_user'
3234
RCU_DB_CONN = 'rcu_db_conn_string'
3335
RCU_COMP_INFO = 'compInfoXMLLocation'
3436
RCU_STG_INFO = 'storageXMLLocation'
3537
RCU_VARIABLES = 'rcu_variables'
38+
DATABASE_TYPE = 'databaseType'
3639
USE_ATP = 'useATP'
37-
ATP_TNS_ENTRY = 'tns.alias'
40+
TNS_ENTRY = 'tns.alias'
3841
ATP_DEFAULT_TABLESPACE = 'atp.default.tablespace'
3942
ATP_TEMPORARY_TABLESPACE = 'atp.temp.tablespace'
4043
ATP_ADMIN_USER = 'atp.admin.user'
@@ -280,8 +283,6 @@
280283
SOURCE_DESTINATION = 'SourceDestination'
281284
SQL_AUTHENTICATOR = 'SQLAuthenticator'
282285
SSL = 'SSL'
283-
SSL_ADMIN_USER = 'ssl.admin.user'
284-
SSL_TNS_ENTRY = 'tns.alias'
285286
STARTUP_CLASS = 'StartupClass'
286287
STORE = 'Store'
287288
SUB_DEPLOYMENT = 'SubDeployment'
@@ -360,7 +361,7 @@
360361
DRIVER_PARAMS_PROPERTY_VALUE_ENCRYPTED = 'EncryptedValueEncrypted'
361362
DRIVER_PARAMS_USER_PROPERTY = 'user'
362363
DRIVER_PARAMS_TRUSTSTORE_PROPERTY = 'javax.net.ssl.trustStore'
363-
DRIVER_PARAMS_kEYSTORE_PROPERTY = 'javax.net.ssl.keyStore'
364+
DRIVER_PARAMS_KEYSTORE_PROPERTY = 'javax.net.ssl.keyStore'
364365
DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY = 'javax.net.ssl.trustStoreType'
365366
DRIVER_PARAMS_KEYSTORETYPE_PROPERTY = 'javax.net.ssl.keyStoreType'
366367
DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY = 'javax.net.ssl.trustStorePassword'

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ def set_ssl_properties(xml_doc, atp_creds_path, keystore_password, truststore_pa
2525

2626
for prop in props:
2727
if prop.getAttribute('name') == 'props.db.1':
28+
set_property(dom_tree, prop, 'oracle.net.ssl_server_dn_match', 'true')
29+
set_property(dom_tree, prop, 'oracle.net.ssl_version', '1.2')
30+
set_property(dom_tree, prop, 'oracle.net.tns_admin', atp_creds_path)
2831
set_property(dom_tree, prop, 'javax.net.ssl.trustStoreType', 'JKS')
2932
set_property(dom_tree, prop, 'javax.net.ssl.trustStore', atp_creds_path + '/truststore.jks')
30-
set_property(dom_tree, prop, 'oracle.net.tns_admin', atp_creds_path)
3133
set_property(dom_tree, prop, 'javax.net.ssl.keyStoreType', 'JKS')
3234
set_property(dom_tree, prop, 'javax.net.ssl.keyStore', atp_creds_path + '/keystore.jks')
3335
set_property(dom_tree, prop, 'javax.net.ssl.keyStorePassword', keystore_password)
3436
set_property(dom_tree, prop, 'javax.net.ssl.trustStorePassword', truststore_password)
35-
set_property(dom_tree, prop, 'oracle.net.ssl_server_dn_match', 'true')
36-
set_property(dom_tree, prop, 'oracle.net.ssl_version', '1.2')
3737
# Persist the changes in the xml file
3838
file_handle = open(xml_doc, "w")
3939
dom_tree.writexml(file_handle)
@@ -56,14 +56,14 @@ def set_property(dom_tree, prop, name, value):
5656
prop.appendChild(newline)
5757

5858
def fix_jps_config(rcu_db_info, model_context):
59-
tns_admin = rcu_db_info.get_atp_tns_admin()
59+
tns_admin = rcu_db_info.get_tns_admin()
6060
keystore_password = rcu_db_info.get_keystore_password()
6161
truststore_password = rcu_db_info.get_truststore_password()
6262

63-
jsp_config = model_context.get_domain_home() + '/config/fmwconfig/jps-config.xml'
64-
jsp_config_jse = model_context.get_domain_home() + '/config/fmwconfig/jps-config-jse.xml'
65-
set_ssl_properties(jsp_config, tns_admin, keystore_password, truststore_password)
66-
set_ssl_properties(jsp_config_jse, tns_admin, keystore_password, truststore_password)
63+
jps_config = model_context.get_domain_home() + '/config/fmwconfig/jps-config.xml'
64+
jps_config_jse = model_context.get_domain_home() + '/config/fmwconfig/jps-config-jse.xml'
65+
set_ssl_properties(jps_config, tns_admin, keystore_password, truststore_password)
66+
set_ssl_properties(jps_config_jse, tns_admin, keystore_password, truststore_password)
6767

6868

6969
def get_atp_connect_string(tnsnames_ora_path, tns_sid_name):

0 commit comments

Comments
 (0)