Skip to content

Commit 11a79d1

Browse files
committed
Merge branch 'wdt942' into 'main'
working around windows scp upload issue See merge request weblogic-cloud/weblogic-deploy-tooling!1836
2 parents 4131709 + d3617ea commit 11a79d1

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ def __init__(self, model_context, exception_type):
203203
self._os_helper = SSHUnixCommandLineHelper()
204204

205205
self.path_helper = path_helper.get_path_helper()
206-
207206
self._logger.exiting(class_name=self._class_name, method_name=_method_name)
208207

209208
def is_connected(self):
@@ -251,7 +250,7 @@ def download(self, source_path, target_path):
251250

252251
def upload(self, source_path, target_path):
253252
_method_name = 'upload'
254-
self._logger.entering(target_path, source_path, class_name=self._class_name, method_name=_method_name)
253+
self._logger.entering(source_path, target_path, class_name=self._class_name, method_name=_method_name)
255254

256255
if StringUtils.isEmpty(target_path):
257256
ex = exception_helper.create_exception(self._exception_type, 'WLSDPLY-32018')
@@ -272,9 +271,25 @@ def upload(self, source_path, target_path):
272271

273272
try:
274273
remote_host = self._ssh_client.getRemoteHostname()
275-
self._logger.info('WLSDPLY-32022', abs_source_path, remote_host, abs_target_path,
276-
class_name=self._class_name, method_name=_method_name)
277-
self._ssh_client.newSCPFileTransfer().upload(abs_source_path, target_path)
274+
275+
# By default, sshj newSCPFileTransfer().upload() uses single quotes, which
276+
# do not work on Windows. Have to go another level down to make this works
277+
# properly.
278+
#
279+
if self.is_windows:
280+
from net.schmizz.sshj.xfer import FileSystemFile
281+
from net.schmizz.sshj.xfer.scp.ScpCommandLine import EscapeMode
282+
283+
self._logger.info('WLSDPLY-32044', abs_source_path, remote_host, target_path,
284+
class_name=self._class_name, method_name=_method_name)
285+
self._ssh_client.newSCPFileTransfer().newSCPUploadClient().copy(FileSystemFile(abs_source_path),
286+
target_path,
287+
EscapeMode.DoubleQuote)
288+
else:
289+
self._logger.info('WLSDPLY-32022', abs_source_path, remote_host, abs_target_path,
290+
class_name=self._class_name, method_name=_method_name)
291+
self._ssh_client.newSCPFileTransfer().upload(abs_source_path, target_path)
292+
278293
self._logger.info('WLSDPLY-32023', abs_source_path, remote_host, abs_target_path,
279294
class_name=self._class_name, method_name=_method_name)
280295
except IOException,ioe:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,6 +2454,7 @@ WLSDPLY-32041=Skipping SSH initialization since SSH required Java 8 or higher
24542454
WLSDPLY-32042=Failed to get the value of the environment variable {0} with command "{1}" on remote SSH host {2}: {3}
24552455
WLSDPLY-32043=Failed to find the Windows temp directory for user {0} using the environment variable {1} on the remote \
24562456
SSH host {2} because the environment variable {1} was not set
2457+
WLSDPLY-32044=Uploading {0} to remote Windows server {1} path {2} using EscapeMode.DoubleQuote mode
24572458

24582459
# verify_ssh.py
24592460
WLSDPLY-32900=The -remote_test_file {0} argument was specified without the corresponding -local_output_dir argument.

0 commit comments

Comments
 (0)