12
12
from java .lang import IllegalArgumentException
13
13
from java .lang import IllegalStateException
14
14
from java .lang import String
15
-
16
15
from oracle .weblogic .deploy .aliases import AliasException
17
16
from oracle .weblogic .deploy .discover import DiscoverException
18
17
from oracle .weblogic .deploy .util import CLAException
19
18
from oracle .weblogic .deploy .util import FileUtils
20
19
from oracle .weblogic .deploy .util import PyWLSTException
21
20
from oracle .weblogic .deploy .util import TranslateException
22
- from oracle .weblogic .deploy .util import WebLogicDeployToolingVersion
23
21
from oracle .weblogic .deploy .util import WLSDeployArchive
24
22
from oracle .weblogic .deploy .util import WLSDeployArchiveIOException
23
+ from oracle .weblogic .deploy .util import WebLogicDeployToolingVersion
25
24
from oracle .weblogic .deploy .validate import ValidateException
26
25
27
26
sys .path .append (os .path .dirname (os .path .realpath (sys .argv [0 ])))
28
27
29
28
from wlsdeploy .aliases import model_constants
30
29
from wlsdeploy .aliases .aliases import Aliases
31
30
from wlsdeploy .aliases .location_context import LocationContext
31
+ import wlsdeploy .tool .util .variable_injector as variable_injector
32
+
32
33
from wlsdeploy .aliases .wlst_modes import WlstModes
33
34
from wlsdeploy .exception import exception_helper
34
35
from wlsdeploy .logging .platform_logger import PlatformLogger
39
40
from wlsdeploy .tool .discover .multi_tenant_discoverer import MultiTenantDiscoverer
40
41
from wlsdeploy .tool .discover .resources_discoverer import ResourcesDiscoverer
41
42
from wlsdeploy .tool .discover .topology_discoverer import TopologyDiscoverer
42
- from wlsdeploy .tool .validate .validator import Validator
43
43
from wlsdeploy .tool .util import filter_helper
44
+ from wlsdeploy .tool .util .variable_injector import VariableInjector
45
+ from wlsdeploy .tool .validate .validator import Validator
44
46
from wlsdeploy .util import wlst_helper
45
47
from wlsdeploy .util import model_translator
46
48
from wlsdeploy .util .cla_utils import CommandLineArgUtil
61
63
62
64
__optional_arguments = [
63
65
# Used by shell script to locate WLST
64
- CommandLineArgUtil .DOMAIN_TYPE_SWITCH ,
65
66
CommandLineArgUtil .MODEL_FILE_SWITCH ,
67
+ CommandLineArgUtil .DOMAIN_TYPE_SWITCH ,
68
+ CommandLineArgUtil .VARIABLE_PROPERTIES_FILE_SWITCH ,
66
69
CommandLineArgUtil .ADMIN_URL_SWITCH ,
67
70
CommandLineArgUtil .ADMIN_USER_SWITCH ,
68
71
CommandLineArgUtil .ADMIN_PASS_SWITCH
@@ -83,6 +86,7 @@ def __process_args(args):
83
86
__verify_required_args_present (required_arg_map )
84
87
__wlst_mode = __process_online_args (optional_arg_map )
85
88
__process_archive_filename_arg (required_arg_map )
89
+ __process_variable_filename_arg (optional_arg_map )
86
90
87
91
combined_arg_map = optional_arg_map .copy ()
88
92
combined_arg_map .update (required_arg_map )
@@ -162,6 +166,28 @@ def __process_archive_filename_arg(required_arg_map):
162
166
return
163
167
164
168
169
+ def __process_variable_filename_arg (optional_arg_map ):
170
+ """
171
+ If the variable filename argument is present, the required model variable injector json file must exist in
172
+ the WLSDEPLOY lib directory.
173
+ :param optional_arg_map: containing the variable file name
174
+ :raises: CLAException: if this argument is present but the model variable injector json does not exist
175
+ """
176
+ _method_name = '__process_variable_filename_arg'
177
+
178
+ if CommandLineArgUtil .VARIABLE_PROPERTIES_FILE_SWITCH in optional_arg_map :
179
+ variable_injector_file_name = variable_injector .get_default_variable_injector_file_name ()
180
+ try :
181
+ FileUtils .validateExistingFile (variable_injector_file_name )
182
+ except IllegalArgumentException , ie :
183
+ ex = exception_helper .create_cla_exception ('WLSDPLY-06021' , optional_arg_map [
184
+ CommandLineArgUtil .VARIABLE_PROPERTIES_FILE_SWITCH ], variable_injector_file_name ,
185
+ ie .getLocalizedMessage (), error = ie )
186
+ __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
187
+ raise ex
188
+ return
189
+
190
+
165
191
def __discover (model_context , aliases ):
166
192
"""
167
193
Populate the model from the domain.
@@ -210,7 +236,7 @@ def _add_domain_name(location, aliases):
210
236
location .add_name_token (aliases .get_name_token (location ), domain_name )
211
237
__logger .info ('WLSDPLY-06022' , domain_name , class_name = _class_name , method_name = _method_name )
212
238
else :
213
- de = exception_helper .create_discover_exception ('WLSDPLY-WLSDPLY-06021 ' )
239
+ de = exception_helper .create_discover_exception ('WLSDPLY-WLSDPLY-06023 ' )
214
240
__logger .throwing (class_name = _class_name , method_name = _method_name , error = de )
215
241
raise de
216
242
@@ -370,7 +396,7 @@ def __persist_model(model, model_context):
370
396
if not model_file .delete ():
371
397
model_file .deleteOnExit ()
372
398
except (WLSDeployArchiveIOException , IllegalArgumentException ), arch_ex :
373
- ex = exception_helper .create_discover_exception ('WLSDPLY-06009 ' , model_file .getAbsolutePath (),
399
+ ex = exception_helper .create_discover_exception ('WLSDPLY-20023 ' , model_file .getAbsolutePath (),
374
400
model_file_name , arch_ex .getLocalizedMessage (),
375
401
error = arch_ex )
376
402
__logger .throwing (ex , class_name = _class_name , method_name = _method_name )
@@ -394,14 +420,21 @@ def __check_and_customize_model(model, model_context, aliases):
394
420
if filter_helper .apply_filters (model .get_model (), "discover" ):
395
421
__logger .info ('WLSDPLY-06014' , _class_name = _class_name , method_name = _method_name )
396
422
423
+ inserted , variable_model , variable_file_name = VariableInjector (_program_name , model .get_model (), model_context ,
424
+ WebLogicHelper (
425
+ __logger ).get_actual_weblogic_version ()).\
426
+ inject_variables_keyword_file ()
427
+ if inserted :
428
+ model = Model (variable_model )
397
429
try :
398
430
validator = Validator (model_context , wlst_mode = __wlst_mode , aliases = aliases )
399
431
400
432
# no variables are generated by the discover tool
401
- validator .validate_in_tool_mode (model .get_model (), variables_file_name = None ,
433
+ validator .validate_in_tool_mode (model .get_model (), variables_file_name = variable_file_name ,
402
434
archive_file_name = model_context .get_archive_file_name ())
403
435
except ValidateException , ex :
404
436
__logger .warning ('WLSDPLY-06015' , ex .getLocalizedMessage (), class_name = _class_name , method_name = _method_name )
437
+ return model
405
438
406
439
407
440
def __log_and_exit (exit_code , class_name , method_name ):
@@ -412,6 +445,7 @@ def __log_and_exit(exit_code, class_name, method_name):
412
445
:param method_name: the method name to pass to the logger
413
446
"""
414
447
__logger .exiting (result = exit_code , class_name = class_name , method_name = method_name )
448
+
415
449
sys .exit (exit_code )
416
450
417
451
@@ -458,13 +492,14 @@ def main(args):
458
492
model_context .get_domain_home (), ex .getLocalizedMessage (),
459
493
error = ex , class_name = _class_name , method_name = _method_name )
460
494
__log_and_exit (CommandLineArgUtil .PROG_ERROR_EXIT_CODE , _class_name , _method_name )
461
-
462
- __check_and_customize_model (model , model_context , aliases )
463
-
495
+
496
+ model = __check_and_customize_model (model , model_context )
497
+
464
498
try :
465
499
__persist_model (model , model_context )
500
+
466
501
except TranslateException , ex :
467
- __logger .severe ('WLSDPLY-06012 ' , _program_name , model_context .get_archive_file_name (), ex .getLocalizedMessage (),
502
+ __logger .severe ('WLSDPLY-20024 ' , _program_name , model_context .get_archive_file_name (), ex .getLocalizedMessage (),
468
503
error = ex , class_name = _class_name , method_name = _method_name )
469
504
__log_and_exit (CommandLineArgUtil .PROG_ERROR_EXIT_CODE , _class_name , _method_name )
470
505
0 commit comments