Skip to content

Commit 6488e3a

Browse files
jshum2479Johnny
authored andcommitted
refactoring
1 parent ed56400 commit 6488e3a

File tree

2 files changed

+64
-79
lines changed

2 files changed

+64
-79
lines changed

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

Lines changed: 26 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,24 @@
1010
from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME
1111
from wlsdeploy.aliases.model_constants import ADMIN_USERNAME
1212
from wlsdeploy.aliases.model_constants import APP_DIR
13+
from wlsdeploy.aliases.model_constants import ATP_TNS_ENTRY
1314
from wlsdeploy.aliases.model_constants import CLUSTER
1415
from wlsdeploy.aliases.model_constants import DEFAULT_ADMIN_SERVER_NAME
1516
from wlsdeploy.aliases.model_constants import DEFAULT_WLS_DOMAIN_NAME
1617
from wlsdeploy.aliases.model_constants import DOMAIN_NAME
1718
from wlsdeploy.aliases.model_constants import DRIVER_NAME
18-
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_PROPERTY_VALUE
19-
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
2619
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_KEYSTOREPWD_PROPERTY
20+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_KEYSTORETYPE_PROPERTY
21+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_FAN_ENABLED
2722
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_SERVER_DN_MATCH_PROPERTY
2823
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_SSL_VERSION
2924
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_TNS_ADMIN
30-
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_NET_FAN_ENABLED
31-
from wlsdeploy.aliases.model_constants import RCU_PREFIX
32-
from wlsdeploy.aliases.model_constants import RCU_SCHEMA_PASSWORD
33-
from wlsdeploy.aliases.model_constants import RCU_ADMIN_PASSWORD
34-
35-
from wlsdeploy.aliases.model_constants import ATP_TNS_ENTRY
36-
from wlsdeploy.aliases.model_constants import RCU_DB_INFO
37-
from wlsdeploy.aliases.model_constants import RCU_DB_CONN
25+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_PROPERTY_VALUE
26+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY
27+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_TRUSTSTORETYPE_PROPERTY
28+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_TRUSTSTORE_PROPERTY
29+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_USER_PROPERTY
30+
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_kEYSTORE_PROPERTY
3831
from wlsdeploy.aliases.model_constants import JDBC_DRIVER_PARAMS
3932
from wlsdeploy.aliases.model_constants import JDBC_DRIVER_PARAMS_PROPERTIES
4033
from wlsdeploy.aliases.model_constants import JDBC_RESOURCE
@@ -46,6 +39,10 @@
4639
from wlsdeploy.aliases.model_constants import PARTITION
4740
from wlsdeploy.aliases.model_constants import PASSWORD
4841
from wlsdeploy.aliases.model_constants import PASSWORD_ENCRYPTED
42+
from wlsdeploy.aliases.model_constants import RCU_DB_CONN
43+
from wlsdeploy.aliases.model_constants import RCU_DB_INFO
44+
from wlsdeploy.aliases.model_constants import RCU_PREFIX
45+
from wlsdeploy.aliases.model_constants import RCU_SCHEMA_PASSWORD
4946
from wlsdeploy.aliases.model_constants import RESOURCE_GROUP
5047
from wlsdeploy.aliases.model_constants import RESOURCE_GROUP_TEMPLATE
5148
from wlsdeploy.aliases.model_constants import SECURITY
@@ -66,6 +63,8 @@
6663
from wlsdeploy.aliases.model_constants import XML_REGISTRY
6764
from wlsdeploy.exception import exception_helper
6865
from wlsdeploy.exception.expection_types import ExceptionType
66+
from wlsdeploy.tool.create import atp_helper
67+
from wlsdeploy.tool.create import rcudbinfo_helper
6968
from wlsdeploy.tool.create.creator import Creator
7069
from wlsdeploy.tool.create.security_provider_creator import SecurityProviderCreator
7170
from wlsdeploy.tool.deploy import deployer_utils
@@ -76,7 +75,6 @@
7675
from wlsdeploy.tool.util.topology_helper import TopologyHelper
7776
from wlsdeploy.util import dictionary_utils
7877
from wlsdeploy.util import model as model_helper
79-
from wlsdeploy.tool.create import atp_helper
8078

