Skip to content

Owls 741 verify jfr db connectivity #1432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 66 additions & 8 deletions core/src/main/python/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
"""
import os
import sys
import exceptions

from java.lang import Exception as JException
from java.io import IOException
from java.lang import IllegalArgumentException
from java.lang import String
from java.lang import System
import java.sql.DriverManager as DriverManager
import java.util.Properties as Properties

from oracle.weblogic.deploy.create import CreateException
from oracle.weblogic.deploy.deploy import DeployException
from oracle.weblogic.deploy.util import FileUtils
Expand Down Expand Up @@ -45,6 +50,7 @@
from wlsdeploy.util.weblogic_helper import WebLogicHelper
from wlsdeploy.tool.create import atp_helper
from wlsdeploy.tool.create import ssl_helper
import wlsdeploy.tool.create.rcudbinfo_helper as rcudbinfo_helper

wlst_helper.wlst_functions = globals()

Expand Down Expand Up @@ -296,6 +302,54 @@ def _get_domain_path(model_context, model):
return domain_parent + os.sep + DEFAULT_WLS_DOMAIN_NAME


def _precheck_rcu_connectivity(model_context, creator, rcu_db_info):

_method_name = '_precheck_rcu_connectivity'
domain_typename = model_context.get_domain_typedef().get_domain_type()

if model_context.get_domain_typedef().required_rcu() and not model_context.is_run_rcu() and 'STB' in \
model_context.get_domain_typedef().get_rcu_schemas():
# how to create rcu_db_info ?
db_conn_props = None
fmw_database, is_atp_ds, is_ssl_ds, keystore, keystore_pwd, keystore_type, rcu_prefix, rcu_schema_pwd, \
tns_admin, truststore, truststore_pwd, \
truststore_type = creator.get_rcu_basic_connection_info(rcu_db_info)

if is_atp_ds:
db_conn_props = creator.get_atp_standard_conn_properties(tns_admin, truststore, truststore_pwd,
truststore_type, keystore_pwd, keystore_type,
keystore)
elif is_ssl_ds:
db_conn_props = creator.get_ssl_standard_conn_properties(tns_admin, truststore, truststore_pwd,
truststore_type, keystore_pwd, keystore_type,
keystore)

try:
props = Properties()
if db_conn_props is not None:
for item in db_conn_props:
for key in item.keys():
props.put(key, item[key])

__logger.info('WLSDPLY_12575', 'test datasource', fmw_database, rcu_prefix + "_STB", props,
class_name=_class_name, method_name=_method_name)

props.put('user', rcu_prefix + "_STB")
props.put('password', rcu_schema_pwd)

DriverManager.getConnection(fmw_database, props)

except (exceptions.Exception, JException), e:
__logger.severe('WLSDPLY-12505', domain_typename, e.getClass().getName(), e.getLocalizedMessage())
ex = exception_helper.create_create_exception('WLSDPLY-12505', domain_typename, e.getClass().getName(),
e.getLocalizedMessage(), error=e)
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
raise ex
except ee:
ex = exception_helper.create_create_exception('WLSDPLY-12506', domain_typename, ee)
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
raise ex

def main(model_context):
"""
The entry point for the createDomain tool.
Expand Down Expand Up @@ -337,16 +391,20 @@ def main(model_context):
archive_helper.extract_all_database_wallets()

creator = DomainCreator(model_dictionary, model_context, aliases)

rcu_db_info = rcudbinfo_helper.create(model_dictionary, model_context, aliases)

Copy link
Member

@rakillen rakillen Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a static method that does all these checks:

        rcu_db_info = rcudbinfo_helper.create(model_dictionary, model_context, aliases)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed

# JRF domain pre-check connectivity
_precheck_rcu_connectivity(model_context, creator, rcu_db_info)

creator.create()

if has_atp:
rcu_properties_map = model_dictionary[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO]
rcu_db_info = RcuDbInfo(model_context, aliases, rcu_properties_map)
atp_helper.fix_jps_config(rcu_db_info, model_context)
elif has_ssl:
rcu_properties_map = model_dictionary[model_constants.DOMAIN_INFO][model_constants.RCU_DB_INFO]
rcu_db_info = RcuDbInfo(model_context, aliases, rcu_properties_map)
ssl_helper.fix_jps_config(rcu_db_info, model_context)
if model_context.get_domain_typedef().required_rcu():
if has_atp:
atp_helper.fix_jps_config(rcu_db_info, model_context)
elif has_ssl:
ssl_helper.fix_jps_config(rcu_db_info, model_context)

