Skip to content

Commit fec0331

Browse files
committed
Merge branch 'wdt-873' into 'main'
Fixing issue where SSHJ was preventing WDT from running weith JDK 7 See merge request weblogic-cloud/weblogic-deploy-tooling!1679
2 parents b45fed0 + ebe6d82 commit fec0331

File tree

30 files changed

+71
-30
lines changed

30 files changed

+71
-30
lines changed

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<artifactId>weblogic-deploy</artifactId>
1313
<groupId>com.oracle.weblogic.lifecycle</groupId>
14-
<version>4.2.0-SNAPSHOT</version>
14+
<version>4.1.1-SNAPSHOT</version>
1515
<relativePath>../pom.xml</relativePath>
1616
</parent>
1717

core/src/main/python/deploy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def __process_args(args):
9696
cla_helper.validate_variable_file_exists(_program_name, argument_map)
9797
__wlst_mode = cla_helper.process_online_args(argument_map)
9898
cla_helper.validate_if_domain_home_required(_program_name, argument_map, __wlst_mode)
99+
cla_helper.validate_ssh_is_supported(_program_name, argument_map)
99100
cla_helper.process_encryption_args(argument_map)
100101

101102
return model_context_helper.create_context(_program_name, argument_map)

core/src/main/python/discover.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ def __process_args(args):
122122

123123
__wlst_mode = cla_helper.process_online_args(argument_map)
124124
cla_helper.validate_if_domain_home_required(_program_name, argument_map, __wlst_mode)
125+
cla_helper.validate_ssh_is_supported(_program_name, argument_map)
126+
125127
target_configuration_helper.process_target_arguments(argument_map)
126128
__process_model_arg(argument_map)
127129
__process_archive_filename_arg(argument_map)

core/src/main/python/update.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def __process_args(args):
102102
cla_helper.validate_variable_file_exists(_program_name, argument_map)
103103
__wlst_mode = cla_helper.process_online_args(argument_map)
104104
cla_helper.validate_if_domain_home_required(_program_name, argument_map, __wlst_mode)
105+
cla_helper.validate_ssh_is_supported(_program_name, argument_map)
105106
cla_helper.process_encryption_args(argument_map)
106107

107108
return model_context_helper.create_context(_program_name, argument_map)

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from wlsdeploy.util import model_helper
2929
from wlsdeploy.util import model_translator
3030
from wlsdeploy.util import path_helper
31+
from wlsdeploy.util import string_utils
3132

3233
from wlsdeploy.util import variables
3334
from wlsdeploy.util.cla_utils import CommandLineArgUtil
@@ -296,6 +297,16 @@ def process_online_args(optional_arg_map):
296297
return mode
297298

298299

