Skip to content

Commit b5d6b8f

Browse files
jshum2479Johnny
authored andcommitted
add logic to set atp db properties
1 parent aeda310 commit b5d6b8f

File tree

4 files changed

+199
-47
lines changed

4 files changed

+199
-47
lines changed

core/src/main/python/create.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
CommandLineArgUtil.RCU_SCHEMA_PASS_SWITCH,
7575
CommandLineArgUtil.VARIABLE_FILE_SWITCH,
7676
CommandLineArgUtil.USE_ENCRYPTION_SWITCH,
77-
CommandLineArgUtil.PASSPHRASE_SWITCH
77+
CommandLineArgUtil.PASSPHRASE_SWITCH,
78+
CommandLineArgUtil.RCU_PROPERTIES_FILE_SWITCH
7879
]
7980

8081

@@ -86,11 +87,12 @@ def __process_args(args):
8687
"""
8788
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
8889
required_arg_map, optional_arg_map = cla_util.process_args(args, True)
89-
90+
print 'PASSED 1'
9091
__verify_required_args_present(required_arg_map)
9192
__process_java_home_arg(optional_arg_map)
9293
__process_domain_location_args(optional_arg_map)
9394
__process_model_args(optional_arg_map)
95+
print 'PASSED 2'
9496

9597
#
9698
# Verify that the domain type is a known type and load its typedef.
@@ -272,6 +274,8 @@ def __process_rcu_args(optional_arg_map, domain_type, domain_typedef):
272274
ex.setExitCode(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE)
273275
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
274276
raise ex
277+
elif CommandLineArgUtil.RCU_PROPERTIES_FILE_SWITCH in optional_arg_map:
278+
pass
275279
else:
276280
ex = exception_helper.create_cla_exception('WLSDPLY-12408', domain_type, rcu_schema_count,
277281
CommandLineArgUtil.RCU_DB_SWITCH,
@@ -381,6 +385,9 @@ def main(args):
381385
__clean_up_temp_files()
382386
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
383387

388+
389+
390+
384391
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
385392
validate_model(model, model_context, aliases)
386393

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,16 @@
274274
DRIVER_NAME = 'DriverName'
275275
DRIVER_PARAMS_PROPERTY_VALUE = 'Value'
276276
DRIVER_PARAMS_USER_PROPERTY = 'user'
277+
DRIVER_PARAMS_TRUSTSTORE_PROPERTY = 'javax.net.ssl.trustStore'
278+
DRIVER_PARAMS_kEYSTORE_PROPERTY = 'javax.net.ssl.keyStore'
279+
DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY = 'javax.net.ssl.trustStoreType'
280+
DRIVER_PARAMS_KEYSTORETYPE_PROPERTY = 'javax.net.ssl.keyStoreType'
281+
DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY = 'javax.net.ssl.trustStorePassword'
282+
DRIVER_PARAMS_KEYSTOREPWD_PROPERTY = 'javax.net.ssl.keyStorePassword'
283+
DRIVER_PARAMS_NET_SERVER_DN_MATCH_PROPERTY = 'oracle.net.ssl_server_dn_match'
284+
DRIVER_PARAMS_NET_SSL_VERSION = 'oracle.net.ssl_version'
285+
DRIVER_PARAMS_NET_TNS_ADMIN = 'oracle.net.tns_admin'
286+
DRIVER_PARAMS_NET_FAN_ENABLED = 'oracle.jdbc.fanEnabled'
277287
ENABLED = 'Enabled'
278288
HARVESTED_ATTRIBUTE = 'HarvestedAttribute'
279289
HARVESTED_INSTANCE = 'HarvestedInstance'

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

Lines changed: 179 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717
from wlsdeploy.aliases.model_constants import DRIVER_NAME
1818
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_PROPERTY_VALUE
1919
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_USER_PROPERTY
20+
21+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_TRUSTSTORE_PROPERTY
22+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_kEYSTORE_PROPERTY
23+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY
24+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_KEYSTORETYPE_PROPERTY
25+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY
26+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_KEYSTOREPWD_PROPERTY
27+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_SERVER_DN_MATCH_PROPERTY
28+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_SSL_VERSION
29+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_TNS_ADMIN
30+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_FAN_ENABLED
31+
2032
from wlsdeploy.aliases.model_constants import JDBC_DRIVER_PARAMS
2133
from wlsdeploy.aliases.model_constants import JDBC_DRIVER_PARAMS_PROPERTIES
2234
from wlsdeploy.aliases.model_constants import JDBC_RESOURCE
@@ -46,6 +58,7 @@
4658
from wlsdeploy.aliases.model_constants import WS_RELIABLE_DELIVERY_POLICY
4759
from wlsdeploy.aliases.model_constants import XML_ENTITY_CACHE
4860
from wlsdeploy.aliases.model_constants import XML_REGISTRY
61+
from wlsdeploy.util import variables
4962
from wlsdeploy.exception import exception_helper
5063
from wlsdeploy.exception.expection_types import ExceptionType
5164
from wlsdeploy.tool.create.creator import Creator
@@ -58,6 +71,7 @@
5871
from wlsdeploy.tool.util.topology_helper import TopologyHelper
5972
from wlsdeploy.util import dictionary_utils
6073
from wlsdeploy.util import model as model_helper
74+
from oracle.weblogic.deploy.util import VariableException
6175

6276

6377
class DomainCreator(Creator):
@@ -195,6 +209,7 @@ def __run_rcu(self):
195209
rcu_sys_pass = self.model_context.get_rcu_sys_pass()
196210
rcu_schema_pass = self.model_context.get_rcu_schema_pass()
197211

212+
198213
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas)
199214
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
200215

@@ -642,6 +657,20 @@ def __create_other_domain_artifacts(self, location, mbean_type_list):
642657
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
643658
return
644659

660+
def __set_atp_connection_property(self, root_location, propery_name, property_value):
661+
token_name = self.alias_helper.get_name_token(root_location)
662+
if token_name is not None:
663+
root_location.add_name_token(token_name, propery_name)
664+
665+
wlst_name, wlst_value = \
666+
self.alias_helper.get_wlst_attribute_name_and_value(root_location, DRIVER_PARAMS_PROPERTY_VALUE,
667+
property_value )
668+
self.wlst_helper.set_if_needed(wlst_name, wlst_value,
669+
JDBC_DRIVER_PARAMS_PROPERTIES, propery_name)
670+
671+
root_location.remove_name_token(propery_name)
672+
673+
645674
def __configure_fmw_infra_database(self):
646675
"""
647676
Configure the FMW Infrastructure DataSources.
@@ -650,61 +679,167 @@ def __configure_fmw_infra_database(self):
650679
_method_name = '__configure_fmw_infra_database'
651680

