Skip to content

Commit dde23db

Browse files
Set staging mode of app or lib during deploy or redeploy (#945)
* Set staging mode of app or lib during deploy or redeploy * Set staging mode of app or lib during deploy or redeploy * rename methods to indicate online only
1 parent e24e232 commit dde23db

File tree

6 files changed

+50
-7
lines changed

6 files changed

+50
-7
lines changed

core/src/main/python/deploy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def __deploy_online(model, model_context, aliases):
132132
try:
133133
model_deployer.deploy_resources(model, model_context, aliases, wlst_mode=__wlst_mode)
134134
deployer_utils.delete_online_deployment_targets(model, aliases, __wlst_mode)
135+
model_deployer.deploy_app_attributes_online(model, model_context, aliases)
135136
except DeployException, de:
136137
deployer_utils.release_edit_session_and_disconnect()
137138
raise de

core/src/main/python/update.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def __update_online(model, model_context, aliases):
162162
topology_updater.update()
163163
model_deployer.deploy_resources(model, model_context, aliases, wlst_mode=__wlst_mode)
164164
deployer_utils.delete_online_deployment_targets(model, aliases, __wlst_mode)
165+
model_deployer.deploy_app_attributes_online(model, model_context, aliases)
165166
except DeployException, de:
166167
deployer_utils.release_edit_session_and_disconnect()
167168
raise de

core/src/main/python/wlsdeploy/aliases/model_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@
372372
SET_OPTION_JAVA_HOME = 'JavaHome'
373373
SET_OPTION_SERVER_START_MODE = 'ServerStartMode'
374374
SOURCE_PATH = 'SourcePath'
375-
STAGE_MODE = 'StageMode'
375+
STAGE_MODE = 'StagingMode'
376376
TAGS = 'Tags'
377377
TARGETS = 'Targets'
378378
URL = 'URL'

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ def __online_deploy_apps_and_libs(self, base_location):
245245
self.__build_app_deploy_strategy(app_location, model_applications, existing_app_refs,
246246
stop_and_undeploy_app_list)
247247

248-
# deployed_app_list is list of apps that has been deployed and stareted again
249-
# redeploy_app_list is list of apps that needs to be redeplyed
248+
# deployed_app_list is list of apps that has been deployed and started again
249+
# redeploy_app_list is list of apps that needs to be redeployed
250250
deployed_app_list = []
251251
redeploy_app_list = []
252252

@@ -903,6 +903,7 @@ def __deploy_model_libraries(self, model_libs, lib_location):
903903
src_path = dictionary_utils.get_element(lib_dict, SOURCE_PATH)
904904
plan_file = dictionary_utils.get_element(lib_dict, PLAN_PATH)
905905
targets = dictionary_utils.get_element(lib_dict, TARGET)
906+
stage_mode = dictionary_utils.get_element(lib_dict, STAGE_MODE)
906907
options = _get_deploy_options(model_libs, lib_name, library_module='true')
907908
for uses_path_tokens_attribute_name in uses_path_tokens_attribute_names:
908909
if uses_path_tokens_attribute_name in lib_dict:
@@ -913,7 +914,7 @@ def __deploy_model_libraries(self, model_libs, lib_location):
913914
location.add_name_token(token_name, lib_name)
914915
resource_group_template_name, resource_group_name, partition_name = \
915916
self.__get_mt_names_from_location(location)
916-
self.__deploy_app_online(lib_name, src_path, targets, plan=plan_file,
917+
self.__deploy_app_online(lib_name, src_path, targets, plan=plan_file, stage_mode=stage_mode,
917918
partition=partition_name, resource_group=resource_group_name,
918919
resource_group_template=resource_group_template_name, options=options)
919920
location.remove_name_token(token_name)
@@ -930,6 +931,7 @@ def __deploy_model_applications(self, model_apps, app_location, deployed_applist
930931
app_dict = model_apps[app_name]
931932
src_path = dictionary_utils.get_element(app_dict, SOURCE_PATH)
932933
plan_file = dictionary_utils.get_element(app_dict, PLAN_PATH)
934+
stage_mode = dictionary_utils.get_element(app_dict, STAGE_MODE)
933935
targets = dictionary_utils.get_element(app_dict, TARGET)
934936
options = _get_deploy_options(model_apps, app_name, library_module='false')
935937

@@ -945,7 +947,8 @@ def __deploy_model_applications(self, model_apps, app_location, deployed_applist
945947
self.__get_mt_names_from_location(location)
946948

947949
new_app_name = self.__deploy_app_online(app_name, src_path, targets, plan=plan_file,
948-
partition=partition_name, resource_group=resource_group_name,
950+
stage_mode=stage_mode, partition=partition_name,
951+
resource_group=resource_group_name,
949952
resource_group_template=resource_group_template_name,
950953
options=options)
951954
location.remove_name_token(token_name)
@@ -973,7 +976,7 @@ def __get_mt_names_from_location(self, app_location):
973976
dummy_location.pop_location()
974977
return resource_group_template_name, resource_group_name, partition_name
975978

976-
def __deploy_app_online(self, application_name, source_path, targets, plan=None, partition=None,
979+
def __deploy_app_online(self, application_name, source_path, targets, stage_mode=None, plan=None, partition=None,
977980
resource_group=None, resource_group_template=None, options=None):
978981
"""
979982
Deploy an application or shared library in online mode.
@@ -1039,6 +1042,8 @@ def __deploy_app_online(self, application_name, source_path, targets, plan=None,
10391042
kwargs['resourceGroupTemplate'] = str(resource_group_template)
10401043
if partition is not None:
10411044
kwargs['partition'] = str(partition)
1045+
if stage_mode is not None:
1046+
kwargs['stageMode'] = str(stage_mode)
10421047
if options is not None:
10431048
for key, value in options.iteritems():
10441049
kwargs[key] = value

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55
import os
6+
import copy
67

78
from array import array
89
from java.lang import Class
910
from oracle.weblogic.deploy.util import PyWLSTException
10-
11+
from wlsdeploy.aliases.model_constants import ABSOLUTE_PLAN_PATH
12+
from wlsdeploy.aliases.model_constants import ABSOLUTE_SOURCE_PATH
13+
from wlsdeploy.aliases.model_constants import APP_DEPLOYMENTS
14+
from wlsdeploy.aliases.model_constants import APPLICATION
15+
from wlsdeploy.aliases.model_constants import PLAN_PATH
16+
from wlsdeploy.aliases.model_constants import SOURCE_PATH
17+
from wlsdeploy.aliases.model_constants import TARGET
1118
from wlsdeploy.aliases.wlst_modes import WlstModes
1219
from wlsdeploy.aliases.location_context import LocationContext
1320
from wlsdeploy.exception import exception_helper
@@ -409,6 +416,30 @@ def __process_archive_entry(self, location, key, value):
409416
self.logger.exiting(class_name=self._class_name, method_name=_method_name, result=result)
410417
return result
411418

419+
def add_application_attributes_online(self, model, location):
420+
"""
421+
Add attributes for online; the attributes that are added are not set during the online
422+
deploy WLST call.
423+
:param model: dictionary model
424+
:param location: current location
425+
"""
426+
427+
deploy = dictionary_utils.get_dictionary_element(model.get_model(), APP_DEPLOYMENTS)
428+
apps_deploy = dictionary_utils.get_dictionary_element(deploy, APPLICATION)
429+
apps = copy.deepcopy(apps_deploy)
430+
431+
for app in apps:
432+
apps_slim = apps[app]
433+
deploy_info = [ PLAN_PATH, ABSOLUTE_PLAN_PATH, SOURCE_PATH, ABSOLUTE_SOURCE_PATH, TARGET]
434+
new_location = LocationContext(location)
435+
new_location.append_location(APPLICATION)
436+
new_location.add_name_token(self.aliases.get_name_token(new_location), app)
437+
path = self.aliases.get_wlst_attributes_path(new_location)
438+
if self.wlst_helper.path_exists(path):
439+
self.wlst_helper.cd(path)
440+
self.set_attributes(new_location, apps_slim, excludes=deploy_info)
441+
442+
412443
def __process_directory_entry(self, path):
413444
"""
414445
Create the directory (and any parent directories) if it does not already exist.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ def deploy_resources(model, model_context, aliases, wlst_mode=WlstModes.OFFLINE)
3838
return
3939

4040

41+
def deploy_app_attributes_online(model, model_context, aliases):
42+
applications_deployer = ApplicationsDeployer(model, model_context, aliases, wlst_mode=WlstModes.ONLINE)
43+
applications_deployer.add_application_attributes_online(model,LocationContext())
44+
45+
4146
def deploy_applications(model, model_context, aliases, wlst_mode=WlstModes.OFFLINE):
4247
"""
4348
Deploy the applications from the model.

0 commit comments

Comments
 (0)