Skip to content

Commit 6f95c93

Browse files
authored
WIP: Merge model kubernetes section to template for extract tool (#1130)
* Merge model kubernetes section to template for extract tool * Use option -domain_home argument in output file content * Output template files correctly when deprecated -domain_resource_file argument is used * Convert model variables to correct types for domain resource file * Resolve problem with simple map elements * Use targets for extract resource test * Support deprecated "named object list" model format * Sonar cleanup * Update script help output * Updated copyrights
1 parent 408ed9d commit 6f95c93

File tree

8 files changed

+259
-349
lines changed

8 files changed

+259
-349
lines changed

core/src/main/python/extract_resource.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# imports from local packages start here
1616
from wlsdeploy.aliases.aliases import Aliases
1717
from wlsdeploy.aliases.wlst_modes import WlstModes
18+
from wlsdeploy.exception import exception_helper
1819
from wlsdeploy.logging.platform_logger import PlatformLogger
1920
from wlsdeploy.tool.extract.domain_resource_extractor import DomainResourceExtractor
2021
from wlsdeploy.tool.util import model_context_helper
@@ -33,21 +34,23 @@
3334
__wlst_mode = WlstModes.OFFLINE
3435

3536
__required_arguments = [
36-
CommandLineArgUtil.ORACLE_HOME_SWITCH,
37-
CommandLineArgUtil.DOMAIN_HOME_SWITCH,
38-
CommandLineArgUtil.DOMAIN_RESOURCE_FILE_SWITCH
37+
CommandLineArgUtil.ORACLE_HOME_SWITCH
3938
]
4039

4140
__optional_arguments = [
4241
# Used by shell script to locate WLST
4342
CommandLineArgUtil.DOMAIN_TYPE_SWITCH,
43+
CommandLineArgUtil.DOMAIN_HOME_SWITCH,
4444
CommandLineArgUtil.ARCHIVE_FILE_SWITCH,
4545
CommandLineArgUtil.MODEL_FILE_SWITCH,
46+
CommandLineArgUtil.TARGET_SWITCH,
4647
CommandLineArgUtil.VARIABLE_FILE_SWITCH,
4748
CommandLineArgUtil.USE_ENCRYPTION_SWITCH,
4849
CommandLineArgUtil.PASSPHRASE_SWITCH,
4950
CommandLineArgUtil.PASSPHRASE_FILE_SWITCH,
5051
CommandLineArgUtil.PASSPHRASE_ENV_SWITCH,
52+
CommandLineArgUtil.OUTPUT_DIR_SWITCH, # move to __required_arguments once DOMAIN_RESOURCE_FILE_SWITCH is removed
53+
CommandLineArgUtil.DOMAIN_RESOURCE_FILE_SWITCH # deprecated, only this program uses it
5154
]
5255

5356

@@ -57,6 +60,8 @@ def __process_args(args):
5760
:param args: the command-line arguments list
5861
:raises CLAException: if an error occurs while validating and processing the command-line arguments
5962
"""
63+
_method_name = '__process_args'
64+
6065
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
6166
cla_util.set_allow_multiple_models(True)
6267
argument_map = cla_util.process_args(args, TOOL_TYPE_EXTRACT)
@@ -70,19 +75,37 @@ def __process_args(args):
7075

7176
# allow unresolved tokens and archive entries
7277
argument_map[CommandLineArgUtil.VALIDATION_METHOD] = validate_configuration.LAX_METHOD
78+
79+
# if no target type was specified, use wko
80+
if CommandLineArgUtil.TARGET_SWITCH not in argument_map:
81+
argument_map[CommandLineArgUtil.TARGET_SWITCH] = 'wko'
82+
83+
# warn about deprecated -domain_resource_file argument.
84+
# not needed once -domain_resource_file is removed and -output_dir moves to __required_arguments.
85+
if CommandLineArgUtil.DOMAIN_RESOURCE_FILE_SWITCH in argument_map:
86+
__logger.warning('WLSDPLY-10040', CommandLineArgUtil.DOMAIN_RESOURCE_FILE_SWITCH,
87+
CommandLineArgUtil.OUTPUT_DIR_SWITCH, class_name=_class_name, method_name=_method_name)
88+
elif CommandLineArgUtil.OUTPUT_DIR_SWITCH not in argument_map:
89+
ex = exception_helper.create_cla_exception(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE, 'WLSDPLY-20005',
90+
_program_name, CommandLineArgUtil.OUTPUT_DIR_SWITCH,
91+
class_name=_class_name, method_name=_method_name)
92+
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
93+
raise ex
94+
7395
return model_context_helper.create_context(_program_name, argument_map)
7496

7597

76-
def __extract_resource(model, model_context):
98+
def __extract_resource(model, model_context, aliases):
7799
"""
78100
Offline deployment orchestration
79101
:param model: the model
80102
:param model_context: the model context
103+
:param aliases: the aliases object
81104
:raises: DeployException: if an error occurs
82105
"""
83106
_method_name = '__extract_resource'
84107

85-
resource_extractor = DomainResourceExtractor(model, model_context, __logger)
108+
resource_extractor = DomainResourceExtractor(model, model_context, aliases, __logger)
86109
resource_extractor.extract()
87110
return 0
88111

@@ -119,7 +142,7 @@ def main(args):
119142

120143
try:
121144
model = Model(model_dictionary)
122-
exit_code = __extract_resource(model, model_context)
145+
exit_code = __extract_resource(model, model_context, aliases)
123146
except DeployException, ex:
124147
__logger.severe('WLSDPLY-09015', _program_name, ex.getLocalizedMessage(), error=ex,
125148
class_name=_class_name, method_name=_method_name)

0 commit comments

Comments
 (0)