28
28
from wlsdeploy .aliases .model_constants import APPLICATION
29
29
from wlsdeploy .aliases .model_constants import DEPLOYMENT_ORDER
30
30
from wlsdeploy .aliases .model_constants import LIBRARY
31
+ from wlsdeploy .aliases .model_constants import MODULE_TYPE
31
32
from wlsdeploy .aliases .model_constants import PARTITION
32
33
from wlsdeploy .aliases .model_constants import PLAN_DIR
33
34
from wlsdeploy .aliases .model_constants import PLAN_PATH
38
39
from wlsdeploy .aliases .model_constants import SECURITY_DD_MODEL
39
40
from wlsdeploy .aliases .model_constants import SOURCE_PATH
40
41
from wlsdeploy .aliases .model_constants import STAGE_MODE
42
+ from wlsdeploy .aliases .model_constants import SUB_DEPLOYMENT
43
+ from wlsdeploy .aliases .model_constants import SUB_MODULE_TARGETS
41
44
from wlsdeploy .aliases .model_constants import TARGET
42
45
from wlsdeploy .aliases .model_constants import TARGETS
43
46
from wlsdeploy .aliases .wlst_modes import WlstModes
48
51
from wlsdeploy .util import dictionary_utils
49
52
from wlsdeploy .util import model_helper
50
53
from wlsdeploy .util import string_utils
54
+ from wlsdeploy .tool .util import appmodule_helper
55
+
56
+ import wlsdeploy .util .variables as variables
51
57
52
58
53
59
class ApplicationsDeployer (Deployer ):
@@ -192,17 +198,23 @@ def __add_applications(self):
192
198
self .logger .throwing (ex , class_name = self ._class_name , method_name = _method_name )
193
199
raise ex
194
200
201
+ module_type = dictionary_utils .get_element (application , MODULE_TYPE )
195
202
196
203
application_name = \
197
- self .version_helper .get_application_versioned_name (app_source_path , application_name )
204
+ self .version_helper .get_application_versioned_name (app_source_path , application_name ,
205
+ module_type = module_type )
198
206
199
207
quoted_application_name = self .wlst_helper .get_quoted_name_for_wlst (application_name )
208
+
200
209
application_location .add_name_token (application_token , quoted_application_name )
201
210
202
211
self .wlst_helper .cd (root_path )
203
212
deployer_utils .create_and_cd (application_location , existing_applications , self .aliases )
213
+
204
214
self ._set_attributes_and_add_subfolders (application_location , application )
215
+
205
216
application_location .remove_name_token (application_token )
217
+ self .__substitute_appmodule_token (app_source_path , module_type )
206
218
207
219
if app_source_path .startswith (WLSDeployArchive .ARCHIVE_STRUCT_APPS_TARGET_DIR ):
208
220
plan_dir = dictionary_utils .get_element (application , PLAN_DIR )
@@ -211,6 +223,34 @@ def __add_applications(self):
211
223
212
224
self .logger .exiting (class_name = self ._class_name , method_name = _method_name )
213
225
226
+ def __substitute_appmodule_token (self , path , module_type ):
227
+ # we need to substitute any token in the app module xml file
228
+ if self .version_helper .is_module_type_app_module (module_type ):
229
+ if os .path .isabs (path ):
230
+ abspath = path
231
+ else :
232
+ abspath = self .model_context .get_domain_home () + os .sep + path
233
+
234
+ original_variables = {}
235
+ variable_file = self .model_context .get_variable_file ()
236
+ if variable_file is not None and os .path .exists (variable_file ):
237
+ original_variables = variables .load_variables (variable_file )
238
+
239
+ fh = open (abspath , 'r' )
240
+ text = fh .read ()
241
+ fh .close ()
242
+ newtext = variables .substitute_value (text , original_variables , self .model_context )
243
+ # only jdbc and jms for now
244
+ if module_type == 'jdbc' :
245
+ newtext = appmodule_helper .process_jdbc_appmodule_xml (newtext , self .model_context )
246
+ elif module_type == 'jms' :
247
+ newtext = appmodule_helper .process_jms_appmodule_xml (newtext , self .model_context )
248
+
249
+ newfh = open (abspath , 'w' )
250
+ newfh .write (newtext )
251
+ newfh .close ()
252
+
253
+
214
254
def __online_deploy_apps_and_libs (self , base_location ):
215
255
"""
216
256
Deploy shared libraries and applications in online mode.
@@ -937,7 +977,8 @@ def __deploy_model_libraries(self, model_libs, lib_location):
937
977
plan_file = dictionary_utils .get_element (lib_dict , PLAN_PATH )
938
978
targets = dictionary_utils .get_element (lib_dict , TARGET )
939
979
stage_mode = dictionary_utils .get_element (lib_dict , STAGE_MODE )
940
- options = _get_deploy_options (model_libs , lib_name , library_module = 'true' )
980
+ options , sub_module_targets = _get_deploy_options (model_libs , lib_name , library_module = 'true' ,
981
+ application_version_helper = self .version_helper )
941
982
for uses_path_tokens_attribute_name in uses_path_tokens_attribute_names :
942
983
if uses_path_tokens_attribute_name in lib_dict :
943
984
path = lib_dict [uses_path_tokens_attribute_name ]
@@ -965,7 +1006,8 @@ def __deploy_model_applications(self, model_apps, app_location, deployed_applist
965
1006
plan_file = dictionary_utils .get_element (app_dict , PLAN_PATH )
966
1007
stage_mode = dictionary_utils .get_element (app_dict , STAGE_MODE )
967
1008
targets = dictionary_utils .get_element (app_dict , TARGET )
968
- options = _get_deploy_options (model_apps , app_name , library_module = 'false' )
1009
+ options , sub_module_targets = _get_deploy_options (model_apps , app_name , library_module = 'false' ,
1010
+ application_version_helper = self .version_helper )
969
1011
970
1012
# any attribute with 'uses_path_tokens' may be in the archive (such as SourcePath)
971
1013
for uses_path_tokens_attribute_name in uses_path_tokens_attribute_names :
@@ -977,13 +1019,19 @@ def __deploy_model_applications(self, model_apps, app_location, deployed_applist
977
1019
resource_group_template_name , resource_group_name , partition_name = \
978
1020
self .__get_mt_names_from_location (location )
979
1021
1022
+ module_type = dictionary_utils .get_element (app_dict , MODULE_TYPE )
1023
+
980
1024
new_app_name = self .__deploy_app_online (app_name , src_path , targets , plan = plan_file ,
981
1025
stage_mode = stage_mode , partition = partition_name ,
982
1026
resource_group = resource_group_name ,
983
1027
resource_group_template = resource_group_template_name ,
1028
+ module_type = module_type ,
1029
+ sub_module_targets = sub_module_targets ,
984
1030
options = options )
985
1031
location .remove_name_token (token_name )
986
1032
deployed_applist .append (new_app_name )
1033
+ self .__substitute_appmodule_token (path , module_type )
1034
+
987
1035
988
1036
def __get_mt_names_from_location (self , app_location ):
989
1037
dummy_location = LocationContext ()
@@ -1007,7 +1055,8 @@ def __get_mt_names_from_location(self, app_location):
1007
1055
return resource_group_template_name , resource_group_name , partition_name
1008
1056
1009
1057
def __deploy_app_online (self , application_name , source_path , targets , stage_mode = None , plan = None , partition = None ,
1010
- resource_group = None , resource_group_template = None , options = None ):
1058
+ resource_group = None , resource_group_template = None , sub_module_targets = None ,
1059
+ module_type = None , options = None ):
1011
1060
"""
1012
1061
Deploy an application or shared library in online mode.
1013
1062
:param application_name: the name of the app or library from the model
@@ -1050,7 +1099,8 @@ def __deploy_app_online(self, application_name, source_path, targets, stage_mode
1050
1099
if is_library :
1051
1100
computed_name = self .version_helper .get_library_versioned_name (source_path , application_name )
1052
1101
else :
1053
- computed_name = self .version_helper .get_application_versioned_name (source_path , application_name )
1102
+ computed_name = self .version_helper .get_application_versioned_name (source_path , application_name ,
1103
+ module_type = module_type )
1054
1104
1055
1105
application_name = computed_name
1056
1106
@@ -1079,6 +1129,9 @@ def __deploy_app_online(self, application_name, source_path, targets, stage_mode
1079
1129
kwargs [key ] = value
1080
1130
kwargs ['timeout' ] = self .model_context .get_model_config ().get_deploy_timeout ()
1081
1131
1132
+ if self .version_helper .is_module_type_app_module (module_type ) and sub_module_targets is not None :
1133
+ kwargs [SUB_MODULE_TARGETS ] = sub_module_targets
1134
+
1082
1135
self .logger .fine ('WLSDPLY-09320' , type_name , application_name , kwargs ,
1083
1136
class_name = self ._class_name , method_name = _method_name )
1084
1137
self .wlst_helper .deploy_application (application_name , * args , ** kwargs )
@@ -1093,7 +1146,6 @@ def __extract_source_path_from_archive(self, source_path, model_type, model_name
1093
1146
:param model_name: the element name (my-app, etc.), used for logging
1094
1147
"""
1095
1148
_method_name = '__extract_source_path_from_archive'
1096
-
1097
1149
# source path may be may be a single file (jar, war, etc.)
1098
1150
if self .archive_helper .contains_file (source_path ):
1099
1151
self .archive_helper .extract_file (source_path )
@@ -1192,7 +1244,7 @@ def __start_all_apps(self, deployed_app_list, base_location):
1192
1244
self .__start_app (app )
1193
1245
1194
1246
1195
- def _get_deploy_options (model_apps , app_name , library_module ):
1247
+ def _get_deploy_options (model_apps , app_name , library_module , application_version_helper ):
1196
1248
"""
1197
1249
Get the deploy command options.
1198
1250
:param model_apps: the apps dictionary
@@ -1202,8 +1254,8 @@ def _get_deploy_options(model_apps, app_name, library_module):
1202
1254
"""
1203
1255
deploy_options = OrderedDict ()
1204
1256
# not sure about altDD, altWlsDD
1257
+ app = dictionary_utils .get_dictionary_element (model_apps , app_name )
1205
1258
for option in [DEPLOYMENT_ORDER , SECURITY_DD_MODEL , PLAN_STAGING_MODE , STAGE_MODE ]:
1206
- app = dictionary_utils .get_dictionary_element (model_apps , app_name )
1207
1259
value = dictionary_utils .get_element (app , option )
1208
1260
1209
1261
option_name = ''
@@ -1224,8 +1276,21 @@ def _get_deploy_options(model_apps, app_name, library_module):
1224
1276
1225
1277
if len (deploy_options ) == 0 :
1226
1278
deploy_options = None
1227
- return deploy_options
1228
1279
1280
+ module_type = dictionary_utils .get_element (app , MODULE_TYPE )
1281
+ sub_module_targets = ''
1282
+ if application_version_helper .is_module_type_app_module (module_type ):
1283
+ sub_deployments = dictionary_utils .get_element (app , SUB_DEPLOYMENT )
1284
+ if sub_deployments is not None :
1285
+ for sub_deployment in sub_deployments :
1286
+ if sub_module_targets != '' :
1287
+ sub_module_targets += ','
1288
+ name = sub_deployment
1289
+ target = sub_deployments [name ][TARGET ]
1290
+ sub_module_targets += '%s@%s' % (name , target )
1291
+
1292
+
1293
+ return deploy_options , sub_module_targets
1229
1294
1230
1295
def _find_deployorder_list (apps_dict , ordered_list , order ):
1231
1296
"""
0 commit comments