Skip to content

Commit 3767e46

Browse files
jshum2479Johnny
authored andcommitted
change to put the atp properties inside the model domainInfo
1 parent 9cca685 commit 3767e46

File tree

5 files changed

+142
-116
lines changed

5 files changed

+142
-116
lines changed

core/src/main/python/create.py

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
"""
77
import javaos as os
88
import sys
9+
910
from xml.dom.minidom import parse
1011

1112
from java.io import IOException
1213
from java.lang import IllegalArgumentException
1314
from java.lang import IllegalStateException
1415
from java.lang import String
16+
from java.io import File
17+
from java.io import FileInputStream
18+
from java.io import FileOutputStream
19+
from java.util.zip import ZipInputStream
20+
import jarray
21+
22+
1523

1624
from oracle.weblogic.deploy.create import CreateException
1725
from oracle.weblogic.deploy.deploy import DeployException
@@ -29,6 +37,7 @@
2937
# imports from local packages start here
3038

3139
from wlsdeploy.aliases.aliases import Aliases
40+
from wlsdeploy.aliases import model_constants
3241
from wlsdeploy.aliases.wlst_modes import WlstModes
3342
from wlsdeploy.exception import exception_helper
3443
from wlsdeploy.logging.platform_logger import PlatformLogger
@@ -88,6 +97,7 @@ def __process_args(args):
8897
"""
8998
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
9099
required_arg_map, optional_arg_map = cla_util.process_args(args, True)
100+
91101
__verify_required_args_present(required_arg_map)
92102
__process_java_home_arg(optional_arg_map)
93103
__process_domain_location_args(optional_arg_map)
@@ -382,6 +392,33 @@ def set_property(DOMTree, prop, name, value):
382392
prop.appendChild(newline)
383393

384394

