Skip to content

Commit 5f63738

Browse files
committed
Issue#27 - Add filter capability for create
1 parent bf27c98 commit 5f63738

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

core/src/main/python/create.py

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from wlsdeploy.logging.platform_logger import PlatformLogger
3333
from wlsdeploy.tool.create.domain_creator import DomainCreator
3434
from wlsdeploy.tool.create.domain_typedef import DomainTypedef
35+
from wlsdeploy.tool.util import filter_helper
3536
from wlsdeploy.tool.validate.validator import Validator
3637
from wlsdeploy.util import getcreds
3738
from wlsdeploy.util import variables
@@ -66,6 +67,7 @@
6667
CommandLineArgUtil.PASSPHRASE_SWITCH
6768
]
6869

70+
6971
def __process_args(args):
7072
"""
7173
Process the command-line arguments and prompt the user for any missing information
@@ -95,6 +97,7 @@ def __process_args(args):
9597
domain_typedef.set_model_context(model_context)
9698
return model_context
9799

100+
98101
def __verify_required_args_present(required_arg_map):
99102
"""
100103
Verify that the required args are present.
@@ -111,6 +114,7 @@ def __verify_required_args_present(required_arg_map):
111114
raise ex
112115
return
113116

117+
114118
def __process_java_home_arg(optional_arg_map):
115119
"""
116120
Verify that java_home is set. If not, set it.
@@ -132,6 +136,7 @@ def __process_java_home_arg(optional_arg_map):
132136
optional_arg_map[CommandLineArgUtil.JAVA_HOME_SWITCH] = java_home.getAbsolutePath()
133137
return
134138

139+
135140
def __process_model_args(optional_arg_map):
136141
"""
137142
Verify that either the model_file or archive_file was provided and exists.
@@ -176,6 +181,7 @@ def __process_model_args(optional_arg_map):
176181
raise ex
177182
return
178183

184+
179185
def __process_rcu_args(optional_arg_map, domain_type, domain_typedef):
180186
"""
181187
Determine if the RCU is needed and validate/prompt for any missing information
@@ -234,6 +240,7 @@ def __process_rcu_args(optional_arg_map, domain_type, domain_typedef):
234240
raise ex
235241
return
236242

243+
237244
def __process_encryption_args(optional_arg_map):
238245
"""
239246
Determine if the user is using our encryption and if so, get the passphrase.
@@ -255,6 +262,7 @@ def __process_encryption_args(optional_arg_map):
255262
optional_arg_map[CommandLineArgUtil.PASSPHRASE_SWITCH] = String(passphrase)
256263
return
257264

265+
258266
def __clean_up_temp_files():
259267
"""
260268
If a temporary directory was created to extract the model from the archive, delete the directory and its contents.
@@ -265,6 +273,30 @@ def __clean_up_temp_files():
265273
FileUtils.deleteDirectory(__tmp_model_dir)
266274
__tmp_model_dir = None
267275

276+
277+
def validate_model(model_dictionary, model_context, aliases):
278+
_method_name = 'validate_model'
279+
280+
try:
281+
validator = Validator(model_context, aliases, wlst_mode=__wlst_mode)
282+
283+
# Since the have already performed all variable substitution,
284+
# no need to pass the variable file for processing.
285+
#
286+
return_code = validator.validate_in_tool_mode(model_dictionary, variables_file_name=None,
287+
archive_file_name=model_context.get_archive_file_name())
288+
except ValidateException, ex:
289+
__logger.severe('WLSDPLY-20000', _program_name, ex.getLocalizedMessage(), error=ex,
290+
class_name=_class_name, method_name=_method_name)
291+
__clean_up_temp_files()
292+
sys.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
293+
294+
if return_code == Validator.ReturnCode.STOP:
295+
__logger.severe('WLSDPLY-20001', _program_name, class_name=_class_name, method_name=_method_name)
296+
__clean_up_temp_files()
297+
sys.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
298+
299+
268300
def main():
269301
"""
270302
The entry point for the create domain tool.
@@ -306,26 +338,12 @@ def main():
306338
__clean_up_temp_files()
307339
sys.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
308340

309-
try:
310-
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
311-
validator = Validator(model_context, aliases, wlst_mode=__wlst_mode)
312-
313-
# Since the have already performed all variable substitution,
314-
# no need to pass the variable file for processing.
315-
#
316-
return_code = validator.validate_in_tool_mode(model,
317-
variables_file_name=None,
318-
archive_file_name=model_context.get_archive_file_name())
319-
except ValidateException, ex:
320-
__logger.severe('WLSDPLY-20000', _program_name, ex.getLocalizedMessage(), error=ex,
321-
class_name=_class_name, method_name=_method_name)
322-
__clean_up_temp_files()
323-
sys.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
341+
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
342+
validate_model(model, model_context, aliases)
324343

325-
if return_code == Validator.ReturnCode.STOP:
326-
__logger.severe('WLSDPLY-20001', _program_name, class_name=_class_name, method_name=_method_name)
327-
__clean_up_temp_files()
328-
sys.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE)
344+
if filter_helper.apply_filters(model, "create"):
345+
# if any filters were applied, re-validate the model
346+
validate_model(model, model_context, aliases)
329347

330348
try:
331349
creator = DomainCreator(model, model_context, aliases)

0 commit comments

Comments
 (0)