Skip to content

Commit 2a9ad80

Browse files
committed
Merge branch 'wdt-853' into 'develop-4.0'
WDT-853 Fixing SSH Update of structured applications See merge request weblogic-cloud/weblogic-deploy-tooling!1647
2 parents 8f6e5bc + 1fc8b2b commit 2a9ad80

File tree

23 files changed

+692
-51
lines changed

23 files changed

+692
-51
lines changed

core/src/main/python/wlsdeploy/tool/deploy/applications_online_deployer.py

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,7 @@ def __build_app_deploy_strategy(self, location, model_apps, existing_app_refs, s
500500

501501
model_src_path = dictionary_utils.get_element(app_dict, SOURCE_PATH)
502502
# determine the versioned name of the library from the application's MANIFEST
503-
# FIXME - why is from_archive always set to True???
504-
versioned_name = \
505-
self.version_helper.get_application_versioned_name(model_src_path, app, from_archive=True)
506-
503+
versioned_name = self.version_helper.get_application_versioned_name(model_src_path, app)
507504
existing_app_ref = dictionary_utils.get_dictionary_element(existing_app_refs, versioned_name)
508505

509506
# remove deleted targets from the model and the existing app targets
@@ -818,7 +815,6 @@ def __deploy_model_deployments(self, deployments, deployments_location, deployme
818815
for deployment_name in deploy_ordered_keys:
819816
if not model_helper.is_delete_name(deployment_name):
820817
deployment_dict = deployments[deployment_name]
821-
src_path = dictionary_utils.get_element(deployment_dict, SOURCE_PATH)
822818
stage_mode = dictionary_utils.get_element(deployment_dict, STAGE_MODE)
823819
targets = dictionary_utils.get_element(deployment_dict, TARGET)
824820

@@ -833,41 +829,43 @@ def __deploy_model_deployments(self, deployments, deployments_location, deployme
833829
self._fixup_structured_app_plan_file_config_root(deployment_dict)
834830

835831
model_source_path = dictionary_utils.get_element(deployment_dict, SOURCE_PATH)
832+
source_path = self.__get_online_deployment_path(deployment_name, deployment_type, SOURCE_PATH, model_source_path)
836833
combined_plan_path = self._get_combined_model_plan_path(deployment_dict)
837-
deploy_path = self.__get_online_deployment_path(model_source_path)
838-
plan_path = self.__get_online_deployment_path(combined_plan_path)
834+
plan_path = self.__get_online_deployment_path(deployment_name, deployment_type, PLAN_PATH, combined_plan_path)
839835

840836
location.add_name_token(token_name, deployment_name)
841837
resource_group_template_name, resource_group_name, partition_name = \
842838
self._get_mt_names_from_location(location)
843839

844840
module_type = dictionary_utils.get_element(deployment_dict, MODULE_TYPE)
845841

846-
new_name = self.__deploy_app_or_library(deployment_name, deploy_path, targets, plan=plan_path,
847-
stage_mode=stage_mode, partition=partition_name,
842+
new_name = self.__deploy_app_or_library(deployment_name, model_source_path, source_path, targets,
843+
plan=plan_path, stage_mode=stage_mode,
844+
partition=partition_name,
848845
resource_group=resource_group_name,
849846
resource_group_template=resource_group_template_name,
850847
module_type=module_type,
851848
sub_module_targets=sub_module_targets,
852849
options=options)
853850

854851
deployed_names.append(new_name)
855-
self._substitute_appmodule_token(src_path, module_type)
852+
self._substitute_appmodule_token(model_source_path, module_type)
856853

857854
location.remove_name_token(token_name)
858855

859856
self.logger.exiting(class_name=self._class_name, method_name=_method_name)
860857
return deployed_names
861858

862-
def __deploy_app_or_library(self, application_name, source_path, targets, stage_mode=None, plan=None, partition=None,
863-
resource_group=None, resource_group_template=None, sub_module_targets=None,
864-
module_type = None, options=None):
859+
def __deploy_app_or_library(self, application_name, model_source_path, deploy_source_path, targets, stage_mode=None,
860+
plan=None, partition=None, resource_group=None, resource_group_template=None,
861+
sub_module_targets=None, module_type = None, options=None):
865862
"""
866863
Deploy an application or shared library in online mode.
867864
:param application_name: the name of the app or library from the model
868-
:param source_path: the source path of the app or library
865+
:param model_source_path: the model source path of the app or library
866+
:param deploy_source_path: the full source path of the app or library
869867
:param targets: the intended targets
870-
:param plan: optional, the path to the plan
868+
:param plan: optional, the full path to the plan file
871869
:param partition: optional, the partition
872870
:param resource_group: optional, the resource group
873871
:param resource_group_template: optional, the resource group template
@@ -887,42 +885,39 @@ def __deploy_app_or_library(self, application_name, source_path, targets, stage_
887885

888886
real_domain_home = self.model_context.get_domain_home()
889887

890-
if string_utils.is_empty(source_path):
888+
if string_utils.is_empty(model_source_path):
891889
ex = exception_helper.create_deploy_exception('WLSDPLY-09317', type_name, application_name, SOURCE_PATH)
892890
self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
893891
raise ex
894892

895-
full_source_path = source_path
896-
897-
if self.path_helper.is_relative_local_path(full_source_path):
898-
full_source_path = self.path_helper.local_join(real_domain_home, source_path)
899-
900-
if self.path_helper.is_absolute_local_path(full_source_path) and not self.model_context.is_ssh() \
901-
and not os.path.exists(full_source_path):
893+
if not self.model_context.is_ssh() and self.path_helper.is_absolute_local_path(deploy_source_path) and \
894+
not os.path.exists(deploy_source_path):
902895
ex = exception_helper.create_deploy_exception('WLSDPLY-09318', type_name, application_name,
903-
str_helper.to_string(full_source_path))
896+
str_helper.to_string(deploy_source_path))
904897
self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
905898
raise ex
906899

907900
if is_library:
908-
computed_name = self.version_helper.get_library_versioned_name(source_path, application_name,
909-
from_archive=(self.model_context.is_remote() or self.model_context.is_ssh()))
901+
computed_name = self.version_helper.get_library_versioned_name(model_source_path, application_name)
910902
else:
911-
computed_name = self.version_helper.get_application_versioned_name(source_path, application_name,
912-
module_type=module_type,
913-
from_archive=(self.model_context.is_remote() or self.model_context.is_ssh()))
903+
computed_name = self.version_helper.get_application_versioned_name(model_source_path, application_name,
904+
module_type=module_type)
914905

915906
application_name = computed_name
916907

917908
# build the dictionary of named arguments to pass to the deploy_application method
918909
args = list()
919-
kwargs = {'path': str_helper.to_string(full_source_path), 'targets': str_helper.to_string(targets)}
910+
kwargs = {'path': str_helper.to_string(deploy_source_path), 'targets': str_helper.to_string(targets)}
911+
if options is not None:
912+
is_remote = dictionary_utils.get_element(options, 'remote') == 'true'
913+
else:
914+
is_remote = False
920915

921916
if plan is not None:
922917
if self.path_helper.is_relative_local_path(plan):
923918
plan = self.path_helper.local_join(real_domain_home, plan)
924919

925-
if not os.path.exists(plan):
920+
if not is_remote and not os.path.exists(plan):
926921
ex = exception_helper.create_deploy_exception('WLSDPLY-09319', type_name, application_name, plan)
927922
self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
928923
raise ex
@@ -1165,19 +1160,25 @@ def _replace_deployments_path_tokens(self, deployment_type, deployments_dict):
11651160

11661161
self.logger.exiting(class_name=self._class_name, method_name=_method_name)
11671162

1168-
def __get_online_deployment_path(self, model_path):
1163+
def __get_online_deployment_path(self, model_name, model_type, attribute_name, attribute_value):
11691164
_method_name = '__get_online_deployment_path'
1170-
self.logger.entering(model_path, class_name=self._class_name, method_name=_method_name)
1165+
self.logger.entering(model_name, model_type, attribute_name, attribute_value,
1166+
class_name=self._class_name, method_name=_method_name)
11711167

1172-
result = model_path
1173-
if not string_utils.is_empty(model_path):
1174-
if self.archive_helper and self.archive_helper.is_path_into_archive(model_path):
1168+
result = attribute_value
1169+
if not string_utils.is_empty(attribute_value):
1170+
if self.archive_helper and self.archive_helper.is_path_into_archive(attribute_value):
11751171
if self.model_context.is_remote():
1176-
result = self.path_helper.local_join(self.upload_temporary_dir, model_path)
1172+
result = self.path_helper.local_join(self.upload_temporary_dir, attribute_value)
11771173
elif self.model_context.is_ssh():
1178-
result = self.path_helper.remote_join(self.model_context.get_domain_home(), model_path)
1174+
result = self.path_helper.remote_join(self.model_context.get_domain_home(), attribute_value)
11791175
else:
1180-
result = self.path_helper.local_join(self.model_context.get_domain_home(), model_path)
1176+
result = self.path_helper.local_join(self.model_context.get_domain_home(), attribute_value)
1177+
elif self.path_helper.is_relative_path(attribute_value):
1178+
ex = exception_helper.create_deploy_exception('WLSDPLY-09351', model_type, model_name,
1179+
attribute_name, attribute_value)
1180+
self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
1181+
raise ex
11811182

11821183
self.logger.exiting(class_name=self._class_name, method_name=_method_name, result=result)
11831184
return result

core/src/main/python/wlsdeploy/tool/deploy/applications_version_helper.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, model_context, archive_helper):
3737
self.archive_helper = archive_helper
3838
self.logger = PlatformLogger('wlsdeploy.deploy')
3939

40-
def get_library_versioned_name(self, source_path, model_name, from_archive=False):
40+
def get_library_versioned_name(self, source_path, model_name):
4141
"""
4242
Get the proper name of the deployable library that WLST requires in the target domain. This method is
4343
primarily needed for shared libraries in the Oracle Home where the implementation version may have
@@ -57,7 +57,7 @@ def get_library_versioned_name(self, source_path, model_name, from_archive=False
5757
old_name_tuple = deployer_utils.get_library_name_components(model_name)
5858
try:
5959
versioned_name = old_name_tuple[self._EXTENSION_INDEX]
60-
manifest = self.__get_manifest(source_path, from_archive)
60+
manifest = self.__get_manifest(source_path)
6161
if manifest is not None:
6262
attributes = manifest.getMainAttributes()
6363

@@ -86,26 +86,27 @@ def get_library_versioned_name(self, source_path, model_name, from_archive=False
8686
self.logger.exiting(class_name=self._class_name, method_name=_method_name, result=versioned_name)
8787
return versioned_name
8888

89-
def get_application_versioned_name(self, source_path, model_name, from_archive=False, module_type=None):
89+
def get_application_versioned_name(self, source_path, model_name, module_type=None):
9090
"""
9191
Get the proper name of the deployable application that WLST requires in the target domain.
9292
This method is needed for the case where the application is explicitly versioned in its ear/war manifest.
9393
Rather than requiring the modeller to have to know/adjust the application name, we extract
9494
the information from the application's archive file (e.g., war file) and compute the correct name.
9595
:param source_path: the SourcePath value of the application
9696
:param model_name: the model name of the application
97-
:param from_archive: if True, use the manifest from the archive, otherwise from the file system
97+
:param module_type: optional argument to specify the module type being deployed
9898
:return: the updated application name for the target environment
9999
:raises: DeployException: if an error occurs
100100
"""
101101
_method_name = 'get_application_versioned_name'
102-
self.logger.entering(source_path, model_name, class_name=self._class_name, method_name=_method_name)
102+
self.logger.entering(source_path, model_name, module_type,
103+
class_name=self._class_name, method_name=_method_name)
103104

104105
# if no manifest version is found, leave the original name unchanged
105106
versioned_name = model_name
106107
if not self.is_module_type_app_module(module_type) and not string_utils.is_empty(source_path):
107108
try:
108-
manifest = self.__get_manifest(source_path, from_archive)
109+
manifest = self.__get_manifest(source_path)
109110

110111
if manifest is not None:
111112
attributes = manifest.getMainAttributes()
@@ -133,12 +134,11 @@ def is_module_type_app_module(self, module_type):
133134
else:
134135
return False
135136

136-
def __get_manifest(self, source_path, from_archive):
137+
def __get_manifest(self, source_path):
137138
"""
138139
Returns the manifest object for the specified path.
139140
The source path may be a jar, or an exploded path.
140141
:param source_path: the source path to be checked
141-
:param from_archive: if True, use the manifest from the archive, otherwise from the file system
142142
:return: the manifest, or None if it is not present
143143
:raises: IOException: if there are problems reading an existing manifest
144144
"""
@@ -148,7 +148,7 @@ def __get_manifest(self, source_path, from_archive):
148148

149149
source_path = self.model_context.replace_token_string(source_path)
150150

151-
if from_archive and deployer_utils.is_path_into_archive(source_path):
151+
if deployer_utils.is_path_into_archive(source_path):
152152
return self.archive_helper.get_manifest(source_path)
153153

154154
else:

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
@@ -1438,6 +1438,7 @@ WLSDPLY-09348=Model application {0} is missing the SourcePath attribute but no e
14381438
name of application or add the SourcePath.
14391439
WLSDPLY-09349=Cannot deploy structured application {0} with installation directory {1} with '-remote' option
14401440
WLSDPLY-09350={0} {1} cannot be deployed using the -remote options since the SourcePath {2} and combined PlanDir and PlanPath {3} are not both absolute paths
1441+
WLSDPLY-09351={0} {1} has attribute {2} with a relative path that is not referencing an archive file so the absolute path to the file is not well-defined.
14411442

14421443
# wlsdeploy/tool/deploy/common_resources_deployer.py
14431444
WLSDPLY-09400=ResourceGroup was specified in the test file but are not supported in WebLogic Server version {0}

integration-tests/apps/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
<module>simple-app-archive</module>
2222
<module>simple-app-updated-archive</module>
2323
<module>structured-app</module>
24+
<module>versioned-app</module>
2425
</modules>
2526
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (c) 2024, Oracle and/or its affiliates.
4+
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
-->
6+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
7+
<modelVersion>4.0.0</modelVersion>
8+
9+
<artifactId>weblogic-deploy-system-test-apps-versioned-app</artifactId>
10+
<packaging>pom</packaging>
11+
12+
<parent>
13+
<artifactId>weblogic-deploy-system-test-apps</artifactId>
14+
<groupId>com.oracle.weblogic.lifecycle</groupId>
15+
<version>4.0.0-SNAPSHOT</version>
16+
<relativePath>../pom.xml</relativePath>
17+
</parent>
18+
19+
<modules>
20+
<module>versioned-app-war</module>
21+
<module>versioned-app-archive</module>
22+
<module>versioned-app-updated-war</module>
23+
<module>versioned-app-updated-archive</module>
24+
</modules>
25+
</project>

0 commit comments

Comments
 (0)