Skip to content

Commit d3dbf8b

Browse files
committed
change to put the atp properties inside the model domainInfo
1 parent 186ab59 commit d3dbf8b

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
@@ -45,6 +54,7 @@
4554
from wlsdeploy.util.model_translator import FileToPython
4655
from wlsdeploy.util.weblogic_helper import WebLogicHelper
4756

57+
4858
_program_name = 'createDomain'
4959
_class_name = 'create'
5060
__logger = PlatformLogger('wlsdeploy.create')
@@ -377,6 +387,33 @@ def set_property(DOMTree, prop, name, value):
377387
prop.appendChild(newline)
378388

379389

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

395432
try:
396433
model_context = __process_args(args)
397-
if model_context.get_atp_properties_file():
398-
current_wlst_properties = os.environ.get('WLST_PROPERTIES')
399-
os.environ['oracle.net.fanEnabled'] = 'false'
400434
except CLAException, ex:
401435
exit_code = ex.getExitCode()
402436
if exit_code != CommandLineArgUtil.HELP_EXIT_CODE:
@@ -408,6 +442,10 @@ def main(args):
408442
model_file = model_context.get_model_file()
409443
try:
410444
model = FileToPython(model_file, True).parse()
445+
if model_context.get_atp_properties_file():
446+
os.environ['oracle.net.fanEnabled'] = 'false'
447+
unzip_atp_wallet(model_context.get_atp_properties_file(), model[model_constants.DOMAIN_INFO][
448+
model_constants.ATP_DB_INFO][model_constants.DRIVER_PARAMS_NET_TNS_ADMIN])
411449
except TranslateException, te:
412450
__logger.severe('WLSDPLY-20009', _program_name, model_file, te.getLocalizedMessage(), error=te,
413451
class_name=_class_name, method_name=_method_name)
@@ -425,9 +463,6 @@ def main(args):
425463
__clean_up_temp_files()
426464
tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
427465

428-
429-
430-
431466
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
432467
validate_model(model, model_context, aliases)
433468

@@ -438,17 +473,21 @@ def main(args):
438473
try:
439474
creator = DomainCreator(model, model_context, aliases)
440475
creator.create()
441-
atp_props_path = model_context.get_atp_properties_file()
442476

443-
if atp_props_path:
444-
rcu_properties_map = variables.load_variables(atp_props_path)
445-
atp_creds_path = rcu_properties_map['oracle.net.tns_admin']
477+
if model_context.get_atp_properties_file():
478+
#print model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO]
479+
tns_admin = model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO][
480+
model_constants.DRIVER_PARAMS_NET_TNS_ADMIN]
481+
keystore_password = model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO][
482+
model_constants.DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
483+
484+
truststore_password = model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO][
485+
model_constants.DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
486+
446487
jsp_config = model_context.get_domain_home() + '/config/fmwconfig/jps-config.xml'
447488
jsp_config_jse = model_context.get_domain_home() + '/config/fmwconfig/jps-config-jse.xml'
448-
set_ssl_properties(jsp_config, atp_creds_path, rcu_properties_map['javax.net.ssl.keyStorePassword'],
449-
rcu_properties_map['javax.net.ssl.trustStorePassword'])
450-
set_ssl_properties(jsp_config_jse, atp_creds_path, rcu_properties_map['javax.net.ssl.keyStorePassword'],
451-
rcu_properties_map['javax.net.ssl.trustStorePassword'])
489+
set_ssl_properties(jsp_config, tns_admin, keystore_password, truststore_password)
490+
set_ssl_properties(jsp_config_jse, tns_admin, keystore_password, truststore_password)
452491

453492
except (IOException | CreateException), ex:
454493
__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
@@ -219,23 +220,14 @@ def __run_rcu(self):
219220
oracle_home = self.model_context.get_oracle_home()
220221
java_home = self.model_context.get_java_home()
221222

222-
props_file = self.model_context.get_atp_properties_file()
223+
if self.model_context.get_atp_properties_file():
224+
rcu_properties_map = self.model.get_model_domain_info()[ATP_DB_INFO]
223225

224-
if props_file:
225-
try:
226-
rcu_properties_map = variables.load_variables(props_file)
227-
228-
rcu_schema_pass = rcu_properties_map[ATP_RCU_SCHEMA_PASSWORD]
229-
rcu_sys_pass = rcu_properties_map[ATP_ADMIN_PASSWORD]
230-
231-
runner = RCURunner(domain_type, oracle_home, java_home, rcu_schemas, rcu_properties_map)
232-
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
233-
except VariableException, ex:
234-
self.logger.severe('WLSDPLY-20004', __program_name, ex.getLocalizedMessage(), error=ex,
235-
class_name=__class_name, method_name=_method_name)
236-
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
237-
raise ex
226+
rcu_schema_pass = rcu_properties_map[ATP_RCU_SCHEMA_PASSWORD]
227+
rcu_sys_pass = rcu_properties_map[ATP_ADMIN_PASSWORD]
238228

229+
runner = RCURunner(domain_type, oracle_home, java_home, rcu_schemas, rcu_properties_map)
230+
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
239231
else:
240232
rcu_db = self.model_context.get_rcu_database()
241233
rcu_prefix = self.model_context.get_rcu_prefix()
@@ -780,97 +772,88 @@ def __configure_fmw_infra_database(self):
780772
# For ATP databases : we need to set all the property for each datasource
781773
# load atp connection properties from properties file
782774
#
783-
props_file = self.model_context.get_atp_properties_file()
784-
if props_file:
785-
try:
786-
rcu_properties_map = variables.load_variables(props_file)
775+
if self.model_context.get_atp_properties_file():
776+
rcu_properties_map = self.model.get_model_domain_info()[ATP_DB_INFO]
777+
778+
# parse the tnsnames.ora file and retrieve the connection string
779+
tns_admin = rcu_properties_map[DRIVER_PARAMS_NET_TNS_ADMIN]
787780

788-
# parse the tnsnames.ora file and retrieve the connection string
789-
tns_admin = rcu_properties_map[DRIVER_PARAMS_NET_TNS_ADMIN]
781+
rcu_database = self._get_atp_connect_string(tns_admin + os.sep + 'tnsnames.ora', rcu_properties_map[
782+
ATP_TNS_ENTRY])
790783

791-
rcu_database = self._get_atp_connect_string(tns_admin + os.sep + 'tnsnames.ora', rcu_properties_map[
792-
ATP_TNS_ENTRY])
784+
rcu_prefix = rcu_properties_map[ATP_RCU_PREFIX]
785+
rcu_schema_pwd = rcu_properties_map[ATP_RCU_SCHEMA_PASSWORD]
793786

794-
rcu_prefix = rcu_properties_map[ATP_RCU_PREFIX]
795-
rcu_schema_pwd = rcu_properties_map[ATP_RCU_SCHEMA_PASSWORD]
787+
keystore_pwd = rcu_properties_map[DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
788+
truststore_pwd = rcu_properties_map[DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
796789

797-
keystore_pwd = rcu_properties_map[DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
798-
truststore_pwd = rcu_properties_map[DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
790+
# Need to set for the connection proeprty for each datasource
791+
792+
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
799793

800-
# Need to set for the connection proeprty for each datasource
801794

802-
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
795+
location = LocationContext()
796+
location.append_location(JDBC_SYSTEM_RESOURCE)
803797

798+
folder_path = self.alias_helper.get_wlst_list_path(location)
799+
self.wlst_helper.cd(folder_path)
800+
ds_names = self.wlst_helper.lsc()
804801

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