Skip to content

removing deprecated -domain_resource_file argument #1341

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 2 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 2 additions & 15 deletions core/src/main/python/extract_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

__required_arguments = [
CommandLineArgUtil.MODEL_FILE_SWITCH,
CommandLineArgUtil.ORACLE_HOME_SWITCH
CommandLineArgUtil.ORACLE_HOME_SWITCH,
CommandLineArgUtil.OUTPUT_DIR_SWITCH
]

__optional_arguments = [
Expand All @@ -49,8 +50,6 @@
CommandLineArgUtil.PASSPHRASE_SWITCH,
CommandLineArgUtil.PASSPHRASE_FILE_SWITCH,
CommandLineArgUtil.PASSPHRASE_ENV_SWITCH,
CommandLineArgUtil.OUTPUT_DIR_SWITCH, # move to __required_arguments once DOMAIN_RESOURCE_FILE_SWITCH is removed
CommandLineArgUtil.DOMAIN_RESOURCE_FILE_SWITCH # deprecated, only this program uses it
]


Expand Down Expand Up @@ -80,18 +79,6 @@ def __process_args(args):
# allow unresolved tokens and archive entries
argument_map[CommandLineArgUtil.VALIDATION_METHOD] = validate_configuration.LAX_METHOD

# warn about deprecated -domain_resource_file argument.
# not needed once -domain_resource_file is removed and -output_dir moves to __required_arguments.
if CommandLineArgUtil.DOMAIN_RESOURCE_FILE_SWITCH in argument_map:
__logger.warning('WLSDPLY-10040', CommandLineArgUtil.DOMAIN_RESOURCE_FILE_SWITCH,
CommandLineArgUtil.OUTPUT_DIR_SWITCH, class_name=_class_name, method_name=_method_name)
elif CommandLineArgUtil.OUTPUT_DIR_SWITCH not in argument_map:
ex = exception_helper.create_cla_exception(ExitCode.USAGE_ERROR, 'WLSDPLY-20005',
_program_name, CommandLineArgUtil.OUTPUT_DIR_SWITCH,
class_name=_class_name, method_name=_method_name)
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
raise ex

