Skip to content

Commit 4ac0077

Browse files
authored
Add WKO v4 support for WDT (#1218)
* Added schemas for domain v9 and cluster v1 * Read schema versions corresponding to WKO version * Avoid logging parsed JSON and YAML * Add WKO v4 schema support for modelHelp; use revised interface in unit tests * Pass exception to logger to display formatted stack trace in log * Add WKO v4 support to validateModel; refined wko_schema_helper API * Moved wko_schema_helper API code * Use alternate template to generate CRD file for WKO v4 * Refactored CRD folder API; renamed wko_schema_helper * Use correct exception type for extractResource * Corrections to WKO v4 CRD template * Rename crd_file_updater and use model CRD helper API; combine target file output; revise unit tests * Allow different object list keys for different model CRD folders * Corrected usages * Code cleanup, corrected copyrights * Allow createDomain, deployDomain, and updateDomain to skip validation of kubernetes section * Add comments to WKO v4 cluster CRD documents * Add WKO v4 target configurations for DII and PV * Create a results JSON file instead of a k8s secrets file * Replace stack trace in Java exceptions based on Jython exceptions/errors * Let tool_main handle unexpected exceptions in prepareModel * Add cluster server count information to result.json * Add domain UID to JSON results file; use helper methods throughout * Revised unit test to use results.json file instead of k8s_secrets.json
1 parent d049740 commit 4ac0077

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1153
-439
lines changed

core/src/main/java/oracle/weblogic/deploy/exception/PyBaseException.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. All rights reserved.
33
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
*/
55
package oracle.weblogic.deploy.exception;
66

7+
import java.io.PrintStream;
8+
import java.io.PrintWriter;
9+
710
/**
811
* The base class for our python-related exceptions.
912
*/
1013
public class PyBaseException extends BundleAwareException {
1114
private static final long serialVersionUID = 1L;
1215

16+
private String stackTrace;
17+
1318
/**
1419
* Constructs a default exception.
1520
*/
@@ -73,4 +78,28 @@ public PyBaseException(Throwable cause) {
7378
public String getBundleName() {
7479
return ExceptionHelper.getResourceBundleName();
7580
}
81+
82+
// for printing the stack trace with java.util.logging,
83+
// replace the Java stack trace with Jython traceback information.
84+
public void setStackTrace(String stackTrace) {
85+
this.stackTrace = stackTrace;
86+
}
87+
88+
@Override
89+
public void printStackTrace(PrintStream s) {
90+
if(stackTrace != null) {
91+
s.print(stackTrace);
92+
} else {
93+
super.printStackTrace(s);
94+
}
95+
}
96+
97+
@Override
98+
public void printStackTrace(PrintWriter s) {
99+
if(stackTrace != null) {
100+
s.print(stackTrace);
101+
} else {
102+
super.printStackTrace(s);
103+
}
104+
}
76105
}

core/src/main/python/create.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ def main(model_context):
310310

311311
try:
312312
aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.CREATE)
313-
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "create", __wlst_mode)
313+
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "create", __wlst_mode,
314+
validate_crd_sections=False)
314315

315316
archive_helper = None
316317
archive_file_name = model_context.get_archive_file_name()

core/src/main/python/deploy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ def main(model_context):
224224
try:
225225
aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.DEPLOY)
226226

227-
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "deploy", __wlst_mode)
227+
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "deploy", __wlst_mode,
228+
validate_crd_sections=False)
228229
model = Model(model_dictionary)
229230
_exit_code = __deploy(model, model_context, aliases)
230231
except DeployException, ex:

