Skip to content

Commit 20837b0

Browse files
committed
Merge branch 'wdt-860' into 'develop-4.0'
Refactoring RCU execution to support non-Oracle databases See merge request weblogic-cloud/weblogic-deploy-tooling!1654
2 parents 15280cd + a9eb266 commit 20837b0

File tree

62 files changed

+2762
-1884
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2762
-1884
lines changed

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

Lines changed: 166 additions & 212 deletions
Large diffs are not rendered by default.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates.
3+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
*/
5+
package oracle.weblogic.deploy.logging;
6+
7+
import java.util.ArrayList;
8+
import java.util.Arrays;
9+
import java.util.List;
10+
import java.util.logging.Level;
11+
import java.util.logging.LogRecord;
12+
13+
/**
14+
* Extend summary handler to collect message IDs for unit tests.
15+
*/
16+
public class TestSummaryHandler extends SummaryHandler {
17+
private final List<LogRecord> records = new ArrayList<>();
18+
19+
public int getMessageKeyCount(Level level, String key) {
20+
int count = 0;
21+
for(LogRecord record: records) {
22+
if((record.getLevel() == level) && key.equals(record.getMessage())) {
23+
count++;
24+
}
25+
}
26+
return count;
27+
}
28+
29+
// use to debug unit tests
30+
public void printDebug() {
31+
System.out.println();
32+
for(LogRecord record: records) {
33+
System.out.println(" " + record.getMessage() + ": " + record.getLevel()
34+
+ " " + Arrays.asList(record.getParameters()));
35+
}
36+
System.out.println();
37+
}
38+
39+
@Override
40+
public synchronized void publish(LogRecord logRecord) {
41+
records.add(logRecord);
42+
super.publish(logRecord);
43+
}
44+
}

