Skip to content

Commit 437acff

Browse files
committed
add logic to set atp db properties
1 parent 675b47d commit 437acff

File tree

6 files changed

+241
-46
lines changed

6 files changed

+241
-46
lines changed

core/src/main/python/create.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
CommandLineArgUtil.RCU_SCHEMA_PASS_SWITCH,
7070
CommandLineArgUtil.VARIABLE_FILE_SWITCH,
7171
CommandLineArgUtil.USE_ENCRYPTION_SWITCH,
72-
CommandLineArgUtil.PASSPHRASE_SWITCH
72+
CommandLineArgUtil.PASSPHRASE_SWITCH,
73+
CommandLineArgUtil.RCU_PROPERTIES_FILE_SWITCH
7374
]
7475

7576

@@ -81,11 +82,12 @@ def __process_args(args):
8182
"""
8283
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
8384
required_arg_map, optional_arg_map = cla_util.process_args(args, True)
84-
85+
print 'PASSED 1'
8586
__verify_required_args_present(required_arg_map)
8687
__process_java_home_arg(optional_arg_map)
8788
__process_domain_location_args(optional_arg_map)
8889
__process_model_args(optional_arg_map)
90+
print 'PASSED 2'
8991

9092
#
9193
# Verify that the domain type is a known type and load its typedef.
@@ -267,6 +269,8 @@ def __process_rcu_args(optional_arg_map, domain_type, domain_typedef):
267269
ex.setExitCode(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE)
268270
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
269271
raise ex
272+
elif CommandLineArgUtil.RCU_PROPERTIES_FILE_SWITCH in optional_arg_map:
273+
pass
270274
else:
271275
ex = exception_helper.create_cla_exception('WLSDPLY-12408', domain_type, rcu_schema_count,
272276
CommandLineArgUtil.RCU_DB_SWITCH,
@@ -376,6 +380,9 @@ def main(args):
376380
__clean_up_temp_files()
377381
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
378382

383+
384+
385+
379386
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
380387
validate_model(model, model_context, aliases)
381388

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 & 43 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
@@ -57,6 +70,7 @@
5770
from wlsdeploy.tool.util.topology_helper import TopologyHelper
5871
from wlsdeploy.util import dictionary_utils
5972
from wlsdeploy.util import model as model_helper
73+
from oracle.weblogic.deploy.util import VariableException
6074

6175

6276
class DomainCreator(Creator):
@@ -203,6 +217,7 @@ def __run_rcu(self):
203217
rcu_sys_pass = self.model_context.get_rcu_sys_pass()
204218
rcu_schema_pass = self.model_context.get_rcu_schema_pass()
205219

220+
206221
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas)
207222
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
208223

@@ -648,6 +663,20 @@ def __create_other_domain_artifacts(self, location, mbean_type_list):
648663
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
649664
return
650665

666+
def __set_atp_connection_property(self, root_location, propery_name, property_value):
667+
token_name = self.alias_helper.get_name_token(root_location)
668+
if token_name is not None:
669+
root_location.add_name_token(token_name, propery_name)
670+
671+
wlst_name, wlst_value = \
672+
self.alias_helper.get_wlst_attribute_name_and_value(root_location, DRIVER_PARAMS_PROPERTY_VALUE,
673+
property_value )
674+
self.wlst_helper.set_if_needed(wlst_name, wlst_value,
675+
JDBC_DRIVER_PARAMS_PROPERTIES, propery_name)
676+
677+
root_location.remove_name_token(propery_name)
678+
679+
651680
def __configure_fmw_infra_database(self):
652681
"""
653682
Configure the FMW Infrastructure DataSources.
@@ -656,60 +685,167 @@ def __configure_fmw_infra_database(self):
656685
_method_name = '__configure_fmw_infra_database'
657686

658687
self.logger.entering(class_name=self.__class_name, method_name=_method_name)
659-
rcu_database = self.model_context.get_rcu_database()
660-
if rcu_database is None:
661-
return
662688

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

667-
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
668-
self.logger.fine('WLSDPLY-12221', fmw_database, class_name=self.__class_name, method_name=_method_name)
793+
else:
794+
rcu_database = self.model_context.get_rcu_database()
795+
if rcu_database is None:
796+
return
669797

670-
location = LocationContext()
671-
location.append_location(JDBC_SYSTEM_RESOURCE)
672-
token_name = self.alias_helper.get_name_token(location)
673-
svc_table_ds_name = self.wls_helper.get_jrf_service_table_datasource_name()
674-
if token_name is not None:
675-
location.add_name_token(token_name, svc_table_ds_name)
798+
rcu_prefix = self.model_context.get_rcu_prefix()
799+
rcu_schema_pwd = self.model_context.get_rcu_schema_pass()
676800

