44
55The main module for the WLSDeploy tool to create empty domains.
66"""
7+ import exceptions
78import os
89import sys
9- import exceptions
1010
11- from java .lang import Exception as JException
1211from java .io import IOException
12+ from java .lang import Class as JClass
13+ from java .lang import Exception as JException
1314from java .lang import IllegalArgumentException
1415from java .lang import String
15- from java .lang import System
16- import java .sql .DriverManager as DriverManager
17- import java .util .Properties as Properties
18-
16+ from java .sql import DriverManager
17+ from java .util import Properties
1918from oracle .weblogic .deploy .create import CreateException
2019from oracle .weblogic .deploy .deploy import DeployException
21- from oracle .weblogic .deploy .validate import ValidateException
2220from oracle .weblogic .deploy .util import FileUtils
2321from oracle .weblogic .deploy .util import WLSDeployArchiveIOException
22+ from oracle .weblogic .deploy .validate import ValidateException
2423
2524sys .path .insert (0 , os .path .dirname (os .path .realpath (sys .argv [0 ])))
2625
2726# imports from local packages start here
2827from wlsdeploy .aliases .aliases import Aliases
29- from wlsdeploy .aliases import model_constants
30- from wlsdeploy .aliases .model_constants import DEFAULT_WLS_DOMAIN_NAME , PATH_TO_RCU_ADMIN_PASSWORD , \
31- PATH_TO_RCU_SCHEMA_PASSWORD
28+ from wlsdeploy .aliases .model_constants import DEFAULT_WLS_DOMAIN_NAME
3229from wlsdeploy .aliases .model_constants import DOMAIN_NAME
33- from wlsdeploy .aliases .model_constants import PATH_TO_RCU_DB_CONN
34- from wlsdeploy .aliases .model_constants import PATH_TO_RCU_PREFIX
3530from wlsdeploy .aliases .model_constants import TOPOLOGY
3631from wlsdeploy .aliases .wlst_modes import WlstModes
3732from wlsdeploy .exception import exception_helper
3833from wlsdeploy .exception .exception_types import ExceptionType
3934from wlsdeploy .logging .platform_logger import PlatformLogger
40- from wlsdeploy .tool .create .rcudbinfo_helper import RcuDbInfo
35+ from wlsdeploy .tool .create import rcudbinfo_helper
36+ from wlsdeploy .tool .create .jps_config_helper import JpsConfigHelper
4137from wlsdeploy .tool .create .domain_creator import DomainCreator
4238from wlsdeploy .tool .util import model_context_helper
4339from wlsdeploy .tool .util .archive_helper import ArchiveList
4440from wlsdeploy .tool .util .wlst_helper import WlstHelper
4541from wlsdeploy .tool .util import wlst_helper
46- from wlsdeploy .tool .validate .content_validator import CreateDomainContentValidator
42+ from wlsdeploy .tool .validate .create_content_validator import CreateDomainContentValidator
4743from wlsdeploy .util import cla_helper
48- from wlsdeploy .util import dictionary_utils
4944from wlsdeploy .util import env_helper
5045from wlsdeploy .util import getcreds
5146from wlsdeploy .util import string_utils
5247from wlsdeploy .util import tool_main
5348from wlsdeploy .util .cla_utils import CommandLineArgUtil
5449from wlsdeploy .util .cla_utils import TOOL_TYPE_CREATE
5550from wlsdeploy .util .exit_code import ExitCode
56- from wlsdeploy .tool .create import atp_helper
57- from wlsdeploy .tool .create import ssl_helper
58- import wlsdeploy .tool .create .rcudbinfo_helper as rcudbinfo_helper
5951
6052wlst_helper .wlst_functions = globals ()
6153
@@ -198,77 +190,6 @@ def __process_opss_args(optional_arg_map):
198190 optional_arg_map [CommandLineArgUtil .OPSS_WALLET_PASSPHRASE ] = str (String (passphrase ))
199191
200192
201- def validate_rcu_args_and_model (model_context , model , archive_helper , aliases ):
202- _method_name = 'validate_rcu_args_and_model'
203-
204- has_atpdbinfo = 0
205- has_ssldbinfo = 0
206-
207- domain_info = dictionary_utils .get_dictionary_element (model , model_constants .DOMAIN_INFO )
208-
209- if model_context .get_domain_typedef ().requires_rcu ():
210- if model_constants .RCU_DB_INFO in domain_info :
211- rcu_info = domain_info [model_constants .RCU_DB_INFO ]
212- rcu_db_info = RcuDbInfo (model_context , aliases , rcu_info )
213-
214- if string_utils .is_empty (rcu_db_info .get_rcu_prefix ()):
215- ex = exception_helper .create_validate_exception ('WLSDPLY-12414' , model_context .get_domain_type (),
216- PATH_TO_RCU_PREFIX )
217- __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
218- raise ex
219- #
220- # Skip validating rcu_db_conn since is there is a tnsnames.ora file,
221- # the connection string is picked up from there.
222- #
223- if string_utils .is_empty (rcu_db_info .get_rcu_schema_password ()):
224- ex = exception_helper .create_validate_exception ('WLSDPLY-12414' , model_context .get_domain_type (),
225- PATH_TO_RCU_SCHEMA_PASSWORD )
226- __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
227- raise ex
228-
229- if model_context .is_run_rcu () and string_utils .is_empty (rcu_db_info .get_rcu_admin_password ()):
230- ex = exception_helper .create_validate_exception ('WLSDPLY-12415' , model_context .get_domain_type (),
231- CommandLineArgUtil .RUN_RCU_SWITCH , PATH_TO_RCU_ADMIN_PASSWORD )
232- __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
233- raise ex
234-
235- has_tns_admin = rcu_db_info .has_tns_admin ()
236- is_regular_db = rcu_db_info .is_regular_db ()
237- has_atpdbinfo = rcu_db_info .has_atpdbinfo ()
238- has_ssldbinfo = rcu_db_info .has_ssldbinfo ()
239-
240- _validate_atp_wallet_in_archive (archive_helper , is_regular_db , has_tns_admin , model )
241- else :
242- ex = exception_helper .create_validate_exception ('WLSDPLY-12408' , model_context .get_domain_type (),
243- PATH_TO_RCU_DB_CONN , PATH_TO_RCU_PREFIX ,
244- PATH_TO_RCU_ADMIN_PASSWORD , PATH_TO_RCU_SCHEMA_PASSWORD )
245- __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
246- raise ex
247-
248- return has_atpdbinfo , has_ssldbinfo
249-
250-
251- def _validate_atp_wallet_in_archive (archive_helper , is_regular_db , has_tns_admin , model ):
252- _method_name = '_validate_atp_wallet_in_archive'
253- if archive_helper and not is_regular_db :
254- # 1. If it does not have the oracle.net.tns_admin specified, then see if it was extracted
255- # 2. If it is plain old regular oracle db, do nothing
256- # 3. If it does not have tns_admin in the model, then the wallet must be in the archive
257- if not has_tns_admin :
258- wallet_path = archive_helper .check_rcu_wallet_path ()
259- if wallet_path :
260- # update the model to add the tns_admin
261- model [model_constants .DOMAIN_INFO ][model_constants .RCU_DB_INFO ][
262- model_constants .DRIVER_PARAMS_NET_TNS_ADMIN ] = wallet_path
263- else :
264- ex = exception_helper .create_validate_exception ('WLSDPLY-12411' )
265- __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
266- raise ex
267-
268- if not is_regular_db :
269- System .setProperty ('oracle.jdbc.fanEnabled' , 'false' )
270-
271-
272193def _get_domain_path (model_context , model ):
273194 """
274195 Returns the domain home path.
@@ -286,26 +207,31 @@ def _get_domain_path(model_context, model):
286207
287208
288209def _precheck_rcu_connectivity (model_context , creator , rcu_db_info ):
289-
290210 _method_name = '_precheck_rcu_connectivity'
211+ __logger .entering (class_name = _class_name , method_name = _method_name )
212+
291213 domain_typename = model_context .get_domain_typedef ().get_domain_type ()
214+ if model_context .get_domain_typedef ().requires_rcu () and not model_context .is_run_rcu ():
215+ rcu_prefix = rcu_db_info .get_rcu_prefix ()
216+ schema_name = None
217+ if not string_utils .is_empty (rcu_prefix ):
218+ user_name = model_context .get_weblogic_helper ().get_stb_user_name (rcu_prefix )
219+ schema_name = user_name [len (rcu_prefix ) + 1 :]
220+
221+ if schema_name is None or schema_name not in model_context .get_domain_typedef ().get_rcu_schemas ():
222+ __logger .exiting (class_name = _class_name , method_name = _method_name )
223+ return
292224
293- if model_context .get_domain_typedef ().requires_rcu () and not model_context .is_run_rcu () and 'STB' in \
294- model_context .get_domain_typedef ().get_rcu_schemas ():
295- # how to create rcu_db_info ?
296225 db_conn_props = None
297- fmw_database , is_atp_ds , is_ssl_ds , keystore , keystore_pwd , keystore_type , rcu_prefix , rcu_schema_pwd , \
298- tns_admin , truststore , truststore_pwd , \
299- truststore_type = creator .get_rcu_basic_connection_info (rcu_db_info )
300-
301- if is_atp_ds :
302- db_conn_props = creator .get_atp_standard_conn_properties (tns_admin , truststore , truststore_pwd ,
303- truststore_type , keystore_pwd , keystore_type ,
304- keystore )
305- elif is_ssl_ds :
306- db_conn_props = creator .get_ssl_standard_conn_properties (tns_admin , truststore , truststore_pwd ,
307- truststore_type , keystore_pwd , keystore_type ,
308- keystore )
226+
227+ rcu_database_type = rcu_db_info .get_rcu_database_type ()
228+ tns_admin , rcu_prefix , jdbc_conn_string , rcu_schema_pwd = \
229+ creator .get_rcu_datasource_basic_connection_info (rcu_db_info )
230+
231+ if rcu_db_info .is_use_atp () or rcu_db_info .is_use_ssl ():
232+ db_conn_props = creator .get_jdbc_ssl_connection_properties (tns_admin , rcu_db_info .is_use_atp (), rcu_db_info )
233+
234+ jdbc_driver_name = creator .get_jdbc_driver_class_name (rcu_database_type )
309235
310236 try :
311237 props = Properties ()
@@ -314,24 +240,29 @@ def _precheck_rcu_connectivity(model_context, creator, rcu_db_info):
314240 for key in item .keys ():
315241 props .put (key , item [key ])
316242
317- __logger .info ('WLSDPLY_12575' , 'test datasource' , fmw_database , rcu_prefix + "_STB" , props ,
318- class_name = _class_name , method_name = _method_name )
243+ __logger .info ('WLSDPLY_12575' , 'test datasource' , jdbc_conn_string , schema_name , props ,
244+ class_name = _class_name , method_name = _method_name )
319245
320- props .put ('user' , rcu_prefix + "_STB" )
246+ props .put ('user' , user_name )
321247 props .put ('password' , rcu_schema_pwd )
322248
323- DriverManager .getConnection (fmw_database , props )
249+ # Force the driver to be loaded and registered...
250+ JClass .forName (jdbc_driver_name )
251+ DriverManager .getConnection (jdbc_conn_string , props )
324252
325253 except (exceptions .Exception , JException ), e :
326- ex = exception_helper .create_create_exception ('WLSDPLY-12505' , domain_typename , e . getClass (). getName (),
327- e .getLocalizedMessage (), error = e )
254+ ex = exception_helper .create_create_exception ('WLSDPLY-12505' , domain_typename ,
255+ e .getClass (). getName (), e . getLocalizedMessage (), error = e )
328256 __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
329257 raise ex
330258 except ee :
331259 ex = exception_helper .create_create_exception ('WLSDPLY-12506' , domain_typename , error = ee )
332260 __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
333261 raise ex
334262
263+ __logger .exiting (class_name = _class_name , method_name = _method_name )
264+
265+
335266def main (model_context ):
336267 """
337268 The entry point for the createDomain tool.
@@ -353,24 +284,23 @@ def main(model_context):
353284 # set domain home result in model context, for use by deployers and helpers
354285 model_context .set_domain_home (_get_domain_path (model_context , model_dictionary ))
355286
356- # check for any content problems in the merged, substituted model
357- content_validator = CreateDomainContentValidator (model_context , aliases )
358- content_validator .validate_model (model_dictionary )
359-
360287 archive_helper = None
361288 archive_file_name = model_context .get_archive_file_name ()
362289 if archive_file_name :
363- domain_path = _get_domain_path (model_context , model_dictionary )
364290 archive_helper = ArchiveList (archive_file_name , model_context , ExceptionType .CREATE )
365- if archive_helper :
366- if not os .path .exists (os .path .abspath (domain_path )):
367- os .mkdir (os .path .abspath (domain_path ))
368291
369- archive_helper .extract_all_database_wallets ()
370- archive_helper .extract_custom_directory ()
371- archive_helper .extract_weblogic_remote_console_extension ()
292+ # check for any content problems in the merged, substituted model
293+ content_validator = CreateDomainContentValidator (model_context , archive_helper , aliases )
294+ content_validator .validate_model (model_dictionary )
295+
296+ if archive_helper :
297+ domain_path = _get_domain_path (model_context , model_dictionary )
298+ if not os .path .exists (os .path .abspath (domain_path )):
299+ os .mkdir (os .path .abspath (domain_path ))
372300
373- has_atp , has_ssl = validate_rcu_args_and_model (model_context , model_dictionary , archive_helper , aliases )
301+ archive_helper .extract_all_database_wallets ()
302+ archive_helper .extract_custom_directory ()
303+ archive_helper .extract_weblogic_remote_console_extension ()
374304
375305 creator = DomainCreator (model_dictionary , model_context , aliases )
376306
@@ -382,10 +312,8 @@ def main(model_context):
382312 creator .create ()
383313
384314 if model_context .get_domain_typedef ().requires_rcu ():
385- if has_atp :
386- atp_helper .fix_jps_config (rcu_db_info , model_context )
387- elif has_ssl :
388- ssl_helper .fix_jps_config (rcu_db_info , model_context )
315+ jps_config_helper = JpsConfigHelper (model_context , rcu_db_info )
316+ jps_config_helper .fix_jps_config ()
389317
390318 except WLSDeployArchiveIOException , ex :
391319 _exit_code = ExitCode .ERROR
0 commit comments