8179

8280
class DomainCreator(Creator):
@@ -214,15 +212,15 @@ def __run_rcu(self):
214212
rcu_properties_map = self.model.get_model_domain_info()[RCU_DB_INFO]
215213

216214
if ATP_TNS_ENTRY in rcu_properties_map:
217-
rcu_schema_pass = rcu_properties_map[RCU_SCHEMA_PASSWORD]
218-
rcu_sys_pass = rcu_properties_map[RCU_ADMIN_PASSWORD]
215+
rcu_schema_pass = rcudbinfo_helper.get_rcu_schema_password(rcu_properties_map)
216+
rcu_sys_pass = rcudbinfo_helper.get_admin_password(rcu_properties_map)
219217
runner = RCURunner(domain_type, oracle_home, java_home, rcu_schemas, rcu_properties_map)
220218
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
221219
else:
222-
rcu_db = rcu_properties_map[RCU_DB_CONN]
223-
rcu_prefix = rcu_properties_map[RCU_PREFIX]
224-
rcu_sys_pass = rcu_properties_map[RCU_ADMIN_PASSWORD]
225-
rcu_schema_pass = rcu_properties_map[RCU_SCHEMA_PASSWORD]
220+
rcu_db = rcudbinfo_helper.get_rcu_regular_db_conn(rcu_properties_map)
221+
rcu_prefix = rcudbinfo_helper.get_rcu_prefix(rcu_properties_map)
222+
rcu_sys_pass = rcudbinfo_helper.get_admin_password(rcu_properties_map)
223+
rcu_schema_pass = rcudbinfo_helper.get_rcu_schema_password(rcu_properties_map)
226224

