Skip to content

Commit c5ac612

Browse files
authored
Atp harden error detection (#845)
* harden error detection for atp rcu db info. * refactor validate atp rcudbinfo into function for reuse * update check for non atp also * update error message text * Update rcuinfo.md * fix system test problem
1 parent 6a334f9 commit c5ac612

File tree

5 files changed

+91
-11
lines changed

5 files changed

+91
-11
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def fix_jps_config(rcu_db_info, model_context):
6464

6565
def get_atp_connect_string(tnsnames_ora_path, tns_sid_name):
6666

67-
6867
try:
6968
f = open(tnsnames_ora_path, "r+")
7069
try:

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

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ def __run_rcu(self):
286286
if rcu_db_info.is_use_atp():
287287
# ATP database, build runner map from RCUDbInfo in the model.
288288

289+
# check it first
290+
self.__retrieve_atp_rcudbinfo(rcu_db_info, True)
289291
# make a copy of model's map to pass to RCURunner, since we will modify some values
290292
rcu_properties_map = self.model.get_model_domain_info()[RCU_DB_INFO]
291293
rcu_runner_map = dict(rcu_properties_map)
@@ -893,6 +895,61 @@ def __set_atp_connection_property(self, root_location, property_name, property_v
893895

894896
root_location.remove_name_token(property_name)
895897

898+
def __retrieve_atp_rcudbinfo(self, rcu_db_info, checkAdminPwd=False):
899+
"""
900+
Check and return atp connection info and make sure atp rcudb info is complete
901+
:raises: CreateException: if an error occurs
902+
"""
903+
_method_name = '__retrieve_atp_rcudbinfo'
904+
905+
tns_admin = rcu_db_info.get_atp_tns_admin()
906+
907+
if tns_admin is None or not os.path.exists(tns_admin + os.sep + "tnsnames.ora"):
908+
ex = exception_helper.create_create_exception('WLSDPLY-12562')
909+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
910+
raise ex
911+
912+
if rcu_db_info.get_atp_entry() is None:
913+
ex = exception_helper.create_create_exception('WLSDPLY-12413','tns.alias',
914+
"['tns.alias','javax.net.ssl.keyStorePassword',"
915+
"'javax.net.ssl.trustStorePassword']")
916+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
917+
raise ex
918+
919+
rcu_database = atp_helper.get_atp_connect_string(tns_admin + os.sep + 'tnsnames.ora',
920+
rcu_db_info.get_atp_entry())
921+
922+
if rcu_database is None:
923+
ex = exception_helper.create_create_exception('WLSDPLY-12563', rcu_db_info.get_atp_entry())
924+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
925+
raise ex
926+
927+
keystore_pwd = rcu_db_info.get_keystore_password()
928+
truststore_pwd = rcu_db_info.get_truststore_password()
929+
930+
if keystore_pwd is None:
931+
ex = exception_helper.create_create_exception('WLSDPLY-12413','javax.net.ssl.keyStorePassword',
932+
"['tns.alias','javax.net.ssl.keyStorePassword',"
933+
"'javax.net.ssl.trustStorePassword']")
934+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
935+
raise ex
936+
937+
if truststore_pwd is None:
938+
ex = exception_helper.create_create_exception('WLSDPLY-12413','javax.net.ssl.trustStorePassword',
939+
"['tns.alias','javax.net.ssl.keyStorePassword',"
940+
"'javax.net.ssl.trustStorePassword']")
941+
raise ex
942+
943+
if checkAdminPwd:
944+
admin_pwd = rcu_db_info.get_admin_password()
945+
if admin_pwd is None:
946+
ex = exception_helper.create_create_exception('WLSDPLY-12413','rcu_admin_password',
947+
"['rcu_prefix','rcu_schema_password',"
948+
"'rcu_admin_password']")
949+
raise ex
950+
951+
return tns_admin, rcu_database, keystore_pwd, truststore_pwd
952+
896953
def __configure_fmw_infra_database(self):
897954
"""
898955
Configure the FMW Infrastructure DataSources.
@@ -911,19 +968,29 @@ def __configure_fmw_infra_database(self):
911968
rcu_prefix = rcu_db_info.get_preferred_prefix()
912969
rcu_schema_pwd = rcu_db_info.get_preferred_schema_pass()
913970

971+
if rcu_prefix is None:
972+
ex = exception_helper.create_create_exception('WLSDPLY-12413','rcu_prefix',
973+
"['rcu_prefix','rcu_schema_password']")
974+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
975+
raise ex
976+
977+
if rcu_schema_pwd is None:
978+
ex = exception_helper.create_create_exception('WLSDPLY-12413','rcu_schema_password',
979+
"['rcu_prefix','rcu_schema_password']")
980+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
981+
raise ex
982+
914983
# For ATP databases : we need to set all the property for each datasource
915984
# load atp connection properties from properties file
916985
# HANDLE ATP case
917986

918987
if rcu_db_info.has_atpdbinfo():
919988
has_atp = 1
920989
# parse the tnsnames.ora file and retrieve the connection string
921-
tns_admin = rcu_db_info.get_atp_tns_admin()
922-
rcu_database = atp_helper.get_atp_connect_string(tns_admin + os.sep + 'tnsnames.ora',
923-
rcu_db_info.get_atp_entry())
990+
# tns_admin is the wallet path either the path to $DOMAIN_HOME/atpwallet or
991+
# specified in RCUDbinfo.oracle.net.tns_admin
924992

925-
keystore_pwd = rcu_db_info.get_keystore_password()
926-
truststore_pwd = rcu_db_info.get_truststore_password()
993+
tns_admin, rcu_database, keystore_pwd, truststore_pwd = self.__retrieve_atp_rcudbinfo(rcu_db_info)
927994

928995
# Need to set for the connection property for each datasource
929996

@@ -988,9 +1055,11 @@ def __configure_fmw_infra_database(self):
9881055
if not has_atp:
9891056
rcu_database = rcu_db_info.get_preferred_db()
9901057
if rcu_database is None:
991-
return
1058+
ex = exception_helper.create_create_exception('WLSDPLY-12564')
1059+
raise ex
9921060

9931061
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
1062+
9941063
self.logger.fine('WLSDPLY-12221', fmw_database, class_name=self.__class_name, method_name=_method_name)
9951064

9961065
svc_table_ds_name = self.wls_helper.get_jrf_service_table_datasource_name()

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ def is_jrf_domain_type(self):
115115
This returns False for the Restricted JRF domain type.
116116
:return: True if the JRF template is present
117117
"""
118+
if self.is_restricted_jrf_domain_type():
119+
return False
118120
for template in self.get_extension_templates():
119121
if re.match(self.JRF_TEMPLATE_REGEX, template):
120122
return True

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,14 @@ WLSDPLY-12258=RCU {0} file {1} is invalid : {2}
13011301
WLSDPLY-12259=Error creating directory {0} to extract RCU {1} file {2}
13021302
WLSDPLY-12560=Dynamic cluster {0} has size of {1}
13031303
WLSDPLY-12561=Dynamic cluster {0} set to size of {1}
1304+
WLSDPLY-12562=Unable to get ATP database connection info: cannot find ATP tnsnames.ora file. Please make sure \
1305+
you have the correct ATP wallet in the archive file or RCUDbInfo.oracle.net.tns_admin is pointing to an unzipped \
1306+
ATP wallet root directory that contains the tnsnames.ora file.
1307+
WLSDPLY-12563=Unable to retrieve database connection info, please make sure the the entry {0} specified in \
1308+
RCUDbInfo.tns.alias exists in the tnsnames.ora file in the ATP wallet.
1309+
WLSDPLY-12564=Unable to retrieve database connection string, please make sure it is specified in \
1310+
RCUDbInfo.rcu_db_conn_string field or in command line argument '-rcu_database'.
1311+
13041312

13051313
# domain_typedef.py
13061314
WLSDPLY-12300={0} got the domain type {1} but the domain type definition file {2} was not valid: {3}

site/rcuinfo.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@ domainInfo:
99
RCUDbInfo:
1010
useATP : true
1111
rcu_prefix : DEV
12-
rcu_admin_password: <database admin password is required only when you specify -run_rcu flag, will be prompted
13-
if not specified>
14-
rcu_schema_password : <RCU schema password, user will be prompted if not specified>
12+
rcu_admin_password: <database admin password is required only when you specify -run_rcu flag>
13+
rcu_schema_password : <RCU schema password>
1514
atp.admin.user : admin
1615
tns.alias : dbatp_tp
1716
javax.net.ssl.keyStorePassword : <atp wallet password>
1817
javax.net.ssl.trustStorePassword : <atp wallet password>
18+
oracle.net.tns_admin: <optional: absolute path of the unzipped wallet root directory (outside of the archive), if the wallet.zip is not included in the archive>
1919
```
2020
The database wallet can be included in the archive file under `atpwallet` zipentry structure
2121

2222
`atpwallet/Walletxyz.zip`
23-
23+
24+
or by specifying the unzipped root directory of the ATP wallet zip file in `oracle.net.tns_admin`.
25+
2426
Using the Create Domain Tool with the `-run_rcu` flag will create the RCU schemas against the Oracle Autonomous Transaction Processing Cloud Database and configure the datasources in the JRF domain to use the database. For example:
2527

2628
weblogic-deploy/bin/createDomain.sh -oracle_home /u01/wls12213 -domain_type JRF -domain_home /u01/data/domains/demodomain -archive_file DemoDomain.zip -run_rcu

0 commit comments

Comments
 (0)