652681
self.logger.entering(class_name=self.__class_name, method_name=_method_name)
653-
rcu_database = self.model_context.get_rcu_database()
654-
if rcu_database is None:
655-
return
656682

657-
# No need to validate since these were validated at the entry point...
658-
rcu_prefix = self.model_context.get_rcu_prefix()
659-
rcu_schema_pwd = self.model_context.get_rcu_schema_pass()
683+
# For ATP databases : we need to set all the property for each datasource
684+
# load atp connection properties from properties file
685+
#
686+
props_file = self.model_context.get_rcu_properties_file()
687+
if props_file:
688+
try:
689+
rcu_properties_map = variables.load_variables(props_file)
690+
691+
print rcu_properties_map
692+
print '------'
693+
694+
# parse the tnsnames.ora file and retrieve the connection string
695+
tns_admin = rcu_properties_map[DRIVER_PARAMS_NET_TNS_ADMIN]
696+
tns_names = variables.load_variables( tns_admin + os.sep +
697+
'tnsnames.ora')
698+
699+
rcu_database = tns_names[rcu_properties_map['tns.entry']]
700+
701+
rcu_prefix = rcu_properties_map['rcu_prefix']
702+
rcu_schema_pwd = rcu_properties_map['rcu_schema_password']
703+
704+
keystore_pwd = rcu_properties_map[DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
705+
truststore_pwd = rcu_properties_map[DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
706+
707+
# Need to set for the connection proeprty for each datasource
708+
709+
print 'conn ' + str(rcu_database)
710+
print 'prefix ' + str(rcu_prefix)
711+
print 'pawws ' + str(rcu_schema_pwd)
712+
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
713+
714+
location = LocationContext()
715+
location.append_location(JDBC_SYSTEM_RESOURCE)
716+
token_name = self.alias_helper.get_name_token(location)
717+
718+
folder_path = self.alias_helper.get_wlst_list_path(location)
719+
self.wlst_helper.cd(folder_path)
720+
ds_names = self.wlst_helper.lsc()
721+
print ds_names
722+
723+
for ds_name in ds_names:
724+
location = LocationContext()
725+
location.append_location(JDBC_SYSTEM_RESOURCE)
726+
token_name = self.alias_helper.get_name_token(location)
727+
location.add_name_token(token_name, ds_name)
728+
729+
730+
location.append_location(JDBC_RESOURCE)
731+
location.append_location(JDBC_DRIVER_PARAMS)
732+
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
733+
self.wlst_helper.cd(wlst_path)
734+
735+
wlst_name, wlst_value = \
736+
self.alias_helper.get_wlst_attribute_name_and_value(location, URL, fmw_database)
737+
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, ds_name)
738+
739+
wlst_name, wlst_value = \
740+
self.alias_helper.get_wlst_attribute_name_and_value(location, PASSWORD_ENCRYPTED,
741+
rcu_schema_pwd, masked=True)
742+
743+
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, ds_name, masked=True)
744+
745+
746+
location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
747+
token_name = self.alias_helper.get_name_token(location)
748+
if token_name is not None:
749+
location.add_name_token(token_name, DRIVER_PARAMS_USER_PROPERTY)
750+
751+
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
752+
self.wlst_helper.cd(wlst_path)
753+
orig_user = self.wlst_helper.get('Value')
754+
stb_user = orig_user.replace('DEV', rcu_prefix)
755+
wlst_name, wlst_value = \
756+
self.alias_helper.get_wlst_attribute_name_and_value(location, DRIVER_PARAMS_PROPERTY_VALUE, stb_user)
757+
self.wlst_helper.set_if_needed(wlst_name, wlst_value,
758+
JDBC_DRIVER_PARAMS_PROPERTIES, DRIVER_PARAMS_USER_PROPERTY)
759+
760+
# need to set other properties
761+
762+
location.remove_name_token(DRIVER_PARAMS_USER_PROPERTY)
763+
764+
self.__set_atp_connection_property(location, DRIVER_PARAMS_kEYSTORE_PROPERTY, tns_admin + os.sep
765+
+ 'keystore.jks')
766+
self.__set_atp_connection_property(location, DRIVER_PARAMS_KEYSTORETYPE_PROPERTY,
767+
'JKS')
768+
self.__set_atp_connection_property(location, DRIVER_PARAMS_KEYSTOREPWD_PROPERTY, keystore_pwd)
769+
self.__set_atp_connection_property(location, DRIVER_PARAMS_TRUSTSTORE_PROPERTY, tns_admin + os.sep
770+
+ 'truststore.jks')
771+
self.__set_atp_connection_property(location, DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY,
772+
'JKS')
773+
self.__set_atp_connection_property(location, DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY, truststore_pwd)
774+
775+
self.__set_atp_connection_property(location, DRIVER_PARAMS_NET_SSL_VERSION, '1.2')
776+
self.__set_atp_connection_property(location, DRIVER_PARAMS_NET_SERVER_DN_MATCH_PROPERTY, 'true')
777+
self.__set_atp_connection_property(location, DRIVER_PARAMS_NET_TNS_ADMIN, tns_admin)
778+
self.__set_atp_connection_property(location, DRIVER_PARAMS_NET_FAN_ENABLED, 'false')
779+
print 'UPDATED ALL PROPERTIES '
780+
781+
except VariableException, ex:
782+
self.logger.severe('WLSDPLY-20004', _program_name, ex.getLocalizedMessage(), error=ex,
783+
class_name=_class_name, method_name=_method_name)
784+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
785+
raise ex
660786