core/src/main/python/discover.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -473,18 +473,8 @@ def __check_and_customize_model(model, model_context, aliases, credential_inject
473473

474474
credential_cache = credential_injector.get_variable_cache()
475475

476-
# Generate k8s create secret script
477-
if target_configuration.generate_script_for_secrets():
478-
target_configuration_helper.generate_k8s_script(model_context, credential_cache, model.get_model(),
479-
ExceptionType.DISCOVER)
480-
481-
if target_configuration.generate_json_for_secrets():
482-
target_configuration_helper.generate_k8s_json(model_context, credential_cache, model.get_model())
483-
484-
# create additional output after filtering, but before variables have been inserted
485-
if model_context.is_targetted_config():
486-
target_configuration_helper.create_additional_output(model, model_context, aliases, credential_injector,
487-
ExceptionType.DISCOVER)
476+
target_configuration_helper.generate_all_output_files(model, aliases, credential_injector, model_context,
477+
ExceptionType.DISCOVER)
488478

489479
# if target handles credential configuration, clear property cache to keep out of variables file.
490480
if model_context.get_target_configuration().manages_credentials():
@@ -500,7 +490,7 @@ def __check_and_customize_model(model, model_context, aliases, credential_inject
500490
if inserted:
501491
model = Model(variable_model)
502492
try:
503-
validator = Validator(model_context, wlst_mode=__wlst_mode, aliases=aliases)
493+
validator = Validator(model_context, aliases, wlst_mode=__wlst_mode)
504494

505495
# no variables are generated by the discover tool
506496
validator.validate_in_tool_mode(model.get_model(), variables_file_name=variable_file_name,

core/src/main/python/extract_resource.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from wlsdeploy.aliases.aliases import Aliases
1515
from wlsdeploy.aliases.wlst_modes import WlstModes
1616
from wlsdeploy.exception import exception_helper
17+
from wlsdeploy.exception.expection_types import ExceptionType
1718
from wlsdeploy.logging.platform_logger import PlatformLogger
1819
from wlsdeploy.tool.extract.domain_resource_extractor import DomainResourceExtractor
1920
from wlsdeploy.tool.util import model_context_helper
@@ -121,7 +122,7 @@ def main(model_context):
121122
_exit_code = ExitCode.OK
122123

123124
try:
124-
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
125+
aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.DEPLOY)
125126
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "extract", __wlst_mode)
126127
model = Model(model_dictionary)
127128
_exit_code = __extract_resource(model, model_context, aliases)

core/src/main/python/model_help.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
CommandLineArgUtil.ATTRIBUTES_ONLY_SWITCH,
3434
CommandLineArgUtil.FOLDERS_ONLY_SWITCH,
3535
CommandLineArgUtil.RECURSIVE_SWITCH,
36-
CommandLineArgUtil.INTERACTIVE_MODE_SWITCH
36+
CommandLineArgUtil.INTERACTIVE_MODE_SWITCH,
37+
CommandLineArgUtil.TARGET_SWITCH
3738
]
3839

