Skip to content

Commit b07e4ab

Browse files
committed
Discover overwrite existing archive and variable files
1 parent d33fbc2 commit b07e4ab

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

core/src/main/python/discover.py

+25-12
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,20 @@ def __process_archive_filename_arg(argument_map):
169169
else:
170170
archive_file_name = argument_map[CommandLineArgUtil.ARCHIVE_FILE_SWITCH]
171171
archive_dir_name = path_utils.get_parent_directory(archive_file_name)
172-
if os.path.exists(archive_dir_name) is False:
172+
if not os.path.exists(archive_dir_name):
173173
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR,
174174
'WLSDPLY-06026', archive_file_name)
175175
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
176176
raise ex
177+
178+
# Delete any existing archive file for discoverDomain so that we always start with a fresh zip file.
179+
archive_file_obj = FileUtils.getCanonicalFile(archive_file_name)
180+
if archive_file_obj.exists() and not archive_file_obj.delete():
181+
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR,'WLSDPLY-06047',
182+
_program_name, archive_file_name)
183+
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
184+
raise ex
185+
177186
try:
178187
archive_file = WLSDeployArchive(archive_file_name)
179188
except (IllegalArgumentException, IllegalStateException), ie:
@@ -187,23 +196,27 @@ def __process_archive_filename_arg(argument_map):
187196

188197
def __process_variable_filename_arg(optional_arg_map):
189198
"""
190-
If the variable filename argument is present, the required model variable injector json file must exist in
191-
the WLSDEPLOY lib directory.
199+
Validate the variable filename argument if present.
192200
:param optional_arg_map: containing the variable file name
193-
:raises: CLAException: if this argument is present but the model variable injector json does not exist
201+
:raises: CLAException: if this argument is present but fails validation
194202
"""
195203
_method_name = '__process_variable_filename_arg'
196204

197205
if CommandLineArgUtil.VARIABLE_FILE_SWITCH in optional_arg_map:
198-
variable_injector_file_name = optional_arg_map[CommandLineArgUtil.VARIABLE_FILE_SWITCH]
199-
try:
200-
FileUtils.validateWritableFile(variable_injector_file_name)
201-
except IllegalArgumentException, ie:
206+
variable_file_name = optional_arg_map[CommandLineArgUtil.VARIABLE_FILE_SWITCH]
207+
variable_dir_name = path_utils.get_parent_directory(variable_file_name)
208+
209+
if not os.path.exists(variable_dir_name):
202210
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR,
203-
'WLSDPLY-06021',
204-
optional_arg_map[CommandLineArgUtil.VARIABLE_FILE_SWITCH],
205-
variable_injector_file_name,
206-
ie.getLocalizedMessage(), error=ie)
211+
'WLSDPLY-06048', variable_file_name)
212+
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
213+
raise ex
214+
215+
# Delete any existing variable file for discoverDomain so that we always start with a fresh file.
216+
variable_file_obj = FileUtils.getCanonicalFile(variable_file_name)
217+
if variable_file_obj.exists() and not variable_file_obj.delete():
218+
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR,'WLSDPLY-06049',
219+
_program_name, variable_file_name)
207220
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
208221
raise ex
209222

core/src/main/python/wlsdeploy/util/path_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def get_parent_directory(path):
5757
"""
5858
result = path
5959
if path is not None:
60-
result = JFile(path).getParentFile().getCanonicalPath()
60+
result = JFile(path).getCanonicalFile().getParentFile().getCanonicalPath()
6161
return result
6262

6363

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

+4-2
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,7 @@ WLSDPLY-06017=Failed to read the WebLogic administrator username input from the
700700
WLSDPLY-06018=Please enter the WebLogic administrator password
701701
WLSDPLY-06019=Failed to read the WebLogic administrator password input from the user: {0}
702702
WLSDPLY-06020=Unable to get the domain name from the connected domain: {0}
703-
WLSDPLY-06021=The variables file command line argument {0} was used but the model variables injector file \
704-
{1} does not exist: {2}
703+
WLSDPLY-06021=<EMPTY>
705704
WLSDPLY-06022=Discover domain {0}
706705
WLSDPLY-06023=No domain name found in the domain configuration
707706
WLSDPLY-06024=No variable file provided. Model passwords will contain the token '-- FIX ME --'
@@ -735,6 +734,9 @@ WLSDPLY-06045=The -remote parameter was used to update the domain. \
735734
WLSDPLY-06046=The -remote parameter was used to deploy to the domain. \
736735
The -archive_file contains paths that will not be updated on the remote system. \
737736
Please manually extract the files to the remote machine.
737+
WLSDPLY-06047={0} failed to delete the existing archive file {1}
738+
WLSDPLY-06048=Target directory for variable file argument {0} does not exist
739+
WLSDPLY-06049={0} failed to delete the existing variable file {1}
738740

739741
# discoverer.py
740742
WLSDPLY-06100=Find attributes at location {0}

documentation/4.0/content/release-notes/_index.md

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ pre = "<b> </b>"
4343
- #1599 - Added support for the 12.2.1.4 and 14.1.1 January 2024 PSUs.
4444
- #1605 - Deprecated the Deploy Applications Tool. The intention going forward is that users should be able to use
4545
the Update Domain Tool, which already does everything that the Deploy Applications Tool does and more.
46+
- #1613 - Added ability to use variable tokens in the SAML 2 data initialization property files that will be replaced
47+
during domain creation or update processing.
48+
- #1614 - Updated Discover Domain Tool to overwrite existing variable and archive files if they already exist.
4649

4750
#### Bug Fixes
4851
- #1555 - Fixed issues with creating and discovering `UnixMachine` objects in online mode.

0 commit comments

Comments
 (0)