Skip to content

Commit cf14a9a

Browse files
committed
Merge branch 'wdt-850-851' into 'develop-4.0'
Fixing -remote for structured apps and discover issue with tokens See merge request weblogic-cloud/weblogic-deploy-tooling!1643
2 parents ab1c714 + d5c3580 commit cf14a9a

File tree

8 files changed

+252
-62
lines changed

8 files changed

+252
-62
lines changed

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

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -996,9 +996,16 @@ def __get_deploy_options(self, model_apps, app_name, is_library_module):
996996
deploy_options['libraryModule'] = 'true'
997997

998998
if self.model_context.is_remote():
999-
deploy_options['upload'] = 'true'
1000-
1001-
if self.model_context.is_ssh():
999+
# In the -remote use case, if the SourcePath and combined PlanDir/PlanPath are absolute paths in
1000+
# the model, we do not try to upload them and instead assume that they are available on the remote
1001+
# machine already.
1002+
#
1003+
deploy_should_upload = self.__remote_deploy_should_upload_app(app, app_name, is_library_module)
1004+
if deploy_should_upload:
1005+
deploy_options['upload'] = 'true'
1006+
else:
1007+
deploy_options['remote'] = 'true'
1008+
elif self.model_context.is_ssh():
10021009
deploy_options['remote'] = 'true'
10031010

10041011
if len(deploy_options) == 0:
@@ -1012,6 +1019,47 @@ def __get_deploy_options(self, model_apps, app_name, is_library_module):
10121019
result=[deploy_options, sub_module_targets])
10131020
return deploy_options, sub_module_targets
10141021

1022+
def __remote_deploy_should_upload_app(self, deployment_dict, deployment_name, is_library_module):
1023+
"""
1024+
In the -remote use case, should the deployment be uploaded>
1025+
:param deployment_dict: the model dictionary
1026+
:param deployment_name: the model name
1027+
:param is_library_module: whether the deployment is a shared library
1028+
:return: True, if the deploy options should set upload to true; False otherwise
1029+
:raises: DeployException: if the model deployment paths are inconsistent
1030+
"""
1031+
_method_name = '__remote_deploy_should_upload_app'
1032+
self.logger.entering(deployment_dict, deployment_name, is_library_module,
1033+
class_name=self._class_name, method_name=_method_name)
1034+
1035+
deploy_should_upload = True
1036+
1037+
model_source_path = dictionary_utils.get_element(deployment_dict, SOURCE_PATH)
1038+
if not string_utils.is_empty(model_source_path):
1039+
if self.path_helper.is_absolute_path(model_source_path):
1040+
deploy_should_upload = False
1041+
1042+
model_combined_plan_path = self._get_combined_model_plan_path(deployment_dict)
1043+
if not string_utils.is_empty(model_combined_plan_path):
1044+
if self.path_helper.is_absolute_path(model_combined_plan_path):
1045+
if string_utils.is_empty(model_source_path):
1046+
deploy_should_upload = False
1047+
elif deploy_should_upload:
1048+
# SourcePath was not empty and not an absolute path but the plan is an absolute path so
1049+
# the model is inconsistent and the deploy operation cannot process it.
1050+
#
1051+
model_type = APPLICATION
1052+
if is_library_module:
1053+
model_type = LIBRARY
1054+
ex = exception_helper.create_deploy_exception('WLSDPLY-09350', model_type, deployment_name,
1055+
model_source_path, model_combined_plan_path)
1056+
self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
1057+
raise ex
1058+
# else deploy_should_upload already set to false so there is nothing to do
1059+
1060+
self.logger.exiting(class_name=self._class_name, method_name=_method_name, result=deploy_should_upload)
1061+
return deploy_should_upload
1062+
10151063
def __set_sub_deployments_for_app_module(self, app, module_type, sub_module_targets):
10161064
_method_name = '__set_sub_deployments_for_app_module'
10171065
self.logger.entering(app, module_type, sub_module_targets, class_name=self._class_name, method_name=_method_name)

