Skip to content

Commit 119fa9f

Browse files
committed
refactoring
1 parent 158abcb commit 119fa9f

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 model_deployer
@@ -75,7 +74,6 @@
7574
from wlsdeploy.tool.util.topology_helper import TopologyHelper
7675
from wlsdeploy.util import dictionary_utils
7776
from wlsdeploy.util import model as model_helper
78-
from wlsdeploy.tool.create import atp_helper
7977

8078

8179
class DomainCreator(Creator):
@@ -222,15 +220,15 @@ def __run_rcu(self):
222220
rcu_properties_map = self.model.get_model_domain_info()[RCU_DB_INFO]
223221

224222
if ATP_TNS_ENTRY in rcu_properties_map:
225-
rcu_schema_pass = rcu_properties_map[RCU_SCHEMA_PASSWORD]
226-
rcu_sys_pass = rcu_properties_map[RCU_ADMIN_PASSWORD]
223+
rcu_schema_pass = rcudbinfo_helper.get_rcu_schema_password(rcu_properties_map)
224+
rcu_sys_pass = rcudbinfo_helper.get_admin_password(rcu_properties_map)
227225
runner = RCURunner(domain_type, oracle_home, java_home, rcu_schemas, rcu_properties_map)
228226
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
229227
else:
230-
rcu_db = rcu_properties_map[RCU_DB_CONN]
231-
rcu_prefix = rcu_properties_map[RCU_PREFIX]
232-
rcu_sys_pass = rcu_properties_map[RCU_ADMIN_PASSWORD]
233-
rcu_schema_pass = rcu_properties_map[RCU_SCHEMA_PASSWORD]
228+
rcu_db = rcudbinfo_helper.get_rcu_regular_db_conn(rcu_properties_map)
229+
rcu_prefix = rcudbinfo_helper.get_rcu_prefix(rcu_properties_map)
230+
rcu_sys_pass = rcudbinfo_helper.get_admin_password(rcu_properties_map)
231+
rcu_schema_pass = rcudbinfo_helper.get_rcu_schema_password(rcu_properties_map)
234232

235233
runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas)
236234
runner.runRcu(rcu_sys_pass, rcu_schema_pass)
@@ -715,55 +713,6 @@ def __set_atp_connection_property(self, root_location, propery_name, property_va
715713

716714
root_location.remove_name_token(propery_name)
717715

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

768717
def __configure_fmw_infra_database(self):
769718
"""
@@ -781,21 +730,19 @@ def __configure_fmw_infra_database(self):
781730

782731
if RCU_DB_INFO in domain_info:
783732
rcu_properties_map = domain_info[RCU_DB_INFO]
784-
#rcu_properties_map = self.model.get_model_domain_info()[RCU_DB_INFO]
785733
# HANDLE ATP case
786734

787735
if ATP_TNS_ENTRY in rcu_properties_map:
788736
has_atp = 1
789737
# parse the tnsnames.ora file and retrieve the connection string
790738
tns_admin = rcu_properties_map[DRIVER_PARAMS_NET_TNS_ADMIN]
791739
rcu_database = atp_helper.get_atp_connect_string(tns_admin + os.sep + 'tnsnames.ora',
792-
rcu_properties_map[
793-
ATP_TNS_ENTRY])
740+
rcudbinfo_helper.get_atp_entry(rcu_properties_map))
794741

795-
rcu_prefix = rcu_properties_map[RCU_PREFIX]
796-
rcu_schema_pwd = rcu_properties_map[RCU_SCHEMA_PASSWORD]
797-
keystore_pwd = rcu_properties_map[DRIVER_PARAMS_KEYSTOREPWD_PROPERTY]
798-
truststore_pwd = rcu_properties_map[DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY]
742+
rcu_prefix = rcudbinfo_helper.get_rcu_prefix(rcu_properties_map)
743+
rcu_schema_pwd = rcudbinfo_helper.get_rcu_schema_password(rcu_properties_map)
744+
keystore_pwd = rcudbinfo_helper.get_keystore_password(rcu_properties_map)
745+
truststore_pwd = rcudbinfo_helper.get_truststore_password(rcu_properties_map)
799746

800747
# Need to set for the connection proeprty for each datasource
801748

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)