300+
def validate_ssh_is_supported(program_name, argument_map):
301+
_method_name = 'validate_ssh_is_supported'
302+
303+
if CommandLineArgUtil.SSH_HOST_SWITCH in argument_map and not string_utils.is_java_version_or_above('1.8.0'):
304+
tool_exception = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-20042',
305+
program_name, CommandLineArgUtil.SSH_HOST_SWITCH)
306+
__logger.throwing(tool_exception, class_name=_class_name, method_name=_method_name)
307+
raise tool_exception
308+
309+
299310
def clean_up_temp_files():
300311
"""
301312
If a temporary directory was created to extract the model from the archive, delete the directory and its contents.

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
import java.lang.String as JString
1414
import java.lang.System as JSystem
1515

16-
from net.schmizz.sshj import SSHClient
17-
import net.schmizz.sshj.common.SSHException as SSHJException
18-
from net.schmizz.sshj.transport import TransportException
19-
from net.schmizz.sshj.userauth import UserAuthException
20-
2116
from oracle.weblogic.deploy.exception import BundleAwareException
2217
from oracle.weblogic.deploy.util import SSHException
2318
from oracle.weblogic.deploy.util import StringUtils
@@ -30,6 +25,7 @@
3025
from wlsdeploy.util.cla_utils import CommandLineArgUtil
3126
from wlsdeploy.util.exit_code import ExitCode
3227
from wlsdeploy.util import path_helper
28+
from wlsdeploy.util import string_utils
3329
from wlsdeploy.util.ssh_command_line_helper import SSHUnixCommandLineHelper
3430
from wlsdeploy.util.ssh_command_line_helper import SSHWindowsCommandLineHelper
3531

@@ -44,10 +40,15 @@ def initialize_ssh(model_context, argument_map, exception_type=ExceptionType.SSH
4440
__logger.finest('WLSDPLY-32007', class_name=__class_name, method_name=_method_name)
4541
__logger.exiting(class_name=__class_name, method_name=_method_name)
4642
return
43+
elif not string_utils.is_java_version_or_above('1.8.0'):
44+
__logger.fine('WLSDPLY-32041', class_name=__class_name, method_name=_method_name)
45+
__logger.exiting(class_name=__class_name, method_name=_method_name)
46+
return
4747

4848
__validate_ssh_arguments(argument_map, model_context)
4949
__ensure_ssh_credentials(model_context)
5050

51+
import net.schmizz.sshj.common.SSHException as SSHJException
5152
try:
5253
ssh_context = SSHContext(model_context, exception_type)
5354
except (SSHException, SSHJException, JException),err:
@@ -404,6 +405,8 @@ def _connect(self):
404405
_method_name = '_connect'
405406
self._logger.entering(class_name=self._class_name, method_name=_method_name)
406407

408+
from net.schmizz.sshj import SSHClient
409+
407410
ssh_client = SSHClient()
408411
if self._model_context.get_model_config().use_ssh_compression():
409412
ssh_client.useCompression()
@@ -485,6 +488,8 @@ def _username_password_auth(self):
485488
_method_name = '_username_password_auth'
486489
self._logger.entering(class_name=self._class_name, method_name=_method_name)
487490

491+
from net.schmizz.sshj.transport import TransportException
492+
from net.schmizz.sshj.userauth import UserAuthException
488493
user = self._model_context.get_ssh_user()
489494
passwd = self._model_context.get_ssh_pass()
490495
try:
@@ -535,6 +540,7 @@ def _get_private_key_provider(self, key_path, passphrase):
535540
_method_name = '_get_private_key_provider'
536541
self._logger.entering(key_path, class_name=self._class_name, method_name=_method_name)
537542

543+
import net.schmizz.sshj.common.SSHException as SSHJException
538544
try:
539545
if passphrase is not None:
540546
key_provider = self._ssh_client.loadKeys(key_path, passphrase)
@@ -553,6 +559,8 @@ def _do_public_key_auth(self, user, key_arg=None):
553559
_method_name = '_do_public_key_auth'
554560
self._logger.entering(user, key_arg, class_name=self._class_name, method_name=_method_name)
555561

562+
from net.schmizz.sshj.transport import TransportException
563+
from net.schmizz.sshj.userauth import UserAuthException
556564
try:
557565
if key_arg is not None:
558566
self._ssh_client.authPublickey(user, [ key_arg ])

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
"""
2-
Copyright (c) 2017, 2023, Oracle and/or its affiliates.
2+
Copyright (c) 2017, 2024, Oracle 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
This module provides string manipulation helper methods that are not found in the WLST version of Jython
66
"""
7-
import java.util.Properties as Properties
87
import java.io.FileInputStream as FileInputStream
98
import java.io.IOException as IOException
9+
from java.lang import System
10+
from java.util import Properties
1011

1112
from oracle.weblogic.deploy.aliases import VersionUtils
1213
import wlsdeploy.exception.exception_helper as exception_helper
@@ -116,3 +117,18 @@ def is_weblogic_version_or_above(wls_version, str_version):
116117
by the str_version argument, False otherwise
117118
"""
118119
return VersionUtils.compareVersions(wls_version, str_version) >= 0
120+
121+
122+
def is_java_version_or_above(str_version):
123+
"""
124+
Is the current Java version number equal to or greater than the str_version.
125+
:param str_version: the string representation of the version to be compared to the actual java version
126+
:return: True if the actual Java version is equal or greater than the version represented
127+
by the str_version argument, False otherwise
128+
"""
129+
java_version = System.getProperty('java.version')
130+
# strip off the _###
131+
if '_' in java_version:
132+
idx = java_version.index('_')
133+
java_version = java_version[0:idx]
134+
return VersionUtils.compareVersions(java_version, str_version) >= 0

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,6 +2112,7 @@ WLSDPLY-20038=Error applying final filter configuration: {0}
21122112
WLSDPLY-20039=Remote WebLogic PSU version "{0}" extracted from "{1}"
21132113
WLSDPLY-20040=Remote WebLogic version is {0}
21142114
WLSDPLY-20041={0} invoked in online mode with an unused argument {1}, which has been ignored
2115+
WLSDPLY-20042={0} invoked with {1} argument but SSH support requires Java 8 or above
21152116

21162117
# Messages for internal filters
21172118
WLSDPLY-20201=Unsupported attribute {0} at location {1} removed from model: {2}
@@ -2258,6 +2259,7 @@ WLSDPLY-32037=SSH command {0} returned exit code {1} but had no error message: "
22582259
WLSDPLY-32038=Failed to SSH connect to host {0}: {1}
22592260
WLSDPLY-32039=The {0} and {1} arguments are mutually exclusive
22602261
WLSDPLY-32040=SSH requires using running the tool in online mode
2262+
WLSDPLY-32041=Skipping SSH initialization since SSH required Java 8 or higher
22612263

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

installer/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<parent>
1313
<groupId>com.oracle.weblogic.lifecycle</groupId>
1414
<artifactId>weblogic-deploy</artifactId>
15-
<version>4.2.0-SNAPSHOT</version>
15+
<version>4.1.1-SNAPSHOT</version>
1616
<relativePath>../pom.xml</relativePath>
1717
</parent>
1818

integration-tests/alias-test/generate/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<parent>
1313
<artifactId>weblogic-deploy-alias-test</artifactId>
1414
<groupId>com.oracle.weblogic.lifecycle</groupId>
15-
<version>4.2.0-SNAPSHOT</version>
15+
<version>4.1.1-SNAPSHOT</version>
1616
<relativePath>../pom.xml</relativePath>
1717
</parent>
1818

0 commit comments

Comments
 (0)