core/src/main/python/wlsdeploy/tool/discover/deployments_discoverer.py

Lines changed: 68 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
from wlsdeploy.aliases.alias_constants import PASSWORD_TOKEN
2222
from wlsdeploy.aliases import model_constants
2323
from wlsdeploy.aliases.location_context import LocationContext
24+
from wlsdeploy.aliases.model_constants import PLAN_DIR
25+
from wlsdeploy.aliases.model_constants import PLAN_PATH
26+
from wlsdeploy.aliases.model_constants import SOURCE_PATH
2427
from wlsdeploy.aliases.wlst_modes import WlstModes
2528
from wlsdeploy.exception import exception_helper
2629
from wlsdeploy.logging.platform_logger import PlatformLogger
@@ -299,49 +302,48 @@ def _add_application_to_archive(self, application_name, application_dict):
299302
_logger.entering(application_name, class_name=_class_name, method_name=_method_name)
300303

301304
archive_file = self._model_context.get_archive_file()
302-
if model_constants.SOURCE_PATH in application_dict:
303-
file_name = application_dict[model_constants.SOURCE_PATH]
304-
if file_name:
305-
file_name_path = file_name
306-
if not self._model_context.is_remote():
307-
file_name_path = self._convert_path(file_name)
308-
if self._is_file_to_exclude_from_archive(file_name_path):
309-
_logger.info('WLSDPLY-06393', application_name,
305+
file_name = self._get_dictionary_attribute_with_path_tokens_replaced(application_dict, SOURCE_PATH)
306+
if file_name is not None:
307+
file_name_path = file_name
308+
if not self._model_context.is_remote():
309+
file_name_path = self._convert_path(file_name)
310+
if self._is_file_to_exclude_from_archive(file_name_path):
311+
_logger.info('WLSDPLY-06393', application_name,
312+
class_name=_class_name, method_name=_method_name)
313+
else:
314+
new_source_name = None
315+
if self._model_context.is_remote():
316+
new_source_name = WLSDeployArchive.getApplicationArchivePath(file_name_path)
317+
self.add_to_remote_map(file_name_path, new_source_name,
318+
WLSDeployArchive.ArchiveEntryType.APPLICATION.name())
319+
elif not self._model_context.is_skip_archive():
320+
_logger.info('WLSDPLY-06394', application_name, file_name_path,
310321
class_name=_class_name, method_name=_method_name)
311-
else:
312-
new_source_name = None
313-
if self._model_context.is_remote():
314-
new_source_name = WLSDeployArchive.getApplicationArchivePath(file_name_path)
315-
self.add_to_remote_map(file_name_path, new_source_name,
316-
WLSDeployArchive.ArchiveEntryType.APPLICATION.name())
317-
elif not self._model_context.is_skip_archive():
318-
_logger.info('WLSDPLY-06394', application_name, file_name_path,
319-
class_name=_class_name, method_name=_method_name)
320-
try:
321-
if self._model_context.is_ssh():
322-
file_name_path = \
323-
self.download_deployment_from_remote_server(file_name_path,
324-
self.download_temporary_dir,
325-
"applications")
326-
327-
new_source_name = archive_file.addApplication(file_name_path)
328-
module_type = dictionary_utils.get_dictionary_element(application_dict,
329-
model_constants.MODULE_TYPE)
330-
if module_type == 'jdbc':
331-
self._jdbc_password_fix(new_source_name)
332-
333-
except IllegalArgumentException, iae:
334-
self._disconnect_target(application_name, application_dict, iae.getLocalizedMessage())
335-
except WLSDeployArchiveIOException, wioe:
336-
de = exception_helper.create_discover_exception('WLSDPLY-06397', application_name,
337-
file_name_path, wioe.getLocalizedMessage())
338-
_logger.throwing(class_name=_class_name, method_name=_method_name, error=de)
339-
raise de
340-
if new_source_name is not None:
341-
_logger.finer('WLSDPLY-06398', application_name, new_source_name, class_name=_class_name,
342-
method_name=_method_name)
343-
application_dict[model_constants.SOURCE_PATH] = new_source_name
344-
self.add_application_plan_to_archive(application_name, application_dict)
322+
try:
323+
if self._model_context.is_ssh():
324+
file_name_path = \
325+
self.download_deployment_from_remote_server(file_name_path,
326+
self.download_temporary_dir,
327+
"applications")
328+
329+
new_source_name = archive_file.addApplication(file_name_path)
330+
module_type = dictionary_utils.get_dictionary_element(application_dict,
331+
model_constants.MODULE_TYPE)
332+
if module_type == 'jdbc':
333+
self._jdbc_password_fix(new_source_name)
334+
335+
except IllegalArgumentException, iae:
336+
self._disconnect_target(application_name, application_dict, iae.getLocalizedMessage())
337+
except WLSDeployArchiveIOException, wioe:
338+
de = exception_helper.create_discover_exception('WLSDPLY-06397', application_name,
339+
file_name_path, wioe.getLocalizedMessage())
340+
_logger.throwing(class_name=_class_name, method_name=_method_name, error=de)
341+
raise de
342+
if new_source_name is not None:
343+
_logger.finer('WLSDPLY-06398', application_name, new_source_name, class_name=_class_name,
344+
method_name=_method_name)
345+
application_dict[model_constants.SOURCE_PATH] = new_source_name
346+
self.add_application_plan_to_archive(application_name, application_dict)
345347

346348
_logger.exiting(class_name=_class_name, method_name=_method_name)
347349

@@ -357,9 +359,17 @@ def add_application_plan_to_archive(self, application_name, application_dict):
357359
_method_name = 'add_application_plan_to_archive'
358360
_logger.entering(application_name, class_name=_class_name, method_name=_method_name)
359361
archive_file = self._model_context.get_archive_file()
360-
if model_constants.PLAN_PATH in application_dict:
361-
app_source_name = application_dict[model_constants.SOURCE_PATH]
362-
plan_path = application_dict[model_constants.PLAN_PATH]
362+
363+
model_plan_path = self._get_dictionary_attribute_with_path_tokens_replaced(application_dict, PLAN_PATH)
364+
if model_plan_path is not None:
365+
app_source_name = self._get_dictionary_attribute_with_path_tokens_replaced(application_dict, SOURCE_PATH)
366+
model_plan_dir = self._get_dictionary_attribute_with_path_tokens_replaced(application_dict, PLAN_DIR)
367+
368+
if model_plan_dir is not None and self.path_helper.is_relative_path(model_plan_path):
369+
plan_path = self.path_helper.join(model_plan_dir, model_plan_path)
370+
else:
371+
plan_path = model_plan_path
372+
363373
if plan_path:
364374
if not self._model_context.is_remote():
365375
plan_path = self._convert_path(plan_path)
@@ -425,16 +435,9 @@ def _is_structured_app(self, application_name, application_dict):
425435
_method_name = '_is_structured_app'
426436
_logger.entering(application_dict, class_name=_class_name, method_name=_method_name)
427437

428-
source_path = None
429-
plan_dir = None
430-
plan_path = None
431-
432-
if 'SourcePath' in application_dict:
433-
source_path = application_dict['SourcePath']
434-
if 'PlanDir' in application_dict:
435-
plan_dir = application_dict['PlanDir']
436-
if 'PlanPath' in application_dict:
437-
plan_path = application_dict['PlanPath']
438+
source_path = self._get_dictionary_attribute_with_path_tokens_replaced(application_dict, SOURCE_PATH)
439+
plan_dir = self._get_dictionary_attribute_with_path_tokens_replaced(application_dict, PLAN_DIR)
440+
plan_path = self._get_dictionary_attribute_with_path_tokens_replaced(application_dict, PLAN_PATH)
438441

439442
_logger.finer('WLSDPLY-06405', application_name, source_path, plan_dir, plan_path,
440443
class_name=_class_name, method_name=_method_name)
@@ -681,6 +684,16 @@ def _get_app_install_root(self, app_dir, plan_dir):
681684
_logger.exiting(class_name=_class_name, method_name=_method_name, result=install_root)
682685
return install_root
683686

687+
def _get_dictionary_attribute_with_path_tokens_replaced(self, model_dict, attribute_name):
688+
_method_name = '_get_dictionary_attribute_with_path_tokens_replaced'
689+
_logger.entering(model_dict, attribute_name, class_name=_class_name, method_name=_method_name)
690+
691+
result = dictionary_utils.get_element(model_dict, attribute_name)
692+
if result is not None:
693+
result = self._model_context.replace_token_string(result)
694+
695+
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
696+
return result
684697

685698
def _generate_new_plan_name(binary_path, plan_path):
686699
"""

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
@@ -1436,6 +1436,7 @@ WLSDPLY-09348=Model application {0} is missing the SourcePath attribute but no e
14361436
exact same name but one or more possible matches {1} were found. Please update the model to either use the exact \
14371437
name of application or add the SourcePath.
14381438
WLSDPLY-09349=Cannot deploy structured application {0} with installation directory {1} with '-remote' option
1439+
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
14391440

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

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ pre = "<b> </b>"
2121
Added online mode support. Fixed CRDs to work consistently with alias folders and attributes.
2222
- #1550 - Refactored the archive file and moved content extraction into `$DOMAIN_HOME/config/wlsdeploy` for some types
2323
to take advantage of existing Pack/Unpack behavior and admin server to managed server replications capabilities.
24-
- #1584 - Added support for creating WebLogic authorization policies during domain creation (GitHub issue #1496).
24+
- #1584 - Added support for creating WebLogic authorization policies during domain creation (GitHub issue #1496).
25+
- #1641, #1643 - Overhauled Application and Library provisioning. As part of this overhaul, we have tried to define the
26+
semantics for non-archive application deployments, particularly with online Update Domain and Deploy Apps tools.
27+
For non-archive applications/libraries, online deployment of binaries outside of the archive will always
28+
assume that the binaries are available to the Admin Server at the model-specified paths. Neither the
29+
`-remote` or SSH options will attempt to upload the non-archived binaries.
2530

2631
#### Other Changes
2732
- #1544 - Consolidated multiple internal WLST helper methods to get an MBean.
@@ -71,9 +76,12 @@ pre = "<b> </b>"
7176
WebLogic Server 14.1.1 and newer.
7277
- #1636 - Fixed an issue with Update Domain and Deploy Applications Tools when using the `-remote` option that was
7378
causing a TODO message to be generated when there was nothing for the user to do.
74-
- #1638 - Fixed an issue with Update Domain and Deploy Applications Tools where the application specified a `PlanDir`
75-
and a `PlanPath` but the online deployment was ignoring the `PlanDir`, resulting in a file does not exist
76-
error when attempting to deploy the application.
79+
- #1638 - Fixed an issue with the Update Domain and Deploy Applications Tools where the application specified a
80+
`PlanDir` and a `PlanPath` but the online deployment was ignoring the `PlanDir`, resulting in a file does
81+
not exist error when attempting to deploy the application.
82+
- #1642 - Fixed deployment issues with deploying applications not included in an archive file.
83+
- #1643 - Fixed an issue with Discover Domain where application/library path tokenization was preventing adding
84+
deployments to the archive file.
7785

7886
#### Known Issues
7987
- SSH support requires a reasonably recent version of Bouncy Castle. WDT picks up Bouncy Castle from WLST so, for example,

0 commit comments

Comments
 (0)