661-
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
662-
self.logger.fine('WLSDPLY-12221', fmw_database, class_name=self.__class_name, method_name=_method_name)
787+
else:
788+
rcu_database = self.model_context.get_rcu_database()
789+
if rcu_database is None:
790+
return
663791

664-
location = LocationContext()
665-
location.append_location(JDBC_SYSTEM_RESOURCE)
666-
token_name = self.alias_helper.get_name_token(location)
667-
svc_table_ds_name = self.wls_helper.get_jrf_service_table_datasource_name()
668-
if token_name is not None:
669-
location.add_name_token(token_name, svc_table_ds_name)
792+
rcu_prefix = self.model_context.get_rcu_prefix()
793+
rcu_schema_pwd = self.model_context.get_rcu_schema_pass()
670794

671-
location.append_location(JDBC_RESOURCE)
672-
location.append_location(JDBC_DRIVER_PARAMS)
673-
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
674-
self.wlst_helper.cd(wlst_path)
795+
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
796+
self.logger.fine('WLSDPLY-12221', fmw_database, class_name=self.__class_name, method_name=_method_name)
675797

676-
svc_table_driver_name = self.wls_helper.get_stb_data_source_jdbc_driver_name()
677-
wlst_name, wlst_value = \
678-
self.alias_helper.get_wlst_attribute_name_and_value(location, DRIVER_NAME, svc_table_driver_name)
679-
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, svc_table_ds_name)
798+
location = LocationContext()
799+
location.append_location(JDBC_SYSTEM_RESOURCE)
800+
token_name = self.alias_helper.get_name_token(location)
801+
svc_table_ds_name = self.wls_helper.get_jrf_service_table_datasource_name()
802+
if token_name is not None:
803+
location.add_name_token(token_name, svc_table_ds_name)
680804