except WLSDeployArchiveIOException, ex:
_exit_code = ExitCode.ERROR
__logger.severe('WLSDPLY-12409', _program_name, ex.getLocalizedMessage(), error=ex,
Expand Down
152 changes: 111 additions & 41 deletions core/src/main/python/wlsdeploy/tool/create/domain_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,6 @@ def __validate_and_get_atp_rcudbinfo(self, rcu_db_info, check_admin_pwd=False):
keystore_type = rcu_db_info.get_keystore_type()
truststore = rcu_db_info.get_truststore()
keystore = rcu_db_info.get_keystore()

if keystore_pwd is None and keystore_type != 'SSO':
ex = exception_helper.create_create_exception('WLSDPLY-12413','javax.net.ssl.keyStorePassword',
"['tns.alias','javax.net.ssl.keyStorePassword',"
Expand All @@ -1092,7 +1091,8 @@ def __validate_and_get_atp_rcudbinfo(self, rcu_db_info, check_admin_pwd=False):
"'rcu_admin_password']")
raise ex

return tns_admin, rcu_database, truststore_pwd, truststore_type, truststore, keystore_pwd, keystore_type, keystore
return tns_admin, rcu_database, truststore_pwd, truststore_type, truststore, keystore_pwd, keystore_type, \
keystore

def __validate_and_get_ssl_rcudbinfo(self, rcu_db_info, check_admin_pwd=False):
"""
Expand Down Expand Up @@ -1175,45 +1175,8 @@ def __set_rcu_datasource_parameters_without_shadow_table(self, rcu_db_info):
"""
_method_name = 'set_rcu_datasource_parameters'

rcu_prefix = rcu_db_info.get_preferred_prefix()
rcu_schema_pwd = rcu_db_info.get_preferred_schema_pass()

if rcu_prefix is None:
ex = exception_helper.create_create_exception('WLSDPLY-12413','rcu_prefix',
"['rcu_prefix','rcu_schema_password']")
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
raise ex

if rcu_schema_pwd is None:
ex = exception_helper.create_create_exception('WLSDPLY-12413','rcu_schema_password',
"['rcu_prefix','rcu_schema_password']")
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
raise ex


# For ATP databases : we need to set all the property for each datasource
# load atp connection properties from properties file
# HANDLE ATP case
is_atp_ds = rcu_db_info.is_use_atp()
is_ssl_ds = rcu_db_info.is_use_ssl()

if is_atp_ds:
tns_admin, rcu_database, truststore_pwd, truststore_type, \
truststore, keystore_pwd, keystore_type, keystore = self.__validate_and_get_atp_rcudbinfo(rcu_db_info)
elif is_ssl_ds:
tns_admin, rcu_database, truststore_pwd, truststore_type, \
truststore, keystore_pwd, keystore_type, keystore = self.__validate_and_get_ssl_rcudbinfo(rcu_db_info)
else:
rcu_database = rcu_db_info.get_preferred_db()

if rcu_database is None:
ex = exception_helper.create_create_exception('WLSDPLY-12564')
raise ex

# Need to set for the connection property for each datasource

fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
self.logger.fine('WLSDPLY-12221', fmw_database, class_name=self.__class_name, method_name=_method_name)
fmw_database, is_atp_ds, is_ssl_ds, keystore, keystore_pwd, keystore_type, rcu_prefix, rcu_schema_pwd, \
tns_admin, truststore, truststore_pwd, truststore_type = self.get_rcu_basic_connection_info(rcu_db_info)

location = LocationContext()
location.append_location(JDBC_SYSTEM_RESOURCE)
Expand Down Expand Up @@ -1566,3 +1529,110 @@ def __configure_opss_secrets(self):
self.wlst_helper.set_shared_secret_store_with_password(opss_wallet, opss_secret_password)

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

def get_rcu_basic_connection_info(self, rcu_db_info):

_method_name = 'get_rcu_basic_connection_info'

keystore = None
keystore_pwd = None
keystore_type = None
tns_admin = None
truststore = None
truststore_pwd = None
truststore_type = None

rcu_prefix = rcu_db_info.get_preferred_prefix()
rcu_schema_pwd = rcu_db_info.get_preferred_schema_pass()
if rcu_prefix is None:
ex = exception_helper.create_create_exception('WLSDPLY-12413', 'rcu_prefix',
"['rcu_prefix','rcu_schema_password']")
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
raise ex
if rcu_schema_pwd is None:
ex = exception_helper.create_create_exception('WLSDPLY-12413', 'rcu_schema_password',
"['rcu_prefix','rcu_schema_password']")
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
raise ex

# For ATP databases : we need to set all the property for each datasource
# load atp connection properties from properties file
# HANDLE ATP case

is_atp_ds = rcu_db_info.is_use_atp()
is_ssl_ds = rcu_db_info.is_use_ssl()
if is_atp_ds:
tns_admin, rcu_database, truststore_pwd, truststore_type, \
truststore, keystore_pwd, keystore_type, keystore = self.__validate_and_get_atp_rcudbinfo(rcu_db_info)
elif is_ssl_ds:
tns_admin, rcu_database, truststore_pwd, truststore_type, \
truststore, keystore_pwd, keystore_type, keystore = self.__validate_and_get_ssl_rcudbinfo(rcu_db_info)
else:
rcu_database = rcu_db_info.get_preferred_db()
if rcu_database is None:
ex = exception_helper.create_create_exception('WLSDPLY-12564')
raise ex

# Need to set for the connection property for each datasource
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
self.logger.fine('WLSDPLY-12221', fmw_database, class_name=self.__class_name, method_name=_method_name)

return fmw_database, is_atp_ds, is_ssl_ds, keystore, keystore_pwd, keystore_type, rcu_prefix, rcu_schema_pwd, \
tns_admin, truststore, truststore_pwd, truststore_type

def get_ssl_standard_conn_properties(self, tns_admin, truststore, truststore_pwd,
truststore_type, keystore_pwd, keystore_type, keystore):
properties_set = []

# Should always have trust store
properties_set.append({DRIVER_PARAMS_TRUSTSTORE_PROPERTY: self.__get_store_path(tns_admin, truststore)})

properties_set.append({DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY: truststore_type})

# if not sso type then user must provide pwd
if truststore_pwd is not None and truststore_pwd != 'None':
properties_set.append({DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY: truststore_pwd})

if keystore_pwd is not None and keystore_pwd != 'None':
properties_set.append({DRIVER_PARAMS_KEYSTOREPWD_PROPERTY: keystore_pwd})

# if it is 2 ways SSL
if keystore is not None and keystore != 'None':
properties_set.append({DRIVER_PARAMS_KEYSTORE_PROPERTY: self.__get_store_path(tns_admin, keystore)})

if keystore_type is not None and keystore_type != 'None':
properties_set.append({DRIVER_PARAMS_KEYSTORETYPE_PROPERTY: keystore_type})

return properties_set

def get_atp_standard_conn_properties(self, tns_admin, truststore, truststore_pwd,
truststore_type, keystore_pwd, keystore_type, keystore):

keystore, keystore_type, truststore, truststore_type = atp_helper.fix_store_type_and_default_value(keystore,
keystore_type, truststore, truststore_type)

properties_set = []

properties_set.append({DRIVER_PARAMS_KEYSTORE_PROPERTY: self.__get_store_path(tns_admin,
keystore)})

properties_set.append({DRIVER_PARAMS_KEYSTORETYPE_PROPERTY: keystore_type})

if keystore_pwd:
properties_set.append({DRIVER_PARAMS_KEYSTOREPWD_PROPERTY: keystore_pwd})

properties_set.append({DRIVER_PARAMS_TRUSTSTORE_PROPERTY: self.__get_store_path(tns_admin,
truststore)})

properties_set.append({DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY: truststore_type})

if truststore_pwd:
properties_set.append({DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY: truststore_pwd})

properties_set.append({DRIVER_PARAMS_NET_SSL_VERSION: DRIVER_PARAMS_NET_SSL_VERSION_VALUE})

properties_set.append({DRIVER_PARAMS_NET_SERVER_DN_MATCH_PROPERTY: 'true'})
properties_set.append({DRIVER_PARAMS_NET_TNS_ADMIN: tns_admin})
properties_set.append({DRIVER_PARAMS_NET_FAN_ENABLED: 'false'})

return properties_set
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ WLSDPLY-12572=Failed to create domain because either RCUDbinfo is missing rcu_db
in command line option
WLSDPLY-12573=Invalid databaseType specified in RCUDbInfo: {0}. It must be 'SSL' or 'ATP'
WLSDPLY-12574=Path: {0} specified for JDBC driver property: {1} does not exists. Please check your model's RCUDbInfo section.
WLSDPLY_12575=Setting rcu datasource {0} driver params - url: {1} schema: {2} properties: {3}
WLSDPLY_12575=Setting rcu datasource {0} driver params - url: {1}. schema: {2}. properties: {3}.

# domain_typedef.py
WLSDPLY-12300={0} got the domain type {1} but the domain type definition file {2} was not valid: {3}
Expand Down Expand Up @@ -1500,6 +1500,8 @@ WLSDPLY-12501=The role {0} has no specified expression value and will be ignored
WLSDPLY-12502=The role {0} is not a WebLogic global role and will use the expression as specified
WLSDPLY-12503=The role {0} specifies an invalid update mode and will use the default replace mode
WLSDPLY-12504=The processing of WebLogic roles from the model is not support with WebLogic Server version {0}
WLSDPLY-12505={0} domain creation precheck failed. {1}: {2}
WLSDPLY-12506={0} domain creation precheck failed. {1}

###############################################################################
# YAML/JSON messages (18000 - 18999) #
Expand Down