Skip to content

Commit 76e48ec

Browse files
rakillenJohnny Shum
andauthored
Add target option for Verrazzano to WDT (#659)
* Enable new target v8o with filter; refactored shared code; removed unused methods * Move k8s operator filter into target directory; remove explicit copy * Updated scripts to reflect additional options for -target * Revisions to scripts * Allow additional output types to be specified in the target configuration; fixed logger errors * Fixed comment typo * JIRA WDT-426 Build resource config files from templates, perform simple substitutions; improve exception handling * JIRA WDT-426 Break out substitution module; use substitution blocks for databases, clusters * JIRA WDT-426 Renaming to use vz throughout * JIRA WDT-426 Revised model and binding templates * JIRA WDT-426 Match secret name to script; use aliases for name resolution * JIRA WDT-426 Use domain UID consistently in VZ config and secrets script * JIRA WDT-426 Use a secret for AdminUserName, use DOMAIN_UID environment variable consistently * JIRA WDT-426 Define secret model tokens and references consistently * JIRA WDT-426 Use JDBC secret name for vz config; refactor format_variable_name() into variable_injector_functions.py * JIRA WDT-426 Create additional output in discover before variables have been inserted * JIRA WDT-426 Use shared method to calculate server count for clusters * JIRA WDT-426 Remove unused method * JIRA WDT-426 Check credential secret flag before updating model; fixed problem with prepareModel properties * JIRA WDT-426 Revise secrets scripts to support paired secrets; added comments * JIRA WDT-426 Use object for target configuration * JIRA WDT-426 Just create secrets in prepareModel; corrected admin secret name * JIRA WDT-426 Changed name to target configuration throughout * JIRA WDT-426 Check before creating secrets script; add config_override_secrets flag * JIRA WDT-426 Use ".password" for paired secret password fields * JIRA WDT-426 Fixed problem when no target * JIRA WDT-426 Use password placeholder in model for config_override_secrets * JIRA WDT-426 Added comments, changed parameter name, for __check_and_customize_model() * JIRA WDT-426 Corrected method name * JIRA WDT-426 Use credentials_method property to determine handling * JIRA WDT-426 Leave credential fields unchanged if credential method not specified * JIRA WDT-426 Change admin user and password secret names to 'username' and 'password' * JIRA WDT-426 Leave credential fields unchanged if credential method not specified * add vz required fields for models update component name in binding file update discovery where url may have '&' and needs to be encoded back * change default logHome location * update logHome location and remove default channel ports * JIRA WDT-426 Don't XML encode JDBC URL * JIRA WDT-426 Use "password" key for all secrets, improve script comments * JIRA WDT-426 Use "credentials_method" in doc and comments * JIRA WDT-426 Remove "replicas" from binding model Co-authored-by: Johnny Shum <cbdream99@gmail.com>
1 parent 846b968 commit 76e48ec

28 files changed

+1138
-400
lines changed

core/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
<includes>
8686
<include>oracle/**/*.json</include>
8787
<include>oracle/**/*.properties</include>
88+
<include>oracle/**/*.yaml</include>
8889
</includes>
8990
<filtering>false</filtering>
9091
</resource>

core/src/main/python/discover.py

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55
The entry point for the discoverDomain tool.
@@ -44,7 +44,6 @@
4444
from wlsdeploy.tool.util.wlst_helper import WlstHelper
4545
from wlsdeploy.tool.validate.validator import Validator
4646
from wlsdeploy.util import cla_helper
47-
from wlsdeploy.util import dictionary_utils
4847
from wlsdeploy.util import model_translator
4948
from wlsdeploy.util import path_utils
5049
from wlsdeploy.util import tool_exit
@@ -93,30 +92,13 @@ def __process_args(args):
9392
argument_map = cla_util.process_args(args)
9493

9594
__wlst_mode = cla_helper.process_online_args(argument_map)
96-
__process_target_arg(argument_map)
95+
target_configuration_helper.process_target_arguments(argument_map)
9796
__process_archive_filename_arg(argument_map)
9897
__process_variable_filename_arg(argument_map)
9998
__process_java_home(argument_map)
10099

101100
return model_context_helper.create_context(_program_name, argument_map)
102101

103-
def __process_target_arg(optional_arg_map):
104-
105-
_method_name = '__process_target_arg'
106-
107-
if CommandLineArgUtil.TARGET_SWITCH in optional_arg_map:
108-
# if -target is specified -output_dir is required
109-
output_dir = dictionary_utils.get_element(optional_arg_map, CommandLineArgUtil.OUTPUT_DIR_SWITCH)
110-
if (output_dir is None) or (not os.path.isdir(output_dir)):
111-
ex = exception_helper.create_cla_exception('WLSDPLY-01642', output_dir)
112-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
113-
raise ex
114-
115-
# Set the -variable_file parameter if not present with default
116-
117-
if CommandLineArgUtil.VARIABLE_FILE_SWITCH not in optional_arg_map:
118-
optional_arg_map[CommandLineArgUtil.VARIABLE_FILE_SWITCH] = os.path.join(output_dir,
119-
"k8s_variable.properties")
120102

121103
def __process_archive_filename_arg(required_arg_map):
122104
"""
@@ -409,11 +391,14 @@ def __persist_model(model, model_context):
409391
return
410392

411393

412-
def __check_and_customize_model(model, model_context, aliases, injector):
394+
def __check_and_customize_model(model, model_context, aliases, password_injector):
413395
"""
414396
Customize the model dictionary before persisting. Validate the model after customization for informational
415397
purposes. Any validation errors will not stop the discovered model to be persisted.
416-
:param model: completely discovered model
398+
:param model: completely discovered model, before any tokenization
399+
:param model_context: configuration from command-line
400+
:param aliases: used for validation if model changes are made
401+
:param password_injector: injector created to collect and tokenize passwords, possibly None
417402
"""
418403
_method_name = '__check_and_customize_model'
419404
__logger.entering(class_name=_class_name, method_name=_method_name)
@@ -422,20 +407,24 @@ def __check_and_customize_model(model, model_context, aliases, injector):
422407
__logger.info('WLSDPLY-06014', _class_name=_class_name, method_name=_method_name)
423408

424409
cache = None
425-
if injector is not None:
426-
cache = injector.get_variable_cache()
427-
# Generate k8s create secret script, after that clear the dictionary to avoid showing up in the variable file
410+
if password_injector is not None:
411+
cache = password_injector.get_variable_cache()
412+
413+
# Generate k8s create secret script, possibly using lax validation method
428414
if model_context.is_targetted_config():
429-
validation_method = model_context.get_target_configuration()['validation_method']
415+
validation_method = model_context.get_target_configuration().get_validation_method()
430416
model_context.set_validation_method(validation_method)
431-
target_configuration_helper.generate_k8s_script(model_context.get_kubernetes_variable_file(), cache)
432-
cache.clear()
417+
target_configuration_helper.generate_k8s_script(model_context, cache, model.get_model())
433418

419+
# if target handles password substitution, clear property cache to keep out of variables file.
420+
if model_context.get_target_configuration().manages_credentials():
421+
cache.clear()
422+
423+
# Apply the injectors specified in model_variable_injector.json, or in the target configuration
434424
variable_injector = VariableInjector(_program_name, model.get_model(), model_context,
435-
WebLogicHelper(__logger).get_actual_weblogic_version(), cache)
425+
WebLogicHelper(__logger).get_actual_weblogic_version(), cache)
436426

437-
inserted, variable_model, variable_file_name = \
438-
variable_injector.inject_variables_keyword_file()
427+
inserted, variable_model, variable_file_name = variable_injector.inject_variables_keyword_file()
439428

440429
if inserted:
441430
model = Model(variable_model)
@@ -509,16 +498,22 @@ def main(args):
509498
__logger.info('WLSDPLY-06025', class_name=_class_name, method_name=_method_name)
510499
else:
511500
__logger.info('WLSDPLY-06024', class_name=_class_name, method_name=_method_name)
501+
512502
try:
513503
model = __discover(model_context, aliases, discover_injector, helper)
504+
505+
if model_context.is_targetted_config():
506+
# do this before variables have been inserted into model
507+
target_configuration_helper.create_additional_output(model, model_context, aliases, ExceptionType.DISCOVER)
508+
509+
model = __check_and_customize_model(model, model_context, aliases, discover_injector)
510+
514511
except DiscoverException, ex:
515512
__logger.severe('WLSDPLY-06011', _program_name, model_context.get_domain_name(),
516513
model_context.get_domain_home(), ex.getLocalizedMessage(),
517514
error=ex, class_name=_class_name, method_name=_method_name)
518515
__log_and_exit(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE, _class_name, _method_name)
519516

520-
model = __check_and_customize_model(model, model_context, aliases, discover_injector)
521-
522517
try:
523518
__persist_model(model, model_context)
524519

0 commit comments

Comments
 (0)