From 95ff61545fff5d4a06fa901dc07e61875cee32db Mon Sep 17 00:00:00 2001 From: crountre Date: Wed, 4 Nov 2020 11:34:55 -0600 Subject: [PATCH 1/3] Restore cluster dynamic size after setServerGroups reset value --- .../wlsdeploy/tool/util/target_helper.py | 49 +++++++++++++++++++ .../deploy/messages/wlsdeploy_rb.properties | 2 + 2 files changed, 51 insertions(+) diff --git a/core/src/main/python/wlsdeploy/tool/util/target_helper.py b/core/src/main/python/wlsdeploy/tool/util/target_helper.py index d2ca459b4..63813ad18 100644 --- a/core/src/main/python/wlsdeploy/tool/util/target_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/target_helper.py @@ -12,6 +12,7 @@ from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME from wlsdeploy.aliases.model_constants import CLUSTER from wlsdeploy.aliases.model_constants import DYNAMIC_CLUSTER_SERVER_GROUP_TARGETING_LIMITS +from wlsdeploy.aliases.model_constants import DYNAMIC_CLUSTER_SIZE from wlsdeploy.aliases.model_constants import DYNAMIC_SERVERS from wlsdeploy.aliases.model_constants import DEFAULT_ADMIN_SERVER_NAME from wlsdeploy.aliases.model_constants import MODEL_LIST_DELIMITER @@ -248,9 +249,13 @@ def target_dynamic_server_groups(self, dynamic_cluster_assigns): if len(dynamic_cluster_assigns) > 0: # assign server group resources to cluster based on the version of WebLogic server version. if self.wls_helper.is_dynamic_cluster_server_groups_supported(): + bug_map = self.save_dyn_size(dynamic_cluster_assigns) self.target_server_groups(dynamic_cluster_assigns) + self.restore_dyn_size(bug_map) elif self.wls_helper.is_dynamic_cluster_server_group_supported(): + bug_map = self.save_dyn_size(dynamic_cluster_assigns) self.target_dynamic_clusters(dynamic_cluster_assigns) + self.restore_dyn_size(bug_map) else: self.logger.warning('WLSDPLY-12238', domain_typedef.get_domain_type(), class_name=self.__class_name, method_name=_method_name) @@ -571,3 +576,47 @@ def __get_server_groups_for_entity(self, entity_name, sg_targeting_limits): self.logger.fine('WLSDPLY-12243', entity_name, result, class_name=self.__class_name, method_name=_method_name) return result + + def save_dyn_size(self, cluster_map): + """ + Collect the before attribute of dynamic cluster size for each dynamic cluster. When + setting dynamic clusters to server groups, the parameter dynamic cluster size is reset + based on the parameters in the template server group WSM-CACHE-DYN-CLUSTER. A bug + was opened 32075458, but probably will be seen as not a bug. + :param cluster_map: cluster, server groups map + :return: map of cluster and attribute_value + """ + _method_name = 'save_dyn_size' + bug_map = dict() + for cluster in cluster_map.iterkeys(): + wlst_attribute = self.__locate_dynamic_attribute(cluster) + bug_map[cluster] = self.wlst_helper.get(wlst_attribute) + self.logger.finer('WLSDPLY-12559', cluster, bug_map[cluster], + class_name=self.__class_name, method_name=_method_name) + return bug_map + + def restore_dyn_size(self, bug_map): + """ + The setServerGroups reset the dynamic cluster size. Reset to original value. + :param bug_map: map with cluster, dynamic cluster size + """ + _method_name = 'restore_dyn_size' + for cluster, attribute_value in bug_map.iteritems(): + if attribute_value is not None: + wlst_attribute = self.__locate_dynamic_attribute(cluster) + self.wlst_helper.set(wlst_attribute, attribute_value) + self.logger.finer('WLSDPLY-12560', cluster, wlst_attribute, + class_name=self.__class_name, method_name=_method_name) + + def __locate_dynamic_attribute(self, cluster): + location = LocationContext() + location.append_location(CLUSTER) + location.add_name_token(self.aliases.get_name_token(location), cluster) + location.append_location(DYNAMIC_SERVERS) + list_path = self.aliases.get_wlst_list_path(location) + existing_names = self.wlst_helper.get_existing_object_list(list_path) + location.add_name_token(self.aliases.get_name_token(location), existing_names[0]) + attributes_path = self.aliases.get_wlst_attributes_path(location) + self.wlst_helper.cd(attributes_path) + wlst_attribute = self.aliases.get_wlst_attribute_name(location, DYNAMIC_CLUSTER_SIZE) + return wlst_attribute diff --git a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties index 8fc818766..12968fa09 100644 --- a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties +++ b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties @@ -1281,6 +1281,8 @@ WLSDPLY-12257=No server group found for dynamic cluster {0}. Versions of WebLogi do not support targeting more than one server group to a dynamic cluster. Server group not defined in domain typedef WLSDPLY-12258=RCU {0} file {1} is invalid : {2} WLSDPLY-12259=Error creating directory {0} to extract RCU {1} file {2} +WLSDPLY-12560=Dynamic cluster {0} has size of {1} +WLSDPLY-12561=Dynamic cluster {0} set to size of {1} # domain_typedef.py WLSDPLY-12300={0} got the domain type {1} but the domain type definition file {2} was not valid: {3} From 14bce54cc723e17ea51622c1468b72afc944e21e Mon Sep 17 00:00:00 2001 From: crountre Date: Wed, 4 Nov 2020 11:59:40 -0600 Subject: [PATCH 2/3] Restore cluster dynamic size after setServerGroups reset value --- core/src/main/python/wlsdeploy/tool/util/target_helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/python/wlsdeploy/tool/util/target_helper.py b/core/src/main/python/wlsdeploy/tool/util/target_helper.py index 63813ad18..f5665cbb6 100644 --- a/core/src/main/python/wlsdeploy/tool/util/target_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/target_helper.py @@ -591,7 +591,7 @@ def save_dyn_size(self, cluster_map): for cluster in cluster_map.iterkeys(): wlst_attribute = self.__locate_dynamic_attribute(cluster) bug_map[cluster] = self.wlst_helper.get(wlst_attribute) - self.logger.finer('WLSDPLY-12559', cluster, bug_map[cluster], + self.logger.finer('WLSDPLY-12560', cluster, bug_map[cluster], class_name=self.__class_name, method_name=_method_name) return bug_map @@ -605,7 +605,7 @@ def restore_dyn_size(self, bug_map): if attribute_value is not None: wlst_attribute = self.__locate_dynamic_attribute(cluster) self.wlst_helper.set(wlst_attribute, attribute_value) - self.logger.finer('WLSDPLY-12560', cluster, wlst_attribute, + self.logger.finer('WLSDPLY-12561', cluster, wlst_attribute, class_name=self.__class_name, method_name=_method_name) def __locate_dynamic_attribute(self, cluster): From 27075bab502370029f374d90ebee9d40c8848703 Mon Sep 17 00:00:00 2001 From: crountre Date: Wed, 4 Nov 2020 14:00:56 -0600 Subject: [PATCH 3/3] Restore cluster dynamic size after setServerGroups reset value --- .../python/wlsdeploy/tool/util/target_helper.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/src/main/python/wlsdeploy/tool/util/target_helper.py b/core/src/main/python/wlsdeploy/tool/util/target_helper.py index f5665cbb6..9fa4e8bcf 100644 --- a/core/src/main/python/wlsdeploy/tool/util/target_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/target_helper.py @@ -6,6 +6,8 @@ import copy import oracle.weblogic.deploy.util.PyOrderedDict as OrderedDict +from oracle.weblogic.deploy.exception import BundleAwareException + import wlsdeploy.util.dictionary_utils as dictionary_utils from wlsdeploy.aliases.location_context import LocationContext @@ -601,6 +603,7 @@ def restore_dyn_size(self, bug_map): :param bug_map: map with cluster, dynamic cluster size """ _method_name = 'restore_dyn_size' + self.__put_back_in_edit() for cluster, attribute_value in bug_map.iteritems(): if attribute_value is not None: wlst_attribute = self.__locate_dynamic_attribute(cluster) @@ -608,7 +611,19 @@ def restore_dyn_size(self, bug_map): self.logger.finer('WLSDPLY-12561', cluster, wlst_attribute, class_name=self.__class_name, method_name=_method_name) + def __put_back_in_edit(self): + """ + setServerGroups throws you out of edit. Put it back in. + """ + if self.model_context.is_wlst_online(): + try: + self.wlst_helper.edit() + self.wlst_helper.start_edit() + except BundleAwareException, ex: + raise ex + def __locate_dynamic_attribute(self, cluster): + location = LocationContext() location.append_location(CLUSTER) location.add_name_token(self.aliases.get_name_token(location), cluster)