395+
def unzip_atp_wallet(wallet_file, location):
396+
397+
if not os.path.exists(location):
398+
os.mkdir(location)
399+
400+
buffer = jarray.zeros(1024, "b")
401+
fis = FileInputStream(wallet_file)
402+
zis = ZipInputStream(fis)
403+
ze = zis.getNextEntry()
404+
while ze:
405+
fileName = ze.getName()
406+
newFile = File(location + File.separator + fileName)
407+
File(newFile.getParent()).mkdirs()
408+
fos = FileOutputStream(newFile)
409+
len = zis.read(buffer)
410+
while len > 0:
411+
fos.write(buffer, 0, len)
412+
len = zis.read(buffer)
413+
414+
fos.close()
415+
zis.closeEntry()
416+
ze = zis.getNextEntry()
417+
zis.closeEntry()
418+
zis.close()
419+
fis.close()
420+
421+
385422
def main(args):
386423
"""
387424
The entry point for the create domain tool.
@@ -399,9 +436,6 @@ def main(args):
399436

400437
try:
401438
model_context = __process_args(args)
402-
if model_context.get_atp_properties_file():
403-
current_wlst_properties = os.environ.get('WLST_PROPERTIES')
404-
os.environ['oracle.net.fanEnabled'] = 'false'
405439
except CLAException, ex:
406440
exit_code = ex.getExitCode()
407441
if exit_code != CommandLineArgUtil.HELP_EXIT_CODE:
@@ -413,6 +447,10 @@ def main(args):
413447
model_file = model_context.get_model_file()
414448
try:
415449
model = FileToPython(model_file, True).parse()
450+
if model_context.get_atp_properties_file():
451+
os.environ['oracle.net.fanEnabled'] = 'false'
452+
unzip_atp_wallet(model_context.get_atp_properties_file(), model[model_constants.DOMAIN_INFO][
453+
model_constants.ATP_DB_INFO][model_constants.DRIVER_PARAMS_NET_TNS_ADMIN])
416454
except TranslateException, te:
417455
__logger.severe('WLSDPLY-20009', _program_name, model_file, te.getLocalizedMessage(), error=te,
418456
class_name=_class_name, method_name=_method_name)
@@ -430,9 +468,6 @@ def main(args):
430468
__clean_up_temp_files()
431469
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
432470

433-
434-
435-
436471
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
437472
validate_model(model, model_context, aliases)
438473

@@ -443,17 +478,21 @@ def main(args):
443478
try:
444479
creator = DomainCreator(model, model_context, aliases)
445480
creator.create()
446-
atp_props_path = model_context.get_atp_properties_file()
447481

448-
if atp_props_path:
449-
rcu_properties_map = variables.load_variables(atp_props_path)
450-
atp_creds_path = rcu_properties_map['oracle.net.tns_admin']
482+
if model_context.get_atp_properties_file():
483+
#print model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO]
484+
tns_admin = model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO][
485+
model_constants.DRIVER_PARAMS_NET_TNS_ADMIN]
486+
keystore_password = model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO][
487+
model_constants.DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
488+
489+
truststore_password = model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO][
490+
model_constants.DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
491+
451492
jsp_config = model_context.get_domain_home() + '/config/fmwconfig/jps-config.xml'
452493
jsp_config_jse = model_context.get_domain_home() + '/config/fmwconfig/jps-config-jse.xml'
453-
set_ssl_properties(jsp_config, atp_creds_path, rcu_properties_map['javax.net.ssl.keyStorePassword'],
454-
rcu_properties_map['javax.net.ssl.trustStorePassword'])
455-
set_ssl_properties(jsp_config_jse, atp_creds_path, rcu_properties_map['javax.net.ssl.keyStorePassword'],
456-
rcu_properties_map['javax.net.ssl.trustStorePassword'])
494+
set_ssl_properties(jsp_config, tns_admin, keystore_password, truststore_password)
495+
set_ssl_properties(jsp_config_jse, tns_admin, keystore_password, truststore_password)
457496

458497
except (IOException | CreateException), ex:
459498
__logger.severe('WLSDPLY-12409', _program_name, ex.getLocalizedMessage(), error=ex,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ class AliasEntries(object):
178178
# be targeted. The ServerGroup must appear in the domain typedef definition. If
179179
# the ServerGroup is not listed in this map, it will be targeted to all managed
180180
# servers in the domain.
181-
'ServerGroupTargetingLimits': 'dict'
181+
'ServerGroupTargetingLimits': 'dict',
182+
'ATPDbInfo' : 'dict'
182183
}
183184

184185
__domain_name_token = 'DOMAIN'

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
APP_DEPLOYMENTS = 'appDeployments'
1818
APP_DIR = 'AppDir'
1919
APPLICATION = 'Application'
20+
ATP_DB_INFO = 'ATPDbInfo'
21+
ATP_RCU_PREFIX='rcu_prefix'
22+
ATP_RCU_SCHEMA_PASSWORD='rcu_schema_password'
23+
ATP_ADMIN_PASSWORD='rcu_admin_password'
24+
ATP_TNS_ENTRY='tns.entry'
25+
2026
AUDITOR = 'Auditor'
2127
AUTHENTICATION_PROVIDER = 'AuthenticationProvider'
2228
AUTHORIZER = 'Authorizer'
@@ -284,10 +290,6 @@
284290
DRIVER_PARAMS_NET_SSL_VERSION = 'oracle.net.ssl_version'
285291
DRIVER_PARAMS_NET_TNS_ADMIN = 'oracle.net.tns_admin'
286292
DRIVER_PARAMS_NET_FAN_ENABLED = 'oracle.jdbc.fanEnabled'
287-
ATP_RCU_PREFIX='rcu_prefix'
288-
ATP_RCU_SCHEMA_PASSWORD='rcu_schema_password'
289-
ATP_ADMIN_PASSWORD='rcu_admin_password'
290-
ATP_TNS_ENTRY='tns.entry'
291293

292294
ENABLED = 'Enabled'
293295
HARVESTED_ATTRIBUTE = 'HarvestedAttribute'

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

Lines changed: 79 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from wlsdeploy.aliases.model_constants import ATP_ADMIN_PASSWORD
3535

3636
from wlsdeploy.aliases.model_constants import ATP_TNS_ENTRY
37+
from wlsdeploy.aliases.model_constants import ATP_DB_INFO
3738

3839
from wlsdeploy.aliases.model_constants import JDBC_DRIVER_PARAMS
3940
from wlsdeploy.aliases.model_constants import JDBC_DRIVER_PARAMS_PROPERTIES
@@ -211,23 +212,14 @@ def __run_rcu(self):
211212
oracle_home = self.model_context.get_oracle_home()
212213
java_home = self.model_context.get_java_home()
213214

214-
props_file = self.model_context.get_atp_properties_file()
215+
if self.model_context.get_atp_properties_file():
216+
rcu_properties_map = self.model.get_model_domain_info()[ATP_DB_INFO]
215217

216-
if props_file:
217-
try:
218-
rcu_properties_map = variables.load_variables(props_file)
219-
220-
rcu_schema_pass = rcu_properties_map[ATP_RCU_SCHEMA_PASSWORD]
221-
rcu_sys_pass = rcu_properties_map[ATP_ADMIN_PASSWORD]
222-
223-
runner = RCURunner(domain_type, oracle_home, java_home, rcu_schemas, rcu_properties_map)
224-
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
225-
except VariableException, ex:
226-
self.logger.severe('WLSDPLY-20004', __program_name, ex.getLocalizedMessage(), error=ex,
227-
class_name=__class_name, method_name=_method_name)
228-
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
229-
raise ex
218+
rcu_schema_pass = rcu_properties_map[ATP_RCU_SCHEMA_PASSWORD]
219+
rcu_sys_pass = rcu_properties_map[ATP_ADMIN_PASSWORD]
230220

221+
runner = RCURunner(domain_type, oracle_home, java_home, rcu_schemas, rcu_properties_map)
222+
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
231223
else:
232224
rcu_db = self.model_context.get_rcu_database()
233225
rcu_prefix = self.model_context.get_rcu_prefix()
@@ -774,97 +766,88 @@ def __configure_fmw_infra_database(self):
774766
# For ATP databases : we need to set all the property for each datasource
775767
# load atp connection properties from properties file
776768
#
777-
props_file = self.model_context.get_atp_properties_file()
778-
if props_file:
779-
try:
780-
rcu_properties_map = variables.load_variables(props_file)
769+
if self.model_context.get_atp_properties_file():
770+
rcu_properties_map = self.model.get_model_domain_info()[ATP_DB_INFO]
771+
772+
# parse the tnsnames.ora file and retrieve the connection string
773+
tns_admin = rcu_properties_map[DRIVER_PARAMS_NET_TNS_ADMIN]
781774

782-
# parse the tnsnames.ora file and retrieve the connection string
783-
tns_admin = rcu_properties_map[DRIVER_PARAMS_NET_TNS_ADMIN]
775+
rcu_database = self._get_atp_connect_string(tns_admin + os.sep + 'tnsnames.ora', rcu_properties_map[
776+
ATP_TNS_ENTRY])
784777

785-
rcu_database = self._get_atp_connect_string(tns_admin + os.sep + 'tnsnames.ora', rcu_properties_map[
786-
ATP_TNS_ENTRY])
778+
rcu_prefix = rcu_properties_map[ATP_RCU_PREFIX]
779+
rcu_schema_pwd = rcu_properties_map[ATP_RCU_SCHEMA_PASSWORD]
787780

788-
rcu_prefix = rcu_properties_map[ATP_RCU_PREFIX]
789-
rcu_schema_pwd = rcu_properties_map[ATP_RCU_SCHEMA_PASSWORD]
781+
keystore_pwd = rcu_properties_map[DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
782+
truststore_pwd = rcu_properties_map[DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
790783

791-
keystore_pwd = rcu_properties_map[DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
792-
truststore_pwd = rcu_properties_map[DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
784+
# Need to set for the connection proeprty for each datasource
785+
786+
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
793787

794-
# Need to set for the connection proeprty for each datasource
795788

796-
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
789+
location = LocationContext()
790+
location.append_location(JDBC_SYSTEM_RESOURCE)
797791

792+
folder_path = self.alias_helper.get_wlst_list_path(location)
793+
self.wlst_helper.cd(folder_path)
794+
ds_names = self.wlst_helper.lsc()
798795

796+
for ds_name in ds_names:
799797
location = LocationContext()
800798
location.append_location(JDBC_SYSTEM_RESOURCE)
801-
802-
folder_path = self.alias_helper.get_wlst_list_path(location)
803-
self.wlst_helper.cd(folder_path)
804-
ds_names = self.wlst_helper.lsc()
805-
806-
for ds_name in ds_names:
807-
location = LocationContext()
808-
location.append_location(JDBC_SYSTEM_RESOURCE)
809-
token_name = self.alias_helper.get_name_token(location)
810-
location.add_name_token(token_name, ds_name)
811-
812-
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)
817-
818-
wlst_name, wlst_value = \
819-
self.alias_helper.get_wlst_attribute_name_and_value(location, URL, fmw_database)
820-
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, ds_name)
821-
822-
wlst_name, wlst_value = \
823-
self.alias_helper.get_wlst_attribute_name_and_value(location, PASSWORD_ENCRYPTED,
824-
rcu_schema_pwd, masked=True)
825-
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, ds_name, masked=True)
826-
827-
location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
828-
token_name = self.alias_helper.get_name_token(location)
829-
if token_name is not None:
830-
location.add_name_token(token_name, DRIVER_PARAMS_USER_PROPERTY)
831-
832-
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
833-
self.wlst_helper.cd(wlst_path)
834-
orig_user = self.wlst_helper.get('Value')
835-
stb_user = orig_user.replace('DEV', rcu_prefix)
836-
wlst_name, wlst_value = \
837-
self.alias_helper.get_wlst_attribute_name_and_value(location, DRIVER_PARAMS_PROPERTY_VALUE,
838-
stb_user)
839-
self.wlst_helper.set_if_needed(wlst_name, wlst_value,
840-
JDBC_DRIVER_PARAMS_PROPERTIES, DRIVER_PARAMS_USER_PROPERTY)
841-
842-
# need to set other properties
843-
844-
location.remove_name_token(DRIVER_PARAMS_USER_PROPERTY)
845-
846-
self.__set_atp_connection_property(location, DRIVER_PARAMS_kEYSTORE_PROPERTY, tns_admin + os.sep
847-
+ 'keystore.jks')
848-
self.__set_atp_connection_property(location, DRIVER_PARAMS_KEYSTORETYPE_PROPERTY,
849-
'JKS')
850-
self.__set_atp_connection_property(location, DRIVER_PARAMS_KEYSTOREPWD_PROPERTY, keystore_pwd)
851-
self.__set_atp_connection_property(location, DRIVER_PARAMS_TRUSTSTORE_PROPERTY, tns_admin + os.sep
852-
+ 'truststore.jks')
853-
self.__set_atp_connection_property(location, DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY,
854-
'JKS')
855-
self.__set_atp_connection_property(location, DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY, truststore_pwd)
856-
857-
self.__set_atp_connection_property(location, DRIVER_PARAMS_NET_SSL_VERSION, '1.2')
858-
self.__set_atp_connection_property(location, DRIVER_PARAMS_NET_SERVER_DN_MATCH_PROPERTY, 'true')
859-
self.__set_atp_connection_property(location, DRIVER_PARAMS_NET_TNS_ADMIN, tns_admin)
860-
self.__set_atp_connection_property(location, DRIVER_PARAMS_NET_FAN_ENABLED, 'false')
861-
862-
except VariableException, ex:
863-
self.logger.severe('WLSDPLY-20004', _program_name, ex.getLocalizedMessage(), error=ex,
864-
class_name=_class_name, method_name=_method_name)
865-
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
866-
raise ex
867-
799+
token_name = self.alias_helper.get_name_token(location)
800+
location.add_name_token(token_name, ds_name)
801+
802+
803+
location.append_location(JDBC_RESOURCE)
804+
location.append_location(JDBC_DRIVER_PARAMS)
805+
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
806+
self.wlst_helper.cd(wlst_path)
807+
808+
wlst_name, wlst_value = \
809+
self.alias_helper.get_wlst_attribute_name_and_value(location, URL, fmw_database)
810+
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, ds_name)
811+
812+
wlst_name, wlst_value = \
813+
self.alias_helper.get_wlst_attribute_name_and_value(location, PASSWORD_ENCRYPTED,
814+
rcu_schema_pwd, masked=True)
815+
self.wlst_helper.set_if_needed(wlst_name, wlst_value, JDBC_DRIVER_PARAMS, ds_name, masked=True)
816+
817+
location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
818+
token_name = self.alias_helper.get_name_token(location)
819+
if token_name is not None:
820+
location.add_name_token(token_name, DRIVER_PARAMS_USER_PROPERTY)
821+
822+
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
823+
self.wlst_helper.cd(wlst_path)
824+
orig_user = self.wlst_helper.get('Value')
825+
stb_user = orig_user.replace('DEV', rcu_prefix)
826+
wlst_name, wlst_value = \
827+
self.alias_helper.get_wlst_attribute_name_and_value(location, DRIVER_PARAMS_PROPERTY_VALUE,
828+
stb_user)
829+
self.wlst_helper.set_if_needed(wlst_name, wlst_value,
830+
JDBC_DRIVER_PARAMS_PROPERTIES, DRIVER_PARAMS_USER_PROPERTY)
831+
832+
# need to set other properties
833+
834+
location.remove_name_token(DRIVER_PARAMS_USER_PROPERTY)
835+
836+
self.__set_atp_connection_property(location, DRIVER_PARAMS_kEYSTORE_PROPERTY, tns_admin + os.sep
837+
+ 'keystore.jks')
838+
self.__set_atp_connection_property(location, DRIVER_PARAMS_KEYSTORETYPE_PROPERTY,
839+
'JKS')
840+
self.__set_atp_connection_property(location, DRIVER_PARAMS_KEYSTOREPWD_PROPERTY, keystore_pwd)
841+
self.__set_atp_connection_property(location, DRIVER_PARAMS_TRUSTSTORE_PROPERTY, tns_admin + os.sep
842+
+ 'truststore.jks')
843+
self.__set_atp_connection_property(location, DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY,
844+
'JKS')
845+
self.__set_atp_connection_property(location, DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY, truststore_pwd)
846+
847+
self.__set_atp_connection_property(location, DRIVER_PARAMS_NET_SSL_VERSION, '1.2')
848+
self.__set_atp_connection_property(location, DRIVER_PARAMS_NET_SERVER_DN_MATCH_PROPERTY, 'true')
849+
self.__set_atp_connection_property(location, DRIVER_PARAMS_NET_TNS_ADMIN, tns_admin)
850+
self.__set_atp_connection_property(location, DRIVER_PARAMS_NET_FAN_ENABLED, 'false')
868851
else:
869852
rcu_database = self.model_context.get_rcu_database()
870853
if rcu_database is None:

core/src/main/python/wlsdeploy/tool/util/library_helper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import wlsdeploy.util.dictionary_utils as dictionary_utils
77

88
from wlsdeploy.aliases.model_constants import DOMAIN_LIBRARIES
9+
from wlsdeploy.aliases.model_constants import ATP_DB_INFO
910
from wlsdeploy.exception import exception_helper
1011
from wlsdeploy.tool.util.alias_helper import AliasHelper
1112
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
@@ -42,7 +43,7 @@ def install_domain_libraries(self):
4243
domain_info_dict = self.model.get_model_domain_info()
4344
if DOMAIN_LIBRARIES not in domain_info_dict or len(domain_info_dict[DOMAIN_LIBRARIES]) == 0:
4445
self.logger.info('WLSDPLY-12213', class_name=self.__class_name, method_name=_method_name)
45-
else:
46+
elif DOMAIN_LIBRARIES in domain_info_dict:
4647
domain_libs = dictionary_utils.get_dictionary_element(domain_info_dict, DOMAIN_LIBRARIES)
4748
if self.archive_helper is None:
4849
ex = exception_helper.create_create_exception('WLSDPLY-12214', domain_libs)

0 commit comments

Comments
 (0)