227225
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas)
228226
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
@@ -709,55 +707,6 @@ def __set_atp_connection_property(self, root_location, propery_name, property_va
709707

710708
root_location.remove_name_token(propery_name)
711709

712-
# def _get_atp_connect_string(self, tnsnames_ora_path, tns_sid_name):
713-
#
714-
#
715-
# try:
716-
# f = open(tnsnames_ora_path, "r+")
717-
# try:
718-
# text = f.read()
719-
# finally:
720-
# f.close()
721-
# # The regex below looks for the <dbName>_<level><whitespaces>=<whitespaces> and grabs the
722-
# # tnsConnectString from the current and the next line as tnsnames.ora file has the connect string
723-
# # being printed on 2 lines.
724-
# pattern = tns_sid_name + '\s*=\s*([(].*\n.*)'
725-
# match = re.search(pattern, text)
726-
# if match:
727-
# str = match.group(1)
728-
# tnsConnectString=str.replace('\r','').replace('\n','')
729-
# str = self._format_connect_string(tnsConnectString)
730-
# return str
731-
# except:
732-
# pass
733-
#
734-
# return None
735-
#
736-
# def _format_connect_string(self, connect_string):
737-
# """
738-
# Formats connect string for ATP DB by removing unwanted whitespaces.
739-
# Input:
740-
# (description= (address=(protocol=tcps)(port=1522)(host=adb-preprod.us-phoenix-1.oraclecloud.com))(connect_data=(service_name=uq7p1eavz8qlvts_watsh01_medium.atp.oraclecloud.com))(security=(ssl_server_cert_dn= "CN=adwc-preprod.uscom-east-1.oraclecloud.com,OU=Oracle BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US")) )
741-
# Output Parts:
742-
# 1. (description=(address=(protocol=tcps)(port=1522)(host=adb-preprod.us-phoenix-1.oraclecloud.com))(connect_data=(service_name=uq7p1eavz8qlvts_watsh01_medium.atp.oraclecloud.com))(security=(
743-
# 2. ssl_server_cert_dn=
744-
# 3. "CN=adwc-preprod.uscom-east-1.oraclecloud.com,OU=Oracle BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US"
745-
# 4. )))
746-
# :param connect_string:
747-
# :return:
748-
# """
749-
# pattern = "(.*)(ssl_server_cert_dn=)\s*(\".*\")(.*)"
750-
# match = re.search(pattern, connect_string)
751-
#
752-
# if match:
753-
# part1 = match.group(1).replace(' ','')
754-
# part2 = match.group(2).replace(' ', '')
755-
# # We don't want to remove the spaces from serverDN part.
756-
# part3 = match.group(3)
757-
# part4 = match.group(4).replace(' ', '')
758-
# connect_string = "%s%s%s%s" % (part1, part2, part3, part4)
759-
#
760-
# return connect_string
761710

762711
def __configure_fmw_infra_database(self):
763712
"""
@@ -775,21 +724,19 @@ def __configure_fmw_infra_database(self):
775724

776725
if RCU_DB_INFO in domain_info:
777726
rcu_properties_map = domain_info[RCU_DB_INFO]
778-
#rcu_properties_map = self.model.get_model_domain_info()[RCU_DB_INFO]
779727
# HANDLE ATP case
780728

781729
if ATP_TNS_ENTRY in rcu_properties_map:
782730
has_atp = 1
783731
# parse the tnsnames.ora file and retrieve the connection string
784732
tns_admin = rcu_properties_map[DRIVER_PARAMS_NET_TNS_ADMIN]
785733
rcu_database = atp_helper.get_atp_connect_string(tns_admin + os.sep + 'tnsnames.ora',
786-
rcu_properties_map[
787-
ATP_TNS_ENTRY])
734+
rcudbinfo_helper.get_atp_entry(rcu_properties_map))
788735

789-
rcu_prefix = rcu_properties_map[RCU_PREFIX]
790-
rcu_schema_pwd = rcu_properties_map[RCU_SCHEMA_PASSWORD]
791-
keystore_pwd = rcu_properties_map[DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
792-
truststore_pwd = rcu_properties_map[DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
736+
rcu_prefix = rcudbinfo_helper.get_rcu_prefix(rcu_properties_map)
737+
rcu_schema_pwd = rcudbinfo_helper.get_rcu_schema_password(rcu_properties_map)
738+
keystore_pwd = rcudbinfo_helper.get_keystore_password(rcu_properties_map)
739+
truststore_pwd = rcudbinfo_helper.get_truststore_password(rcu_properties_map)
793740

794741
# Need to set for the connection proeprty for each datasource
795742

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
3+
The Universal Permissive License (UPL), Version 1.0
4+
"""
5+
6+
from wlsdeploy.aliases import model_constants
7+
8+
9+
def get_atp_tns_admin(rcu_properties_map):
10+
return rcu_properties_map[model_constants.DRIVER_PARAMS_NET_TNSADMIN]
11+
12+
13+
def get_atp_entry(rcu_properties_map):
14+
return rcu_properties_map[model_constants.ATP_TNS_ENTRY]
15+
16+
17+
def get_rcu_prefix(rcu_properties_map):
18+
return rcu_properties_map[model_constants.RCU_PREFIX]
19+
20+
21+
def get_rcu_schema_password(rcu_properties_map):
22+
return rcu_properties_map[model_constants.RCU_SCHEMA_PASSWORD]
23+
24+
25+
def get_keystore_password(rcu_properties_map):
26+
return rcu_properties_map[model_constants.DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
27+
28+
29+
def get_truststore_password(rcu_properties_map):
30+
return rcu_properties_map[model_constants.DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
31+
32+
33+
def get_admin_password(rcu_properties_map):
34+
return rcu_properties_map[model_constants.RCU_ADMIN_PASSWORD]
35+
36+
37+
def get_rcu_regular_db_conn(rcu_properties_map):
38+
return rcu_properties_map[model_constants.RCU_DB_CONN]

0 commit comments

Comments
 (0)