2828from wlsdeploy .aliases .model_constants import APPLICATION
2929from wlsdeploy .aliases .model_constants import DEPLOYMENT_ORDER
3030from wlsdeploy .aliases .model_constants import LIBRARY
31+ from wlsdeploy .aliases .model_constants import MODULE_TYPE
3132from wlsdeploy .aliases .model_constants import PARTITION
3233from wlsdeploy .aliases .model_constants import PLAN_DIR
3334from wlsdeploy .aliases .model_constants import PLAN_PATH
3839from wlsdeploy .aliases .model_constants import SECURITY_DD_MODEL
3940from wlsdeploy .aliases .model_constants import SOURCE_PATH
4041from 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
4144from wlsdeploy .aliases .model_constants import TARGET
4245from wlsdeploy .aliases .model_constants import TARGETS
4346from wlsdeploy .aliases .wlst_modes import WlstModes
4851from wlsdeploy .util import dictionary_utils
4952from wlsdeploy .util import model_helper
5053from wlsdeploy .util import string_utils
54+ from wlsdeploy .tool .util import appmodule_helper
55+ 56+ import wlsdeploy .util .variables as variables
5157
5258
5359class ApplicationsDeployer (Deployer ):
@@ -192,17 +198,23 @@ def __add_applications(self):
192198 self .logger .throwing (ex , class_name = self ._class_name , method_name = _method_name )
193199 raise ex
194200
201+ module_type = dictionary_utils .get_element (application , MODULE_TYPE )
195202
196203 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 )
198206
199207 quoted_application_name = self .wlst_helper .get_quoted_name_for_wlst (application_name )
208+ 200209 application_location .add_name_token (application_token , quoted_application_name )
201210
202211 self .wlst_helper .cd (root_path )
203212 deployer_utils .create_and_cd (application_location , existing_applications , self .aliases )
213+ 204214 self ._set_attributes_and_add_subfolders (application_location , application )
215+ 205216 application_location .remove_name_token (application_token )
217+ self .__substitute_appmodule_token (app_source_path , module_type )
206218
207219 if app_source_path .startswith (WLSDeployArchive .ARCHIVE_STRUCT_APPS_TARGET_DIR ):
208220 plan_dir = dictionary_utils .get_element (application , PLAN_DIR )
@@ -211,6 +223,34 @@ def __add_applications(self):
211223
212224 self .logger .exiting (class_name = self ._class_name , method_name = _method_name )
213225
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+ 214254 def __online_deploy_apps_and_libs (self , base_location ):
215255 """
216256 Deploy shared libraries and applications in online mode.
@@ -937,7 +977,8 @@ def __deploy_model_libraries(self, model_libs, lib_location):
937977 plan_file = dictionary_utils .get_element (lib_dict , PLAN_PATH )
938978 targets = dictionary_utils .get_element (lib_dict , TARGET )
939979 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 )
941982 for uses_path_tokens_attribute_name in uses_path_tokens_attribute_names :
942983 if uses_path_tokens_attribute_name in lib_dict :
943984 path = lib_dict [uses_path_tokens_attribute_name ]
@@ -965,7 +1006,8 @@ def __deploy_model_applications(self, model_apps, app_location, deployed_applist
9651006 plan_file = dictionary_utils .get_element (app_dict , PLAN_PATH )
9661007 stage_mode = dictionary_utils .get_element (app_dict , STAGE_MODE )
9671008 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 )
9691011
9701012 # any attribute with 'uses_path_tokens' may be in the archive (such as SourcePath)
9711013 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
9771019 resource_group_template_name , resource_group_name , partition_name = \
9781020 self .__get_mt_names_from_location (location )
9791021
1022+ module_type = dictionary_utils .get_element (app_dict , MODULE_TYPE )
1023+ 9801024 new_app_name = self .__deploy_app_online (app_name , src_path , targets , plan = plan_file ,
9811025 stage_mode = stage_mode , partition = partition_name ,
9821026 resource_group = resource_group_name ,
9831027 resource_group_template = resource_group_template_name ,
1028+ module_type = module_type ,
1029+ sub_module_targets = sub_module_targets ,
9841030 options = options )
9851031 location .remove_name_token (token_name )
9861032 deployed_applist .append (new_app_name )
1033+ self .__substitute_appmodule_token (path , module_type )
1034+ 9871035
9881036 def __get_mt_names_from_location (self , app_location ):
9891037 dummy_location = LocationContext ()
@@ -1007,7 +1055,8 @@ def __get_mt_names_from_location(self, app_location):
10071055 return resource_group_template_name , resource_group_name , partition_name
10081056
10091057 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 ):
10111060 """
10121061 Deploy an application or shared library in online mode.
10131062 :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
10501099 if is_library :
10511100 computed_name = self .version_helper .get_library_versioned_name (source_path , application_name )
10521101 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 )
10541104
10551105 application_name = computed_name
10561106
@@ -1079,6 +1129,9 @@ def __deploy_app_online(self, application_name, source_path, targets, stage_mode
10791129 kwargs [key ] = value
10801130 kwargs ['timeout' ] = self .model_context .get_model_config ().get_deploy_timeout ()
10811131
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+ 10821135 self .logger .fine ('WLSDPLY-09320' , type_name , application_name , kwargs ,
10831136 class_name = self ._class_name , method_name = _method_name )
10841137 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
10931146 :param model_name: the element name (my-app, etc.), used for logging
10941147 """
10951148 _method_name = '__extract_source_path_from_archive'
1096- 10971149 # source path may be may be a single file (jar, war, etc.)
10981150 if self .archive_helper .contains_file (source_path ):
10991151 self .archive_helper .extract_file (source_path )
@@ -1192,7 +1244,7 @@ def __start_all_apps(self, deployed_app_list, base_location):
11921244 self .__start_app (app )
11931245
11941246
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 ):
11961248 """
11971249 Get the deploy command options.
11981250 :param model_apps: the apps dictionary
@@ -1202,8 +1254,8 @@ def _get_deploy_options(model_apps, app_name, library_module):
12021254 """
12031255 deploy_options = OrderedDict ()
12041256 # not sure about altDD, altWlsDD
1257+ app = dictionary_utils .get_dictionary_element (model_apps , app_name )
12051258 for option in [DEPLOYMENT_ORDER , SECURITY_DD_MODEL , PLAN_STAGING_MODE , STAGE_MODE ]:
1206- app = dictionary_utils .get_dictionary_element (model_apps , app_name )
12071259 value = dictionary_utils .get_element (app , option )
12081260
12091261 option_name = ''
@@ -1224,8 +1276,21 @@ def _get_deploy_options(model_apps, app_name, library_module):
12241276
12251277 if len (deploy_options ) == 0 :
12261278 deploy_options = None
1227- return deploy_options
12281279
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
12291294
12301295def _find_deployorder_list (apps_dict , ordered_list , order ):
12311296 """
0 commit comments