return model_context_helper.create_context(_program_name, argument_map)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,38 +90,14 @@ def create_additional_output(model, model_context, aliases, credential_injector,
template_hash = _build_template_hash(model, model_context, aliases, credential_injector, domain_home_override)
for index, template_name in enumerate(template_names):
source_file_name = _get_template_source_name(template_name, target_configuration)

# special processing for deprecated -domain_resource_file argument of extractDomainResource
extract_output_file = _get_extract_output_file(template_name, index, model_context)
if extract_output_file:
output_file = extract_output_file
else:
output_file = File(os.path.join(output_dir, template_name))
output_file = File(os.path.join(output_dir, template_name))

_create_file(source_file_name, template_hash, output_file, exception_type)

crd_helper = model_crd_helper.get_helper(model_context)
crd_file_updater.update_from_model(output_file, model, crd_helper)


# *** DELETE METHOD WHEN deprecated -domain_resource_file IS REMOVED ***
def _get_extract_output_file(template_name, index, model_context):
"""
Special processing for deprecated -domain_resource_file argument used by extractDomainResource.
Use the directory of -domain_resource_file for all templates,
and the name of -domain_resource_file for the first (usually only) template.
"""
_method_name = '_get_extract_output_file'

resource_file = model_context.get_domain_resource_file()
if resource_file:
output_dir, output_name = os.path.split(resource_file)
if index > 0:
output_name = template_name
return File(os.path.join(output_dir, output_name))
return None


def _create_file(template_name, template_hash, output_file, exception_type):
"""
Read the template from the resource stream, perform any substitutions,
Expand Down
21 changes: 0 additions & 21 deletions core/src/main/python/wlsdeploy/util/cla_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ class CommandLineArgUtil(object):
VARIABLE_INJECTOR_FILE_SWITCH = '-variable_injector_file'
VARIABLE_KEYWORDS_FILE_SWITCH = '-variable_keywords_file'
VARIABLE_PROPERTIES_FILE_SWITCH = '-variable_properties_file'
# extractDomainResource output file
DOMAIN_RESOURCE_FILE_SWITCH = '-domain_resource_file'
OUTPUT_DIR_SWITCH = "-output_dir"
WAIT_FOR_EDIT_LOCK_SWITCH = "-wait_for_edit_lock"
TARGET_SWITCH = '-target'
Expand Down Expand Up @@ -324,10 +322,6 @@ def process_args(self, args, tool_type=TOOL_TYPE_DEFAULT, trailing_arg_count=0):
value, idx = self._get_arg_value(args, idx)
full_path = self._validate_variable_properties_file_arg(value)
self._add_arg(key, full_path, True)
elif self.is_domain_resource_file_key(key):
value, idx = self._get_arg_value(args, idx)
full_path = self._validate_domain_resource_file_arg(value)
self._add_arg(key, full_path, True)
elif self.is_boolean_switch(key):
self._add_arg(key, True)
elif self.is_compare_model_output_dir_switch(key):
Expand Down Expand Up @@ -1022,21 +1016,6 @@ def _validate_variable_properties_file_arg(self, value):
raise ex
return variables.getAbsolutePath()

def is_domain_resource_file_key(self, key):
return self.DOMAIN_RESOURCE_FILE_SWITCH == key

def _validate_domain_resource_file_arg(self, value):
method_name = '_validate_domain_resource_file_arg'

try:
variables = JFileUtils.validateFileName(value)
except JIllegalArgumentException, iae:
ex = create_cla_exception(ExitCode.ARG_VALIDATION_ERROR,
'WLSDPLY-01637', value, iae.getLocalizedMessage(), error=iae)
_logger.throwing(ex, class_name=self._class_name, method_name=method_name)
raise ex
return variables.getAbsolutePath()

def is_boolean_switch(self, key):
return key in self.BOOLEAN_SWITCHES

Expand Down
13 changes: 0 additions & 13 deletions core/src/main/python/wlsdeploy/util/model_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def __init__(self, program_name, arg_map):
self._validation_method = None
self._validate_configuration = None # lazy load
self._cancel_changes_if_restart_required = None
self._domain_resource_file = None
self._output_dir = None
self._target = None
self._target_configuration = None # lazy load
Expand Down Expand Up @@ -236,9 +235,6 @@ def __copy_from_args(self, arg_map):
if CommandLineArgUtil.TARGET_VERSION_SWITCH in arg_map:
self._wl_version = arg_map[CommandLineArgUtil.TARGET_VERSION_SWITCH]

if CommandLineArgUtil.DOMAIN_RESOURCE_FILE_SWITCH in arg_map:
self._domain_resource_file = arg_map[CommandLineArgUtil.DOMAIN_RESOURCE_FILE_SWITCH]

if CommandLineArgUtil.TRAILING_ARGS_SWITCH in arg_map:
self._trailing_args = arg_map[CommandLineArgUtil.TRAILING_ARGS_SWITCH]

Expand Down Expand Up @@ -343,8 +339,6 @@ def __copy__(self):
arg_map[CommandLineArgUtil.VALIDATION_METHOD] = self._validation_method
if self._wl_version is not None:
arg_map[CommandLineArgUtil.TARGET_VERSION_SWITCH] = self._wl_version
if self._domain_resource_file is not None:
arg_map[CommandLineArgUtil.DOMAIN_RESOURCE_FILE_SWITCH] = self._domain_resource_file
if self._trailing_args is not None:
arg_map[CommandLineArgUtil.TRAILING_ARGS_SWITCH] = self._trailing_args
if self._target is not None:
Expand Down Expand Up @@ -442,13 +436,6 @@ def get_domain_typedef(self):
"""
return self._domain_typedef

def get_domain_resource_file(self):
"""
Get the domain resource file.
:return: the domain resource file
"""
return self._domain_resource_file

def get_admin_url(self):
"""
Get the admin URL.
Expand Down
4 changes: 2 additions & 2 deletions core/src/test/python/wlsdeploy/tool/extract/extract_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,10 @@ def _extract_domain_resource(self, suffix):
model_dict = translator.parse()
model = Model(model_dict)

resource_file = os.path.join(self.EXTRACT_OUTPUT_DIR, 'domain-resource-' + suffix + '.yaml')
args_map = {
'-domain_home': '/u01/domain',
'-oracle_home': '/oracle',
'-domain_resource_file': resource_file,
'-output_dir': self.EXTRACT_OUTPUT_DIR,
'-target': 'wko'
}
model_context = ModelContext('ExtractTest', args_map)
Expand All @@ -143,5 +142,6 @@ def _extract_domain_resource(self, suffix):
extractor = DomainResourceExtractor(model, model_context, aliases, self.__logger)
extractor.extract()

resource_file = os.path.join(self.EXTRACT_OUTPUT_DIR, 'wko-domain.yaml')
translator = FileToPython(resource_file, use_ordering=True)
return translator.parse()