3940
__output_types = [
@@ -222,7 +223,7 @@ def interactive_help_prompt(model_path, input_file):
222223
sys.stdout.flush()
223224

224225
if not input_file:
225-
command_str = raw_input("") # get command from stdin
226+
command_str = raw_input("") # get command from stdin
226227

227228
else:
228229
# get command from file instead of stdin (undocumented feature)
@@ -243,7 +244,7 @@ def interactive_help_print_path(printer, model_path, history):
243244
"""
244245
Prints help for the given model_path, or an error message.
245246
Also updates the help history on success.
246-
:param model_path: the model path
247+
:param model_path: the model path
247248
:param history: history of successful model paths
248249
:param printer: a model help printer
249250
"""
@@ -364,7 +365,7 @@ def interactive_help_main_loop(aliases, model_path, printer):
364365
if command_str == 'exit':
365366
break
366367

367-
# the "process command" prints the help (or error) for the command_str
368+
# the "process command" prints the help (or error) for the command_str
368369
# plus appends a new path to the history if the str specifies a successful directory change
369370

370371
interactive_help_process_command(aliases, printer, history[-1], command_str, history)
@@ -376,7 +377,7 @@ def interactive_help_main_loop(aliases, model_path, printer):
376377

377378
__logger.exiting(class_name=_class_name, method_name=_method_name)
378379

379-
380+
380381
def print_help(model_path, model_context):
381382
"""
382383
Prints the folders and/or attributes for the specified given model_path,
@@ -401,7 +402,7 @@ def print_help(model_path, model_context):
401402
control_option = ControlOptions.FOLDERS_ONLY
402403

403404
aliases = Aliases(model_context)
404-
printer = ModelHelpPrinter(aliases, __logger)
405+
printer = ModelHelpPrinter(model_context, aliases, __logger)
405406

406407
if model_context.get_interactive_mode_option():
407408
interactive_help_main_loop(aliases, model_path, printer)

core/src/main/python/prepare_model.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
import sys
1111

12+
from oracle.weblogic.deploy.prepare import PrepareException
1213
from oracle.weblogic.deploy.util import CLAException
1314
from oracle.weblogic.deploy.util import PyWLSTException
1415

15-
from oracle.weblogic.deploy.prepare import PrepareException
1616
from wlsdeploy.logging.platform_logger import PlatformLogger
1717
from wlsdeploy.tool.prepare.model_preparer import ModelPreparer
1818
from wlsdeploy.util import target_configuration_helper
@@ -84,11 +84,6 @@ def main(model_context):
8484
_exit_code = ExitCode.ERROR
8585
__logger.severe('WLSDPLY-05801', ex.getLocalizedMessage(), error=ex, class_name=_class_name,
8686
method_name=_method_name)
87-
except Exception, ex:
88-
_exit_code = ExitCode.ERROR
89-
message = str(sys.exc_type) + ': ' + str(sys.exc_value)
90-
__logger.severe('WLSDPLY-05801', message, error=ex, class_name=_class_name,
91-
method_name=_method_name)
9287

9388
__logger.exiting(class_name=_class_name, method_name=_method_name, result=_exit_code)
9489
return _exit_code

core/src/main/python/update.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ def main(model_context):
272272

273273
try:
274274
aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.DEPLOY)
275-
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "update", __wlst_mode)
275+
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "update", __wlst_mode,
276+
validate_crd_sections=False)
276277
model = Model(model_dictionary)
277278
_exit_code = __update(model, model_context, aliases)
278279
except DeployException, ex:

core/src/main/python/validate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
CommandLineArgUtil.MODEL_FILE_SWITCH,
5252
CommandLineArgUtil.ARCHIVE_FILE_SWITCH,
5353
CommandLineArgUtil.VARIABLE_FILE_SWITCH,
54+
CommandLineArgUtil.TARGET_SWITCH,
5455
CommandLineArgUtil.TARGET_VERSION_SWITCH,
5556
CommandLineArgUtil.TARGET_MODE_SWITCH,
5657
CommandLineArgUtil.VALIDATION_METHOD
@@ -111,7 +112,7 @@ def __perform_model_file_validation(model_file_name, model_context):
111112
try:
112113
wlst_mode = model_context.get_target_wlst_mode()
113114
aliases = Aliases(model_context=model_context, wlst_mode=wlst_mode, exception_type=ExceptionType.VALIDATE)
114-
model_validator = Validator(model_context, aliases=aliases, logger=__logger)
115+
model_validator = Validator(model_context, aliases, logger=__logger)
115116
variable_map = model_validator.load_variables(model_context.get_variable_file())
116117
model_dictionary = cla_helper.merge_model_files(model_file_name, variable_map)
117118

core/src/main/python/wlsdeploy/exception/exception_helper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ def convert_error_to_exception():
449449
custom_exception = PyAttributeErrorException(exception_message)
450450
else:
451451
custom_exception = PyBaseException(exception_message)
452+
453+
custom_exception.setStackTrace(exception_message)
452454
return custom_exception
453455

454456

0 commit comments

Comments
 (0)