677-
location.append_location(JDBC_RESOURCE)
678-
location.append_location(JDBC_DRIVER_PARAMS)
679-
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
680-
self.wlst_helper.cd(wlst_path)
681801

682-
svc_table_driver_name = self.wls_helper.get_stb_data_source_jdbc_driver_name()
683-
wlst_name, wlst_value = \
684-
self.alias_helper.get_wlst_attribute_name_and_value(location, DRIVER_NAME, svc_table_driver_name)
685-
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, svc_table_ds_name)
686802

687-
wlst_name, wlst_value = \
688-
self.alias_helper.get_wlst_attribute_name_and_value(location, URL, fmw_database)
689-
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, svc_table_ds_name)
803+
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
804+
self.logger.fine('WLSDPLY-12221', fmw_database, class_name=self.__class_name, method_name=_method_name)
690805

691-
wlst_name, wlst_value = \
692-
self.alias_helper.get_wlst_attribute_name_and_value(location, PASSWORD_ENCRYPTED,
693-
rcu_schema_pwd, masked=True)
694-
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, svc_table_ds_name, masked=True)
806+
location = LocationContext()
807+
location.append_location(JDBC_SYSTEM_RESOURCE)
808+
token_name = self.alias_helper.get_name_token(location)
809+
svc_table_ds_name = self.wls_helper.get_jrf_service_table_datasource_name()
810+
if token_name is not None:
811+
location.add_name_token(token_name, svc_table_ds_name)
695812

696-
location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
697-
token_name = self.alias_helper.get_name_token(location)
698-
if token_name is not None:
699-
location.add_name_token(token_name, DRIVER_PARAMS_USER_PROPERTY)
813+
location.append_location(JDBC_RESOURCE)
814+
location.append_location(JDBC_DRIVER_PARAMS)
815+
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
816+
self.wlst_helper.cd(wlst_path)
700817

701-
stb_user = self.wls_helper.get_stb_user_name(rcu_prefix)
702-
self.logger.fine('WLSDPLY-12222', stb_user, class_name=self.__class_name, method_name=_method_name)
818+
svc_table_driver_name = self.wls_helper.get_stb_data_source_jdbc_driver_name()
819+
wlst_name, wlst_value = \
820+
self.alias_helper.get_wlst_attribute_name_and_value(location, DRIVER_NAME, svc_table_driver_name)
821+
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, svc_table_ds_name)
703822

704-
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
705-
self.wlst_helper.cd(wlst_path)
706-
wlst_name, wlst_value = \
707-
self.alias_helper.get_wlst_attribute_name_and_value(location, DRIVER_PARAMS_PROPERTY_VALUE, stb_user)
708-
self.wlst_helper.set_if_needed(wlst_name, wlst_value,
709-
JDBC_DRIVER_PARAMS_PROPERTIES, DRIVER_PARAMS_USER_PROPERTY)
823+
wlst_name, wlst_value = \
824+
self.alias_helper.get_wlst_attribute_name_and_value(location, URL, fmw_database)
825+
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, svc_table_ds_name)
826+
827+
wlst_name, wlst_value = \
828+
self.alias_helper.get_wlst_attribute_name_and_value(location, PASSWORD_ENCRYPTED,
829+
rcu_schema_pwd, masked=True)
830+
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, svc_table_ds_name, masked=True)
831+
832+
location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
833+
token_name = self.alias_helper.get_name_token(location)
834+
if token_name is not None:
835+
location.add_name_token(token_name, DRIVER_PARAMS_USER_PROPERTY)
836+
837+
stb_user = self.wls_helper.get_stb_user_name(rcu_prefix)
838+
self.logger.fine('WLSDPLY-12222', stb_user, class_name=self.__class_name, method_name=_method_name)
839+
840+
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
841+
self.wlst_helper.cd(wlst_path)
842+
wlst_name, wlst_value = \
843+
self.alias_helper.get_wlst_attribute_name_and_value(location, DRIVER_PARAMS_PROPERTY_VALUE, stb_user)
844+
self.wlst_helper.set_if_needed(wlst_name, wlst_value,
845+
JDBC_DRIVER_PARAMS_PROPERTIES, DRIVER_PARAMS_USER_PROPERTY)
710846

711-
self.logger.info('WLSDPLY-12223', class_name=self.__class_name, method_name=_method_name)
712-
self.wlst_helper.get_database_defaults()
847+
self.logger.info('WLSDPLY-12223', class_name=self.__class_name, method_name=_method_name)
848+
self.wlst_helper.get_database_defaults()
713849

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

0 commit comments

Comments
 (0)