Skip to content

Add WKO v4 support for WDT #1218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
81169ce
Added schemas for domain v9 and cluster v1
rakillen Oct 10, 2022
763bd2a
Read schema versions corresponding to WKO version
rakillen Oct 10, 2022
d40da45
Avoid logging parsed JSON and YAML
rakillen Oct 11, 2022
402cfed
Add WKO v4 schema support for modelHelp; use revised interface in uni…
rakillen Oct 11, 2022
6768451
Pass exception to logger to display formatted stack trace in log
rakillen Oct 12, 2022
38c73bc
Add WKO v4 support to validateModel; refined wko_schema_helper API
rakillen Oct 12, 2022
9426e86
Moved wko_schema_helper API code
rakillen Oct 12, 2022
1080085
Use alternate template to generate CRD file for WKO v4
rakillen Oct 13, 2022
34d9d2e
Refactored CRD folder API; renamed wko_schema_helper
rakillen Oct 18, 2022
30316f8
Use correct exception type for extractResource
rakillen Oct 19, 2022
9060ce3
Corrections to WKO v4 CRD template
rakillen Oct 19, 2022
7eeb08e
Rename crd_file_updater and use model CRD helper API; combine target …
rakillen Oct 19, 2022
4e4addd
Allow different object list keys for different model CRD folders
rakillen Oct 19, 2022
8262883
Corrected usages
rakillen Oct 19, 2022
ca1aef9
Code cleanup, corrected copyrights
rakillen Oct 19, 2022
b5da4f7
Allow createDomain, deployDomain, and updateDomain to skip validation…
rakillen Oct 20, 2022
8886a15
Add comments to WKO v4 cluster CRD documents
rakillen Oct 20, 2022
63f4bbb
Add WKO v4 target configurations for DII and PV
rakillen Oct 20, 2022
fd01924
Create a results JSON file instead of a k8s secrets file
rakillen Oct 20, 2022
46bbab5
Replace stack trace in Java exceptions based on Jython exceptions/errors
rakillen Oct 21, 2022
c014082
Let tool_main handle unexpected exceptions in prepareModel
rakillen Oct 21, 2022
02fc056
Add cluster server count information to result.json
rakillen Oct 21, 2022
d1e2f35
Add domain UID to JSON results file; use helper methods throughout
rakillen Oct 21, 2022
02a4cb2
Revised unit test to use results.json file instead of k8s_secrets.json
rakillen Oct 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
/*
* Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
*/
package oracle.weblogic.deploy.exception;

import java.io.PrintStream;
import java.io.PrintWriter;

/**
* The base class for our python-related exceptions.
*/
public class PyBaseException extends BundleAwareException {
private static final long serialVersionUID = 1L;

private String stackTrace;

/**
* Constructs a default exception.
*/
Expand Down Expand Up @@ -73,4 +78,28 @@ public PyBaseException(Throwable cause) {
public String getBundleName() {
return ExceptionHelper.getResourceBundleName();
}

// for printing the stack trace with java.util.logging,
// replace the Java stack trace with Jython traceback information.
public void setStackTrace(String stackTrace) {
this.stackTrace = stackTrace;
}

@Override
public void printStackTrace(PrintStream s) {
if(stackTrace != null) {
s.print(stackTrace);
} else {
super.printStackTrace(s);
}
}

@Override
public void printStackTrace(PrintWriter s) {
if(stackTrace != null) {
s.print(stackTrace);
} else {
super.printStackTrace(s);
}
}
}
3 changes: 2 additions & 1 deletion core/src/main/python/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ def main(model_context):

try:
aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.CREATE)
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "create", __wlst_mode)
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "create", __wlst_mode,
validate_crd_sections=False)

archive_helper = None
archive_file_name = model_context.get_archive_file_name()
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/python/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ def main(model_context):
try:
aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.DEPLOY)