681-
wlst_name, wlst_value = \
682-
self.alias_helper.get_wlst_attribute_name_and_value(location, URL, fmw_database)
683-
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, svc_table_ds_name)
805+
location.append_location(JDBC_RESOURCE)
806+
location.append_location(JDBC_DRIVER_PARAMS)
807+
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
808+
self.wlst_helper.cd(wlst_path)
684809

685-
wlst_name, wlst_value = \
686-
self.alias_helper.get_wlst_attribute_name_and_value(location, PASSWORD_ENCRYPTED,
687-
rcu_schema_pwd, masked=True)
688-
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, svc_table_ds_name, masked=True)
810+
svc_table_driver_name = self.wls_helper.get_stb_data_source_jdbc_driver_name()
811+
wlst_name, wlst_value = \
812+
self.alias_helper.get_wlst_attribute_name_and_value(location, DRIVER_NAME, svc_table_driver_name)
813+
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, svc_table_ds_name)
689814

690-
location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
691-
token_name = self.alias_helper.get_name_token(location)
815+
wlst_name, wlst_value = \
816+
self.alias_helper.get_wlst_attribute_name_and_value(location, URL, fmw_database)
817+
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, svc_table_ds_name)
692818

693-
if token_name is not None:
694-
location.add_name_token(token_name, DRIVER_PARAMS_USER_PROPERTY)
819+
wlst_name, wlst_value = \
820+
self.alias_helper.get_wlst_attribute_name_and_value(location, PASSWORD_ENCRYPTED,
821+
rcu_schema_pwd, masked=True)
822+
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, svc_table_ds_name, masked=True)
695823

696-
stb_user = self.wls_helper.get_stb_user_name(rcu_prefix)
697-
self.logger.fine('WLSDPLY-12222', stb_user, class_name=self.__class_name, method_name=_method_name)
698-
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
699-
self.wlst_helper.cd(wlst_path)
700-
wlst_name, wlst_value = \
701-
self.alias_helper.get_wlst_attribute_name_and_value(location, DRIVER_PARAMS_PROPERTY_VALUE, stb_user)
702-
self.wlst_helper.set_if_needed(wlst_name, wlst_value,
703-
JDBC_DRIVER_PARAMS_PROPERTIES, DRIVER_PARAMS_USER_PROPERTY)
824+
location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
825+
token_name = self.alias_helper.get_name_token(location)
826+
827+
if token_name is not None:
828+
location.add_name_token(token_name, DRIVER_PARAMS_USER_PROPERTY)
829+
830+
stb_user = self.wls_helper.get_stb_user_name(rcu_prefix)
831+
self.logger.fine('WLSDPLY-12222', stb_user, class_name=self.__class_name, method_name=_method_name)
832+
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
833+
self.wlst_helper.cd(wlst_path)
834+
wlst_name, wlst_value = \
835+
self.alias_helper.get_wlst_attribute_name_and_value(location, DRIVER_PARAMS_PROPERTY_VALUE, stb_user)
836+
self.wlst_helper.set_if_needed(wlst_name, wlst_value,
837+
JDBC_DRIVER_PARAMS_PROPERTIES, DRIVER_PARAMS_USER_PROPERTY)
838+
839+
self.logger.info('WLSDPLY-12223', class_name=self.__class_name, method_name=_method_name)
840+
if self.wls_helper.is_database_defaults_supported():
841+
self.wlst_helper.get_database_defaults()
704842

705-
self.logger.info('WLSDPLY-12223', class_name=self.__class_name, method_name=_method_name)
706-
if self.wls_helper.is_database_defaults_supported():
707-
self.wlst_helper.get_database_defaults()
708843

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

installer/src/main/bin/createDomain.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ echo "WLST_PROPERTIES = ${WLST_PROPERTIES}"
316316
PY_SCRIPTS_PATH=${WLSDEPLOY_HOME}/lib/python
317317
echo "${WLST} ${PY_SCRIPTS_PATH}/create.py ${SCRIPT_ARGS}"
318318

319-
"${WLST}" "${PY_SCRIPTS_PATH}/create.py" ${SCRIPT_ARGS}
319+
eval "${WLST}" "${PY_SCRIPTS_PATH}/create.py" ${SCRIPT_ARGS}
320320

321321
RETURN_CODE=$?
322322
if [ ${RETURN_CODE} -eq 100 ]; then

0 commit comments

Comments
 (0)