1414from wlsdeploy .aliases .model_constants import SERVER_TEMPLATE
1515from wlsdeploy .aliases .model_constants import UNIX_MACHINE
1616from wlsdeploy .aliases .wlst_modes import WlstModes
17+ from wlsdeploy .exception import exception_helper
1718from wlsdeploy .exception .expection_types import ExceptionType
1819from wlsdeploy .tool .create .security_provider_creator import SecurityProviderCreator
1920from wlsdeploy .tool .deploy import deployer_utils
@@ -34,16 +35,17 @@ def __init__(self, model, model_context, aliases, wlst_mode=WlstModes.OFFLINE):
3435 Deployer .__init__ (self , model , model_context , aliases , wlst_mode )
3536 self ._topology = self .model .get_model_topology ()
3637 self ._resources = self .model .get_model_resources ()
37- self ._topology_helper = TopologyHelper (self .aliases , ExceptionType .DEPLOY , self .logger )
38+ self ._exception_type = ExceptionType .DEPLOY
39+ self ._topology_helper = TopologyHelper (self .aliases , self ._exception_type , self .logger )
3840 self ._domain_typedef = self .model_context .get_domain_typedef ()
3941
4042 self ._security_provider_creator = SecurityProviderCreator (model .get_model (), model_context , aliases ,
41- ExceptionType . DEPLOY , self .logger )
43+ self . _exception_type , self .logger )
4244
4345 self .library_helper = LibraryHelper (self .model , self .model_context , self .aliases ,
44- model_context .get_domain_home (), ExceptionType . DEPLOY , self .logger )
46+ model_context .get_domain_home (), self . _exception_type , self .logger )
4547
46- self .target_helper = TargetHelper (self .model , self .model_context , self .aliases , ExceptionType . DEPLOY ,
48+ self .target_helper = TargetHelper (self .model , self .model_context , self .aliases , self . _exception_type ,
4749 self .logger )
4850
4951 # Override
@@ -72,7 +74,11 @@ def update(self):
7274 """
7375 Deploy resource model elements at the domain level, including multi-tenant elements.
7476 """
77+ # For issue in setServerGroups in online mode (new configured clusters and stand-alone managed servers
78+ # will not have extension template resources targeted)
79+ existing_managed_servers , existing_configured_clusters = self ._create_list_of_setservergroups_targets ()
7580 domain_token = deployer_utils .get_domain_token (self .alias_helper )
81+
7682 location = LocationContext ()
7783 location .add_name_token (domain_token , self .model_context .get_domain_name ())
7884
@@ -104,24 +110,33 @@ def update(self):
104110 # create placeholders for Servers that are in a cluster as /Server/JTAMigratableTarget
105111 # can reference "other" servers
106112 self ._topology_helper .create_placeholder_servers_in_cluster (self ._topology )
113+
107114 self ._process_section (self ._topology , folder_list , SERVER , location )
108115
109116 self ._process_section (self ._topology , folder_list , MIGRATABLE_TARGET , location )
110117
118+ new_managed_server_list , new_configured_cluster_list = self ._create_list_of_setservergroups_targets ()
119+
120+ self ._check_for_online_setservergroups_issue (existing_managed_servers , new_managed_server_list )
121+ self ._check_for_online_setservergroups_issue (existing_configured_clusters , new_configured_cluster_list )
122+
111123 # process remaining top-level folders. copy list to avoid concurrent update in loop
112124 remaining = list (folder_list )
113125 for folder_name in remaining :
114126 self ._process_section (self ._topology , folder_list , folder_name , location )
115127
116128 if self .wls_helper .is_set_server_groups_supported ():
117129 server_groups_to_target = self ._domain_typedef .get_server_groups_to_target ()
118- self .target_helper .target_server_groups_to_servers (server_groups_to_target )
119- elif self ._domain_typedef .domain_type_has_jrf_resources ():
120- deployer_utils .save_changes (self .model_context )
121- self .target_helper .target_jrf_groups_to_clusters_servers (self .model_context .get_domain_home ())
122- deployer_utils .read_again (self .model_context )
123-
124- # files referenced in attributes are extracted as attributes are processed
130+ server_assigns , dynamic_assigns = \
131+ self .target_helper .target_server_groups_to_servers (server_groups_to_target )
132+ if dynamic_assigns is not None :
133+ self .wlst_helper .save_and_close (self .model_context )
134+ self .target_helper .target_server_groups_to_dynamic_clusters (dynamic_assigns )
135+ self .wlst_helper .reopen (self .model_context )
136+ if server_assigns is not None :
137+ self .target_helper .target_server_groups (server_assigns )
138+ elif self ._domain_typedef .is_jrf_domain_type ():
139+ self .target_helper .target_jrf_groups_to_clusters_servers ()
125140
126141 self .library_helper .install_domain_libraries ()
127142 self .library_helper .extract_classpath_libraries ()
@@ -153,3 +168,67 @@ def _set_domain_attributes(self):
153168 attribute_path = self .alias_helper .get_wlst_attributes_path (location )
154169 self .wlst_helper .cd (attribute_path )
155170 self .set_attributes (location , attrib_dict )
171+
172+ def is_online_with_ext_templates (self ):
173+ return self .model_context .is_wlst_online () and self .model_context .get_domain_typedef ().has_extension_templates ()
174+
175+ def _check_for_online_setservergroups_issue (self , existing_list , new_list ):
176+ _method_name = '_check_for_online_setservergroups_issue'
177+ if len (existing_list ) != len (new_list ):
178+ for entity_name in new_list :
179+ if entity_name not in existing_list :
180+ self .logger .warning ('WLSDPLY-09701' , entity_name ,
181+ class_name = self ._class_name , method_name = _method_name )
182+ return
183+
184+ def _create_list_of_setservergroups_targets (self ):
185+ """
186+ If an update is executed in online WLST mode, return a list of all existing configured / mixed clusters and
187+ stand-alone managed servers. This method will be invoked to create a list of existing, and a list of new
188+ as added by the update tool. These lists will be compared to determine if they will encounter
189+ the online WLST problem with setServerGroups. The setServerGroups will target template resources to the
190+ new entities, but this targeting is not persisted to the config.xml.
191+ """
192+ _method_name = '_create_list_of_setservergroups_targets'
193+ self .logger .entering (class_name = self ._class_name , method_name = _method_name )
194+
195+ if not self .is_online_with_ext_templates ():
196+ self .logger .exiting (class_name = self ._class_name , method_name = _method_name )
197+ return list (), list ()
198+
199+ location = LocationContext ().append_location (SERVER )
200+ server_path = self .alias_helper .get_wlst_list_path (location )
201+ existing_managed_servers = list ()
202+ existing_servers = self .wlst_helper .get_existing_object_list (server_path )
203+ if existing_servers is not None :
204+ name_token = self .alias_helper .get_name_token (location )
205+ for server_name in existing_servers :
206+ location .add_name_token (name_token , server_name )
207+ wlst_path = self .alias_helper .get_wlst_attributes_path (location )
208+ self .wlst_helper .cd (wlst_path )
209+ cluster_attribute = self .alias_helper .get_wlst_attribute_name (location , CLUSTER )
210+ cluster_value = self .wlst_helper .get (cluster_attribute )
211+ if cluster_value is None :
212+ existing_managed_servers .append (server_name )
213+ location .remove_name_token (name_token )
214+
215+ existing_configured_clusters = list ()
216+ location = LocationContext ().append_location (CLUSTER )
217+ cluster_path = self .alias_helper .get_wlst_list_path (location )
218+ existing_clusters = self .wlst_helper .get_existing_object_list (cluster_path )
219+ if existing_clusters is not None :
220+ name_token = self .alias_helper .get_name_token (location )
221+ for cluster_name in existing_clusters :
222+ location .add_name_token (name_token , cluster_name )
223+ wlst_path = self .alias_helper .get_wlst_attributes_path (location )
224+ self .wlst_helper .cd (wlst_path )
225+ ds_mbean = self .alias_helper .get_wlst_mbean_type (location )
226+ if not self .wlst_helper .subfolder_exists (ds_mbean ,
227+ self .alias_helper .get_wlst_subfolders_path (location )):
228+ existing_configured_clusters .append (cluster_name )
229+ location .remove_name_token (name_token )
230+
231+ self .logger .exiting (class_name = self ._class_name , method_name = _method_name ,
232+ result = 'configured_clusters=' + str (existing_configured_clusters ) +
233+ ' managed servers=' + str (existing_managed_servers ))
234+ return existing_configured_clusters , existing_managed_servers
0 commit comments