14
14
from oracle .weblogic .deploy .deploy import DeployException
15
15
from oracle .weblogic .deploy .util import CLAException
16
16
from oracle .weblogic .deploy .util import FileUtils
17
- from oracle .weblogic .deploy .util import TranslateException
18
- from oracle .weblogic .deploy .util import VariableException
19
17
from oracle .weblogic .deploy .util import WLSDeployArchiveIOException
20
18
from oracle .weblogic .deploy .util import WebLogicDeployToolingVersion
21
- from oracle .weblogic .deploy .validate import ValidateException
22
19
23
20
sys .path .append (os .path .dirname (os .path .realpath (sys .argv [0 ])))
24
21
36
33
from wlsdeploy .tool .create .rcudbinfo_helper import RcuDbInfo
37
34
from wlsdeploy .tool .create .domain_creator import DomainCreator
38
35
from wlsdeploy .tool .create .domain_typedef import CREATE_DOMAIN
39
- from wlsdeploy .tool .util import filter_helper
40
36
from wlsdeploy .tool .util import model_context_helper
41
37
from wlsdeploy .tool .util .alias_helper import AliasHelper
42
38
from wlsdeploy .tool .util .archive_helper import ArchiveHelper
43
39
from wlsdeploy .tool .util .wlst_helper import WlstHelper
44
40
from wlsdeploy .tool .util import wlst_helper
45
- from wlsdeploy .tool .validate .validator import Validator
46
41
from wlsdeploy .util import cla_helper
47
42
from wlsdeploy .util import getcreds
48
43
from wlsdeploy .util import tool_exit
49
- from wlsdeploy .util import variables
50
44
from wlsdeploy .util .cla_utils import CommandLineArgUtil
51
45
from wlsdeploy .util .cla_utils import TOOL_TYPE_CREATE
52
46
from wlsdeploy .util .weblogic_helper import WebLogicHelper
62
56
__version = WebLogicHelper (__logger ).get_actual_weblogic_version ()
63
57
64
58
__required_arguments = [
65
- CommandLineArgUtil .ORACLE_HOME_SWITCH ,
66
- CommandLineArgUtil .DOMAIN_TYPE_SWITCH
59
+ CommandLineArgUtil .ORACLE_HOME_SWITCH
67
60
]
68
61
69
62
__optional_arguments = [
70
63
CommandLineArgUtil .ARCHIVE_FILE_SWITCH ,
71
64
CommandLineArgUtil .DOMAIN_HOME_SWITCH ,
72
65
CommandLineArgUtil .DOMAIN_PARENT_SWITCH ,
66
+ CommandLineArgUtil .DOMAIN_TYPE_SWITCH ,
73
67
CommandLineArgUtil .JAVA_HOME_SWITCH ,
74
68
CommandLineArgUtil .MODEL_FILE_SWITCH ,
75
69
CommandLineArgUtil .RUN_RCU_SWITCH ,
@@ -95,42 +89,29 @@ def __process_args(args):
95
89
cla_util = CommandLineArgUtil (_program_name , __required_arguments , __optional_arguments )
96
90
cla_util .set_allow_multiple_models (True )
97
91
required_arg_map , optional_arg_map = cla_util .process_args (args , TOOL_TYPE_CREATE )
98
- __verify_required_args_present ( required_arg_map )
92
+ cla_helper . verify_required_args_present ( _program_name , __required_arguments , required_arg_map )
99
93
__process_java_home_arg (optional_arg_map )
100
94
__process_domain_location_args (optional_arg_map )
101
- __process_model_args (optional_arg_map )
95
+
96
+ # don't verify that the archive is valid until it is needed.
97
+ # this requirement is specific to create, other tools will verify it.
98
+ cla_helper .validate_model_present (_program_name , optional_arg_map )
99
+ cla_helper .validate_variable_file_exists (_program_name , optional_arg_map )
102
100
103
101
#
104
102
# Verify that the domain type is a known type and load its typedef.
105
103
#
106
- domain_typedef = model_context_helper .create_typedef (_program_name , required_arg_map )
104
+ domain_typedef = model_context_helper .create_typedef (_program_name , optional_arg_map )
107
105
108
106
__process_rcu_args (optional_arg_map , domain_typedef .get_domain_type (), domain_typedef )
109
- __process_encryption_args (optional_arg_map )
107
+ cla_helper . process_encryption_args (optional_arg_map )
110
108
__process_opss_args (optional_arg_map )
111
109
112
110
combined_arg_map = optional_arg_map .copy ()
113
111
combined_arg_map .update (required_arg_map )
114
112
return model_context_helper .create_context (_program_name , combined_arg_map , domain_typedef )
115
113
116
114
117
- def __verify_required_args_present (required_arg_map ):
118
- """
119
- Verify that the required args are present.
120
- :param required_arg_map: the required arguments map
121
- :raises CLAException: if one or more of the required arguments are missing
122
- """
123
- _method_name = '__verify_required_args_present'
124
-
125
- for req_arg in __required_arguments :
126
- if req_arg not in required_arg_map :
127
- ex = exception_helper .create_cla_exception ('WLSDPLY-20005' , _program_name , req_arg )
128
- ex .setExitCode (CommandLineArgUtil .USAGE_ERROR_EXIT_CODE )
129
- __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
130
- raise ex
131
- return
132
-
133
-
134
115
def __process_java_home_arg (optional_arg_map ):
135
116
"""
136
117
Verify that java_home is set. If not, set it.
@@ -175,22 +156,6 @@ def __process_domain_location_args(optional_arg_map):
175
156
return
176
157
177
158
178
- def __process_model_args (optional_arg_map ):
179
- """
180
- Verify that the specified model_file exists, or there is a model file in the specified archive_file.
181
- Extract the model file if only the archive_file was provided.
182
- :param optional_arg_map: the optional arguments map
183
- :raises CLAException: if the arguments are invalid or an error occurs extracting the model from the archive
184
- """
185
-
186
- # don't verify that the archive is valid until it is needed.
187
- # this requirement is specific to create, other tools will verify it.
188
-
189
- cla_helper .validate_model_present (_program_name , optional_arg_map )
190
- cla_helper .validate_variable_file_exists (_program_name , optional_arg_map )
191
- return
192
-
193
-
194
159
def __process_rcu_args (optional_arg_map , domain_type , domain_typedef ):
195
160
"""
196
161
Determine if the RCU is needed and validate/prompt for any missing information
@@ -246,28 +211,6 @@ def __process_rcu_args(optional_arg_map, domain_type, domain_typedef):
246
211
return
247
212
248
213
249
- def __process_encryption_args (optional_arg_map ):
250
- """
251
- Determine if the user is using our encryption and if so, get the passphrase.
252
- :param optional_arg_map: the optional arguments map
253
- :raises CLAException: if getting the passphrase from the user fails
254
- """
255
- _method_name = '__process_encryption_args'
256
-
257
- if CommandLineArgUtil .USE_ENCRYPTION_SWITCH in optional_arg_map and \
258
- CommandLineArgUtil .PASSPHRASE_SWITCH not in optional_arg_map :
259
- try :
260
- passphrase = getcreds .getpass ('WLSDPLY-20002' )
261
- except IOException , ioe :
262
- ex = exception_helper .create_cla_exception ('WLSDPLY-20003' , ioe .getLocalizedMessage (),
263
- error = ioe )
264
- ex .setExitCode (CommandLineArgUtil .ARG_VALIDATION_ERROR_EXIT_CODE )
265
- __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
266
- raise ex
267
- optional_arg_map [CommandLineArgUtil .PASSPHRASE_SWITCH ] = String (passphrase )
268
- return
269
-
270
-
271
214
def __process_opss_args (optional_arg_map ):
272
215
"""
273
216
Determine if the user is using opss wallet and if so, get the passphrase.
@@ -290,27 +233,6 @@ def __process_opss_args(optional_arg_map):
290
233
return
291
234
292
235
293
- def validate_model (model_dictionary , model_context , aliases ):
294
- _method_name = 'validate_model'
295
-
296
- try :
297
- validator = Validator (model_context , aliases , wlst_mode = __wlst_mode )
298
-
299
- # no need to pass the variable file for processing, substitution has already been performed
300
- return_code = validator .validate_in_tool_mode (model_dictionary , variables_file_name = None ,
301
- archive_file_name = model_context .get_archive_file_name ())
302
- except ValidateException , ex :
303
- __logger .severe ('WLSDPLY-20000' , _program_name , ex .getLocalizedMessage (), error = ex ,
304
- class_name = _class_name , method_name = _method_name )
305
- cla_helper .clean_up_temp_files ()
306
- tool_exit .end (model_context , CommandLineArgUtil .PROG_ERROR_EXIT_CODE )
307
-
308
- if return_code == Validator .ReturnCode .STOP :
309
- __logger .severe ('WLSDPLY-20001' , _program_name , class_name = _class_name , method_name = _method_name )
310
- cla_helper .clean_up_temp_files ()
311
- tool_exit .end (model_context , CommandLineArgUtil .PROG_ERROR_EXIT_CODE )
312
-
313
-
314
236
def validate_rcu_args_and_model (model_context , model , archive_helper , alias_helper ):
315
237
_method_name = 'validate_rcu_args_and_model'
316
238
@@ -397,62 +319,30 @@ def main(args):
397
319
model_context = model_context_helper .create_exit_context (_program_name )
398
320
tool_exit .end (model_context , exit_code )
399
321
400
- variable_map = {}
401
- try :
402
- if model_context .get_variable_file ():
403
- variable_map = variables .load_variables (model_context .get_variable_file ())
404
- except VariableException , ex :
405
- __logger .severe ('WLSDPLY-20004' , _program_name , ex .getLocalizedMessage (), error = ex ,
406
- class_name = _class_name , method_name = _method_name )
407
- cla_helper .clean_up_temp_files ()
408
- tool_exit .end (model_context , CommandLineArgUtil .PROG_ERROR_EXIT_CODE )
409
-
410
- model_file_value = model_context .get_model_file ()
411
- try :
412
- model = cla_helper .merge_model_files (model_file_value , variable_map )
413
- except TranslateException , te :
414
- __logger .severe ('WLSDPLY-20009' , _program_name , model_file_value , te .getLocalizedMessage (), error = te ,
415
- class_name = _class_name , method_name = _method_name )
416
- cla_helper .clean_up_temp_files ()
417
- tool_exit .end (model_context , CommandLineArgUtil .PROG_ERROR_EXIT_CODE )
418
-
419
- try :
420
- variables .substitute (model , variable_map , model_context )
421
- except VariableException , ex :
422
- __logger .severe ('WLSDPLY-20004' , _program_name , ex .getLocalizedMessage (), error = ex ,
423
- class_name = _class_name , method_name = _method_name )
424
- cla_helper .clean_up_temp_files ()
425
- tool_exit .end (model_context , CommandLineArgUtil .PROG_ERROR_EXIT_CODE )
426
-
427
- cla_helper .persist_model (model_context , model )
428
-
429
322
aliases = Aliases (model_context , wlst_mode = __wlst_mode )
430
- alias_helper = AliasHelper (aliases , __logger , ExceptionType .CREATE )
431
- validate_model (model , model_context , aliases )
432
323
433
- if filter_helper .apply_filters (model , "create" ):
434
- # if any filters were applied, re-validate the model
435
- validate_model (model , model_context , aliases )
324
+ model_dictionary = cla_helper .load_model (_program_name , model_context , aliases , "create" , __wlst_mode )
436
325
437
326
try :
438
327
archive_helper = None
439
328
archive_file_name = model_context .get_archive_file_name ()
440
329
if archive_file_name :
441
- domain_path = _get_domain_path (model_context , model )
330
+ domain_path = _get_domain_path (model_context , model_dictionary )
442
331
archive_helper = ArchiveHelper (archive_file_name , domain_path , __logger , ExceptionType .CREATE )
443
332
444
- has_atp = validate_rcu_args_and_model (model_context , model , archive_helper , alias_helper )
333
+ alias_helper = AliasHelper (aliases , __logger , ExceptionType .CREATE )
334
+ has_atp = validate_rcu_args_and_model (model_context , model_dictionary , archive_helper , alias_helper )
445
335
446
336
# check if there is an atpwallet and extract in the domain dir
447
337
# it is to support non JRF domain but user wants to use ATP database
448
338
if not has_atp and archive_helper :
449
339
archive_helper .extract_atp_wallet ()
450
340
451
- creator = DomainCreator (model , model_context , aliases )
341
+ creator = DomainCreator (model_dictionary , model_context , aliases )
452
342
creator .create ()
453
343
454
344
if has_atp :
455
- rcu_properties_map = model [model_constants .DOMAIN_INFO ][model_constants .RCU_DB_INFO ]
345
+ rcu_properties_map = model_dictionary [model_constants .DOMAIN_INFO ][model_constants .RCU_DB_INFO ]
456
346
rcu_db_info = RcuDbInfo (alias_helper , rcu_properties_map )
457
347
atp_helper .fix_jps_config (rcu_db_info , model_context )
458
348
0 commit comments