core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2023, Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2024, Oracle and/or its affiliates.
33
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
*/
55
package oracle.weblogic.deploy.util;
@@ -73,6 +73,7 @@ public class WLSDeployArchive {
7373
* Default, top-level archive subdirectory where the database wallet for the RCU database is stored.
7474
*/
7575
public static final String DEFAULT_RCU_WALLET_PATH = ARCHIVE_DB_WALLETS_DIR + ZIP_SEP + DEFAULT_RCU_WALLET_NAME;
76+
public static final String DEPRECATED_RCU_WALLET_PATH = DEPRECATED_DB_WALLETS_DIR + ZIP_SEP + DEFAULT_RCU_WALLET_NAME;
7677

7778
/**
7879
* Top-level archive subdirectory where the opss wallet is stored.

core/src/main/python/create.py

Lines changed: 55 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,50 @@
44
55
The main module for the WLSDeploy tool to create empty domains.
66
"""
7+
import exceptions
78
import os
89
import sys
9-
import exceptions
1010

11-
from java.lang import Exception as JException
1211
from java.io import IOException
12+
from java.lang import Class as JClass
13+
from java.lang import Exception as JException
1314
from java.lang import IllegalArgumentException
1415
from java.lang import String
15-
from java.lang import System
16-
import java.sql.DriverManager as DriverManager
17-
import java.util.Properties as Properties
18-
16+
from java.sql import DriverManager
17+
from java.util import Properties
1918
from oracle.weblogic.deploy.create import CreateException
2019
from oracle.weblogic.deploy.deploy import DeployException
21-
from oracle.weblogic.deploy.validate import ValidateException
2220
from oracle.weblogic.deploy.util import FileUtils
2321
from oracle.weblogic.deploy.util import WLSDeployArchiveIOException
22+
from oracle.weblogic.deploy.validate import ValidateException
2423

2524
sys.path.insert(0, os.path.dirname(os.path.realpath(sys.argv[0])))
2625

2726
# imports from local packages start here
2827
from wlsdeploy.aliases.aliases import Aliases
29-
from wlsdeploy.aliases import model_constants
30-
from wlsdeploy.aliases.model_constants import DEFAULT_WLS_DOMAIN_NAME, PATH_TO_RCU_ADMIN_PASSWORD, \
31-
PATH_TO_RCU_SCHEMA_PASSWORD
28+
from wlsdeploy.aliases.model_constants import DEFAULT_WLS_DOMAIN_NAME
3229
from wlsdeploy.aliases.model_constants import DOMAIN_NAME
33-
from wlsdeploy.aliases.model_constants import PATH_TO_RCU_DB_CONN
34-
from wlsdeploy.aliases.model_constants import PATH_TO_RCU_PREFIX
3530
from wlsdeploy.aliases.model_constants import TOPOLOGY
3631
from wlsdeploy.aliases.wlst_modes import WlstModes
3732
from wlsdeploy.exception import exception_helper
3833
from wlsdeploy.exception.exception_types import ExceptionType
3934
from wlsdeploy.logging.platform_logger import PlatformLogger
40-
from wlsdeploy.tool.create.rcudbinfo_helper import RcuDbInfo
35+
from wlsdeploy.tool.create import rcudbinfo_helper
36+
from wlsdeploy.tool.create.jps_config_helper import JpsConfigHelper
4137
from wlsdeploy.tool.create.domain_creator import DomainCreator
4238
from wlsdeploy.tool.util import model_context_helper
4339
from wlsdeploy.tool.util.archive_helper import ArchiveList
4440
from wlsdeploy.tool.util.wlst_helper import WlstHelper
4541
from wlsdeploy.tool.util import wlst_helper
46-
from wlsdeploy.tool.validate.content_validator import CreateDomainContentValidator
42+
from wlsdeploy.tool.validate.create_content_validator import CreateDomainContentValidator
4743
from wlsdeploy.util import cla_helper
48-
from wlsdeploy.util import dictionary_utils
4944
from wlsdeploy.util import env_helper
5045
from wlsdeploy.util import getcreds
5146
from wlsdeploy.util import string_utils
5247
from wlsdeploy.util import tool_main
5348
from wlsdeploy.util.cla_utils import CommandLineArgUtil
5449
from wlsdeploy.util.cla_utils import TOOL_TYPE_CREATE
5550
from wlsdeploy.util.exit_code import ExitCode
56-
from wlsdeploy.tool.create import atp_helper
57-
from wlsdeploy.tool.create import ssl_helper
58-
import wlsdeploy.tool.create.rcudbinfo_helper as rcudbinfo_helper
5951

6052
wlst_helper.wlst_functions = globals()
6153

@@ -198,77 +190,6 @@ def __process_opss_args(optional_arg_map):
198190
optional_arg_map[CommandLineArgUtil.OPSS_WALLET_PASSPHRASE] = str(String(passphrase))
199191

200192

201-
def validate_rcu_args_and_model(model_context, model, archive_helper, aliases):
202-
_method_name = 'validate_rcu_args_and_model'
203-
204-
has_atpdbinfo = 0
205-
has_ssldbinfo = 0
206-
207-
domain_info = dictionary_utils.get_dictionary_element(model, model_constants.DOMAIN_INFO)
208-
209-
if model_context.get_domain_typedef().requires_rcu():
210-
if model_constants.RCU_DB_INFO in domain_info:
211-
rcu_info = domain_info[model_constants.RCU_DB_INFO]
212-
rcu_db_info = RcuDbInfo(model_context, aliases, rcu_info)
213-
214-
if string_utils.is_empty(rcu_db_info.get_rcu_prefix()):
215-
ex = exception_helper.create_validate_exception('WLSDPLY-12414', model_context.get_domain_type(),
216-
PATH_TO_RCU_PREFIX)
217-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
218-
raise ex
219-
#
220-
# Skip validating rcu_db_conn since is there is a tnsnames.ora file,
221-
# the connection string is picked up from there.
222-
#
223-
if string_utils.is_empty(rcu_db_info.get_rcu_schema_password()):
224-
ex = exception_helper.create_validate_exception('WLSDPLY-12414', model_context.get_domain_type(),
225-
PATH_TO_RCU_SCHEMA_PASSWORD)
226-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
227-
raise ex
228-
229-
if model_context.is_run_rcu() and string_utils.is_empty(rcu_db_info.get_rcu_admin_password()):
230-
ex = exception_helper.create_validate_exception('WLSDPLY-12415', model_context.get_domain_type(),
231-
CommandLineArgUtil.RUN_RCU_SWITCH, PATH_TO_RCU_ADMIN_PASSWORD)
232-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
233-
raise ex
234-
235-
has_tns_admin = rcu_db_info.has_tns_admin()
236-
is_regular_db = rcu_db_info.is_regular_db()
237-
has_atpdbinfo = rcu_db_info.has_atpdbinfo()
238-
has_ssldbinfo = rcu_db_info.has_ssldbinfo()
239-
240-
_validate_atp_wallet_in_archive(archive_helper, is_regular_db, has_tns_admin, model)
241-
else:
242-
ex = exception_helper.create_validate_exception('WLSDPLY-12408', model_context.get_domain_type(),
243-
PATH_TO_RCU_DB_CONN, PATH_TO_RCU_PREFIX,
244-
PATH_TO_RCU_ADMIN_PASSWORD, PATH_TO_RCU_SCHEMA_PASSWORD)
245-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
246-
raise ex
247-
248-
return has_atpdbinfo, has_ssldbinfo
249-
250-
251-
def _validate_atp_wallet_in_archive(archive_helper, is_regular_db, has_tns_admin, model):
252-
_method_name = '_validate_atp_wallet_in_archive'
253-
if archive_helper and not is_regular_db:
254-
# 1. If it does not have the oracle.net.tns_admin specified, then see if it was extracted
255-
# 2. If it is plain old regular oracle db, do nothing
256-
# 3. If it does not have tns_admin in the model, then the wallet must be in the archive
257-
if not has_tns_admin:
258-
wallet_path = archive_helper.check_rcu_wallet_path()
259-
if wallet_path:
260-
# update the model to add the tns_admin
261-
model[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO][
262-
model_constants.DRIVER_PARAMS_NET_TNS_ADMIN] = wallet_path
263-
else:
264-
ex = exception_helper.create_validate_exception('WLSDPLY-12411')
265-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
266-
raise ex
267-
268-
if not is_regular_db:
269-
System.setProperty('oracle.jdbc.fanEnabled', 'false')
270-
271-
272193
def _get_domain_path(model_context, model):
273194
"""
274195
Returns the domain home path.
@@ -286,26 +207,31 @@ def _get_domain_path(model_context, model):
286207

287208

288209
def _precheck_rcu_connectivity(model_context, creator, rcu_db_info):
289-
290210
_method_name = '_precheck_rcu_connectivity'
211+
__logger.entering(class_name=_class_name, method_name=_method_name)
212+
291213
domain_typename = model_context.get_domain_typedef().get_domain_type()
214+
if model_context.get_domain_typedef().requires_rcu() and not model_context.is_run_rcu():
215+
rcu_prefix = rcu_db_info.get_rcu_prefix()
216+
schema_name = None
217+
if not string_utils.is_empty(rcu_prefix):
218+
user_name = model_context.get_weblogic_helper().get_stb_user_name(rcu_prefix)
219+
schema_name = user_name[len(rcu_prefix) + 1:]
220+
221+
if schema_name is None or schema_name not in model_context.get_domain_typedef().get_rcu_schemas():
222+
__logger.exiting(class_name=_class_name, method_name=_method_name)
223+
return
292224

293-
if model_context.get_domain_typedef().requires_rcu() and not model_context.is_run_rcu() and 'STB' in \
294-
model_context.get_domain_typedef().get_rcu_schemas():
295-
# how to create rcu_db_info ?
296225
db_conn_props = None
297-
fmw_database, is_atp_ds, is_ssl_ds, keystore, keystore_pwd, keystore_type, rcu_prefix, rcu_schema_pwd, \
298-
tns_admin, truststore, truststore_pwd, \
299-
truststore_type = creator.get_rcu_basic_connection_info(rcu_db_info)
300-
301-
if is_atp_ds:
302-
db_conn_props = creator.get_atp_standard_conn_properties(tns_admin, truststore, truststore_pwd,
303-
truststore_type, keystore_pwd, keystore_type,
304-
keystore)
305-
elif is_ssl_ds:
306-
db_conn_props = creator.get_ssl_standard_conn_properties(tns_admin, truststore, truststore_pwd,
307-
truststore_type, keystore_pwd, keystore_type,
308-
keystore)
226+
227+
rcu_database_type = rcu_db_info.get_rcu_database_type()
228+
tns_admin, rcu_prefix, jdbc_conn_string, rcu_schema_pwd = \
229+
creator.get_rcu_datasource_basic_connection_info(rcu_db_info)
230+
231+
if rcu_db_info.is_use_atp() or rcu_db_info.is_use_ssl():
232+
db_conn_props = creator.get_jdbc_ssl_connection_properties(tns_admin, rcu_db_info.is_use_atp(), rcu_db_info)
233+
234+
jdbc_driver_name = creator.get_jdbc_driver_class_name(rcu_database_type)
309235

310236
try:
311237
props = Properties()
@@ -314,24 +240,29 @@ def _precheck_rcu_connectivity(model_context, creator, rcu_db_info):
314240
for key in item.keys():
315241
props.put(key, item[key])
316242

317-
__logger.info('WLSDPLY_12575', 'test datasource', fmw_database, rcu_prefix + "_STB", props,
318-
class_name=_class_name, method_name=_method_name)
243+
__logger.info('WLSDPLY_12575', 'test datasource', jdbc_conn_string, schema_name, props,
244+
class_name=_class_name, method_name=_method_name)
319245

320-
props.put('user', rcu_prefix + "_STB")
246+
props.put('user', user_name)
321247
props.put('password', rcu_schema_pwd)
322248

323-
DriverManager.getConnection(fmw_database, props)
249+
# Force the driver to be loaded and registered...
250+
JClass.forName(jdbc_driver_name)
251+
DriverManager.getConnection(jdbc_conn_string, props)
324252

325253
except (exceptions.Exception, JException), e:
326-
ex = exception_helper.create_create_exception('WLSDPLY-12505', domain_typename, e.getClass().getName(),
327-
e.getLocalizedMessage(), error=e)
254+
ex = exception_helper.create_create_exception('WLSDPLY-12505', domain_typename,
255+
e.getClass().getName(), e.getLocalizedMessage(), error=e)
328256
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
329257
raise ex
330258
except ee:
331259
ex = exception_helper.create_create_exception('WLSDPLY-12506', domain_typename, error=ee)
332260
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
333261
raise ex
334262

263+
__logger.exiting(class_name=_class_name, method_name=_method_name)
264+
265+
335266
def main(model_context):
336267
"""
337268
The entry point for the createDomain tool.
@@ -353,24 +284,23 @@ def main(model_context):
353284
# set domain home result in model context, for use by deployers and helpers
354285
model_context.set_domain_home(_get_domain_path(model_context, model_dictionary))
355286

356-
# check for any content problems in the merged, substituted model
357-
content_validator = CreateDomainContentValidator(model_context, aliases)
358-
content_validator.validate_model(model_dictionary)
359-
360287
archive_helper = None
361288
archive_file_name = model_context.get_archive_file_name()
362289
if archive_file_name:
363-
domain_path = _get_domain_path(model_context, model_dictionary)
364290
archive_helper = ArchiveList(archive_file_name, model_context, ExceptionType.CREATE)
365-
if archive_helper:
366-
if not os.path.exists(os.path.abspath(domain_path)):
367-
os.mkdir(os.path.abspath(domain_path))
368291

369-
archive_helper.extract_all_database_wallets()
370-
archive_helper.extract_custom_directory()
371-
archive_helper.extract_weblogic_remote_console_extension()
292+
# check for any content problems in the merged, substituted model
293+
content_validator = CreateDomainContentValidator(model_context, archive_helper, aliases)
294+
content_validator.validate_model(model_dictionary)
295+
296+
if archive_helper:
297+
domain_path = _get_domain_path(model_context, model_dictionary)
298+
if not os.path.exists(os.path.abspath(domain_path)):
299+
os.mkdir(os.path.abspath(domain_path))
372300

373-
has_atp, has_ssl = validate_rcu_args_and_model(model_context, model_dictionary, archive_helper, aliases)
301+
archive_helper.extract_all_database_wallets()
302+
archive_helper.extract_custom_directory()
303+
archive_helper.extract_weblogic_remote_console_extension()
374304

375305
creator = DomainCreator(model_dictionary, model_context, aliases)
376306

@@ -382,10 +312,8 @@ def main(model_context):
382312
creator.create()
383313

384314
if model_context.get_domain_typedef().requires_rcu():
385-
if has_atp:
386-
atp_helper.fix_jps_config(rcu_db_info, model_context)
387-
elif has_ssl:
388-
ssl_helper.fix_jps_config(rcu_db_info, model_context)
315+
jps_config_helper = JpsConfigHelper(model_context, rcu_db_info)
316+
jps_config_helper.fix_jps_config()
389317

390318
except WLSDeployArchiveIOException, ex:
391319
_exit_code = ExitCode.ERROR

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
APP_DIR = 'AppDir'
2525
APPEND = 'append'
2626
APPLICATION = 'Application'
27-
ATP_DEFAULT_TABLESPACE = 'atp.default.tablespace'
28-
ATP_TEMPORARY_TABLESPACE = 'atp.temp.tablespace'
27+
ATP_DEFAULT_TABLESPACE = 'atp.default.tablespace' # deprecated field name in 4.0
28+
ATP_TEMPORARY_TABLESPACE = 'atp.temp.tablespace' # deprecated field name in 4.0
2929
AUDITOR = 'Auditor'
3030
AUTHENTICATION_PROVIDER = 'AuthenticationProvider'
3131
AUTHORIZER = 'Authorizer'
@@ -75,7 +75,10 @@
7575
CROSS_DOMAIN = 'CrossDomain'
7676
CUSTOM_DBMS_AUTHENTICATOR = 'CustomDBMSAuthenticator'
7777
DATA_SOURCE = 'DataSource'
78+
79+
# Deprecated in WDT 4.0.0
7880
DATABASE_TYPE = 'databaseType'
81+
7982
DEFAULT_ADJUDICATOR = 'DefaultAdjudicator'
8083
DEFAULT_ADMIN_SERVER_NAME = 'AdminServer'
8184
DEFAULT_AUDITOR = 'DefaultAuditor'
@@ -204,6 +207,7 @@
204207
# deprecated field name in 4.0
205208
OPSS_SECRETS = 'OPSSSecrets'
206209
OPSS_WALLET_PASSPHRASE = 'OPSSWalletPassphrase'
210+
ORACLE_DATABASE_CONNECTION_TYPE = 'oracle_database_connection_type'
207211
ORACLE_OID_AUTHENTICATOR = 'OracleInternetDirectoryAuthenticator'
208212
ORACLE_OUD_AUTHENTICATOR = 'OracleUnifiedDirectoryAuthenticator'
209213
ORACLE_OVD_AUTHENTICATOR = 'OracleVirtualDirectoryAuthenticator'
@@ -233,13 +237,16 @@
233237
RCU_ADMIN_PASSWORD = 'rcu_admin_password'
234238
RCU_ADMIN_USER = 'rcu_admin_user'
235239
RCU_COMP_INFO = 'compInfoXMLLocation'
236-
RCU_DB_CONN = 'rcu_db_conn_string'
240+
RCU_DATABASE_TYPE = 'rcu_database_type'
241+
RCU_DB_CONN_STRING = 'rcu_db_conn_string'
237242
RCU_DB_INFO = 'RCUDbInfo'
238243
RCU_DEFAULT_TABLESPACE = 'rcu_default_tablespace'
244+
RCU_EDITION = 'rcu_edition'
239245
RCU_PREFIX = 'rcu_prefix'
240246
RCU_SCHEMA_PASSWORD = 'rcu_schema_password'
241247
RCU_STG_INFO = 'storageXMLLocation'
242248
RCU_TEMP_TBLSPACE = 'rcu_temp_tablespace'
249+
RCU_UNICODE_SUPPORT = 'rcu_unicode_support'
243250
RCU_VARIABLES = 'rcu_variables'
244251
REMOTE_CONSOLE_HELPER = 'RemoteConsoleHelper'
245252
REMOTE_DOMAIN = 'RemoteDomain'
@@ -471,7 +478,7 @@
471478
]
472479

473480
# Model Path constants
474-
PATH_TO_RCU_DB_CONN = '%s:/%s/%s' % (DOMAIN_INFO, RCU_DB_INFO, RCU_DB_CONN)
481+
PATH_TO_RCU_DB_CONN = '%s:/%s/%s' % (DOMAIN_INFO, RCU_DB_INFO, RCU_DB_CONN_STRING)
475482
PATH_TO_RCU_PREFIX = '%s:/%s/%s' % (DOMAIN_INFO, RCU_DB_INFO, RCU_PREFIX)
476483
PATH_TO_RCU_ADMIN_PASSWORD = '%s:/%s/%s' % (DOMAIN_INFO, RCU_DB_INFO, RCU_ADMIN_PASSWORD)
477484
PATH_TO_RCU_SCHEMA_PASSWORD = '%s:/%s/%s' % (DOMAIN_INFO, RCU_DB_INFO, RCU_SCHEMA_PASSWORD)

0 commit comments

Comments
 (0)