model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "deploy", __wlst_mode)
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "deploy", __wlst_mode,
validate_crd_sections=False)
model = Model(model_dictionary)
_exit_code = __deploy(model, model_context, aliases)
except DeployException, ex:
Expand Down
16 changes: 3 additions & 13 deletions core/src/main/python/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,8 @@ def __check_and_customize_model(model, model_context, aliases, credential_inject

credential_cache = credential_injector.get_variable_cache()

# Generate k8s create secret script
if target_configuration.generate_script_for_secrets():
target_configuration_helper.generate_k8s_script(model_context, credential_cache, model.get_model(),
ExceptionType.DISCOVER)

if target_configuration.generate_json_for_secrets():
target_configuration_helper.generate_k8s_json(model_context, credential_cache, model.get_model())

# create additional output after filtering, but before variables have been inserted
if model_context.is_targetted_config():
target_configuration_helper.create_additional_output(model, model_context, aliases, credential_injector,
ExceptionType.DISCOVER)
target_configuration_helper.generate_all_output_files(model, aliases, credential_injector, model_context,
ExceptionType.DISCOVER)

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

# no variables are generated by the discover tool
validator.validate_in_tool_mode(model.get_model(), variables_file_name=variable_file_name,
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/python/extract_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from wlsdeploy.aliases.aliases import Aliases
from wlsdeploy.aliases.wlst_modes import WlstModes
from wlsdeploy.exception import exception_helper
from wlsdeploy.exception.expection_types import ExceptionType
from wlsdeploy.logging.platform_logger import PlatformLogger
from wlsdeploy.tool.extract.domain_resource_extractor import DomainResourceExtractor
from wlsdeploy.tool.util import model_context_helper
Expand Down Expand Up @@ -121,7 +122,7 @@ def main(model_context):
_exit_code = ExitCode.OK

try:
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.DEPLOY)
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "extract", __wlst_mode)
model = Model(model_dictionary)
_exit_code = __extract_resource(model, model_context, aliases)
Expand Down
13 changes: 7 additions & 6 deletions core/src/main/python/model_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
CommandLineArgUtil.ATTRIBUTES_ONLY_SWITCH,
CommandLineArgUtil.FOLDERS_ONLY_SWITCH,
CommandLineArgUtil.RECURSIVE_SWITCH,
CommandLineArgUtil.INTERACTIVE_MODE_SWITCH
CommandLineArgUtil.INTERACTIVE_MODE_SWITCH,
CommandLineArgUtil.TARGET_SWITCH
]

__output_types = [
Expand Down Expand Up @@ -222,7 +223,7 @@ def interactive_help_prompt(model_path, input_file):
sys.stdout.flush()

if not input_file:
command_str = raw_input("") # get command from stdin
command_str = raw_input("") # get command from stdin

else:
# get command from file instead of stdin (undocumented feature)
Expand All @@ -243,7 +244,7 @@ def interactive_help_print_path(printer, model_path, history):
"""
Prints help for the given model_path, or an error message.
Also updates the help history on success.
:param model_path: the model path
:param model_path: the model path
:param history: history of successful model paths
:param printer: a model help printer
"""
Expand Down Expand Up @@ -364,7 +365,7 @@ def interactive_help_main_loop(aliases, model_path, printer):
if command_str == 'exit':
break

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

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

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


def print_help(model_path, model_context):
"""
Prints the folders and/or attributes for the specified given model_path,
Expand All @@ -401,7 +402,7 @@ def print_help(model_path, model_context):
control_option = ControlOptions.FOLDERS_ONLY

aliases = Aliases(model_context)
printer = ModelHelpPrinter(aliases, __logger)
printer = ModelHelpPrinter(model_context, aliases, __logger)

if model_context.get_interactive_mode_option():
interactive_help_main_loop(aliases, model_path, printer)
Expand Down
7 changes: 1 addition & 6 deletions core/src/main/python/prepare_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import sys

from oracle.weblogic.deploy.prepare import PrepareException
from oracle.weblogic.deploy.util import CLAException
from oracle.weblogic.deploy.util import PyWLSTException

from oracle.weblogic.deploy.prepare import PrepareException
from wlsdeploy.logging.platform_logger import PlatformLogger
from wlsdeploy.tool.prepare.model_preparer import ModelPreparer
from wlsdeploy.util import target_configuration_helper
Expand Down Expand Up @@ -84,11 +84,6 @@ def main(model_context):
_exit_code = ExitCode.ERROR
__logger.severe('WLSDPLY-05801', ex.getLocalizedMessage(), error=ex, class_name=_class_name,
method_name=_method_name)
except Exception, ex:
_exit_code = ExitCode.ERROR
message = str(sys.exc_type) + ': ' + str(sys.exc_value)
__logger.severe('WLSDPLY-05801', message, error=ex, class_name=_class_name,
method_name=_method_name)

__logger.exiting(class_name=_class_name, method_name=_method_name, result=_exit_code)
return _exit_code
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/python/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ def main(model_context):

try:
aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.DEPLOY)
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "update", __wlst_mode)
model_dictionary = cla_helper.load_model(_program_name, model_context, aliases, "update", __wlst_mode,
validate_crd_sections=False)
model = Model(model_dictionary)
_exit_code = __update(model, model_context, aliases)
except DeployException, ex:
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/python/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
CommandLineArgUtil.MODEL_FILE_SWITCH,
CommandLineArgUtil.ARCHIVE_FILE_SWITCH,
CommandLineArgUtil.VARIABLE_FILE_SWITCH,
CommandLineArgUtil.TARGET_SWITCH,
CommandLineArgUtil.TARGET_VERSION_SWITCH,
CommandLineArgUtil.TARGET_MODE_SWITCH,
CommandLineArgUtil.VALIDATION_METHOD
Expand Down Expand Up @@ -111,7 +112,7 @@ def __perform_model_file_validation(model_file_name, model_context):
try:
wlst_mode = model_context.get_target_wlst_mode()
aliases = Aliases(model_context=model_context, wlst_mode=wlst_mode, exception_type=ExceptionType.VALIDATE)
model_validator = Validator(model_context, aliases=aliases, logger=__logger)
model_validator = Validator(model_context, aliases, logger=__logger)
variable_map = model_validator.load_variables(model_context.get_variable_file())
model_dictionary = cla_helper.merge_model_files(model_file_name, variable_map)

Expand Down
2 changes: 2 additions & 0 deletions core/src/main/python/wlsdeploy/exception/exception_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ def convert_error_to_exception():
custom_exception = PyAttributeErrorException(exception_message)
else:
custom_exception = PyBaseException(exception_message)

custom_exception.setStackTrace(exception_message)
return custom_exception


Expand Down
2 changes: 1 addition & 1 deletion core/src/main/python/wlsdeploy/json/json_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def parse(self):
self._logger.entering(class_name=self._class_name, method_name=_method_name)
# throws JsonException with details, nothing we can really add here...
result_dict = self._translator.parse()
self._logger.exiting(class_name=self._class_name, method_name=_method_name, result=result_dict)
self._logger.exiting(class_name=self._class_name, method_name=_method_name)
return result_dict


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

from wlsdeploy.exception.expection_types import ExceptionType
from wlsdeploy.tool.util.credential_injector import CredentialInjector
from wlsdeploy.tool.util.targets.output_file_helper import DOMAIN_HOME
from wlsdeploy.tool.util.targets.output_file_helper import SPEC
from wlsdeploy.util import target_configuration_helper
from wlsdeploy.tool.util.targets import additional_output_helper

_secret_pattern = re.compile("^@@SECRET:(.*)@@$")

Expand All @@ -33,16 +31,13 @@ def extract(self):
credential_injector = CredentialInjector(DomainResourceExtractor, model_dict, self._model_context)
_add_secrets(model_dict, credential_injector)

# if -domain_home was specified on the command line, it should override any value in the model
domain_home_override = self._model_context.get_domain_home()
if domain_home_override:
kubernetes_dict = self._model.get_model_kubernetes()
spec_dict = get_or_create_dictionary(kubernetes_dict, SPEC)
spec_dict[DOMAIN_HOME] = domain_home_override
# if -domain_home was specified on the extract command line, it should override any value in the model
domain_home = self._model_context.get_domain_home()

# create the output files with information from the model
target_configuration_helper.create_additional_output(self._model, self._model_context, self._aliases,
credential_injector, ExceptionType.DEPLOY)
additional_output_helper.create_additional_output(
self._model, self._model_context, self._aliases, credential_injector, ExceptionType.DEPLOY,
domain_home_override=domain_home)


def _add_secrets(folder, credential_injector):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ class ModelHelpPrinter(object):
Class for printing the recognized model metadata to STDOUT.
"""

def __init__(self, aliases, logger):
def __init__(self, model_context, aliases, logger):
"""
:param model_context: The model context
:param aliases: A reference to an Aliases class instance
:param logger: A reference to the platform logger to write to, if a log entry needs to be made
"""
self._logger = logger
self._aliases = aliases
self._model_context = model_context

def print_model_help(self, model_path, control_option):
"""
Expand Down Expand Up @@ -66,7 +68,7 @@ def print_model_help(self, model_path, control_option):
print(_format_message('WLSDPLY-10105', model_path))

if model_path_tokens[0] == KUBERNETES:
sample_printer = ModelKubernetesPrinter()
sample_printer = ModelKubernetesPrinter(self._model_context)
sample_printer.print_model_sample(model_path_tokens, control_option)
else:
sample_printer = ModelSamplePrinter(self._aliases, self._logger)
Expand Down
Loading