|
6 | 6 | import copy
|
7 | 7 |
|
8 | 8 | import oracle.weblogic.deploy.util.PyOrderedDict as OrderedDict
|
| 9 | +from oracle.weblogic.deploy.exception import BundleAwareException |
| 10 | + |
9 | 11 | import wlsdeploy.util.dictionary_utils as dictionary_utils
|
10 | 12 |
|
11 | 13 | from wlsdeploy.aliases.location_context import LocationContext
|
12 | 14 | from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME
|
13 | 15 | from wlsdeploy.aliases.model_constants import CLUSTER
|
14 | 16 | from wlsdeploy.aliases.model_constants import DYNAMIC_CLUSTER_SERVER_GROUP_TARGETING_LIMITS
|
| 17 | +from wlsdeploy.aliases.model_constants import DYNAMIC_CLUSTER_SIZE |
15 | 18 | from wlsdeploy.aliases.model_constants import DYNAMIC_SERVERS
|
16 | 19 | from wlsdeploy.aliases.model_constants import DEFAULT_ADMIN_SERVER_NAME
|
17 | 20 | from wlsdeploy.aliases.model_constants import MODEL_LIST_DELIMITER
|
@@ -248,9 +251,13 @@ def target_dynamic_server_groups(self, dynamic_cluster_assigns):
|
248 | 251 | if len(dynamic_cluster_assigns) > 0:
|
249 | 252 | # assign server group resources to cluster based on the version of WebLogic server version.
|
250 | 253 | if self.wls_helper.is_dynamic_cluster_server_groups_supported():
|
| 254 | + bug_map = self.save_dyn_size(dynamic_cluster_assigns) |
251 | 255 | self.target_server_groups(dynamic_cluster_assigns)
|
| 256 | + self.restore_dyn_size(bug_map) |
252 | 257 | elif self.wls_helper.is_dynamic_cluster_server_group_supported():
|
| 258 | + bug_map = self.save_dyn_size(dynamic_cluster_assigns) |
253 | 259 | self.target_dynamic_clusters(dynamic_cluster_assigns)
|
| 260 | + self.restore_dyn_size(bug_map) |
254 | 261 | else:
|
255 | 262 | self.logger.warning('WLSDPLY-12238', domain_typedef.get_domain_type(),
|
256 | 263 | class_name=self.__class_name, method_name=_method_name)
|
@@ -571,3 +578,60 @@ def __get_server_groups_for_entity(self, entity_name, sg_targeting_limits):
|
571 | 578 | self.logger.fine('WLSDPLY-12243', entity_name, result, class_name=self.__class_name,
|
572 | 579 | method_name=_method_name)
|
573 | 580 | return result
|
| 581 | + |
| 582 | + def save_dyn_size(self, cluster_map): |
| 583 | + """ |
| 584 | + Collect the before attribute of dynamic cluster size for each dynamic cluster. When |
| 585 | + setting dynamic clusters to server groups, the parameter dynamic cluster size is reset |
| 586 | + based on the parameters in the template server group WSM-CACHE-DYN-CLUSTER. A bug |
| 587 | + was opened 32075458, but probably will be seen as not a bug. |
| 588 | + :param cluster_map: cluster, server groups map |
| 589 | + :return: map of cluster and attribute_value |
| 590 | + """ |
| 591 | + _method_name = 'save_dyn_size' |
| 592 | + bug_map = dict() |
| 593 | + for cluster in cluster_map.iterkeys(): |
| 594 | + wlst_attribute = self.__locate_dynamic_attribute(cluster) |
| 595 | + bug_map[cluster] = self.wlst_helper.get(wlst_attribute) |
| 596 | + self.logger.finer('WLSDPLY-12560', cluster, bug_map[cluster], |
| 597 | + class_name=self.__class_name, method_name=_method_name) |
| 598 | + return bug_map |
| 599 | + |
| 600 | + def restore_dyn_size(self, bug_map): |
| 601 | + """ |
| 602 | + The setServerGroups reset the dynamic cluster size. Reset to original value. |
| 603 | + :param bug_map: map with cluster, dynamic cluster size |
| 604 | + """ |
| 605 | + _method_name = 'restore_dyn_size' |
| 606 | + self.__put_back_in_edit() |
| 607 | + for cluster, attribute_value in bug_map.iteritems(): |
| 608 | + if attribute_value is not None: |
| 609 | + wlst_attribute = self.__locate_dynamic_attribute(cluster) |
| 610 | + self.wlst_helper.set(wlst_attribute, attribute_value) |
| 611 | + self.logger.finer('WLSDPLY-12561', cluster, wlst_attribute, |
| 612 | + class_name=self.__class_name, method_name=_method_name) |
| 613 | + |
| 614 | + def __put_back_in_edit(self): |
| 615 | + """ |
| 616 | + setServerGroups throws you out of edit. Put it back in. |
| 617 | + """ |
| 618 | + if self.model_context.is_wlst_online(): |
| 619 | + try: |
| 620 | + self.wlst_helper.edit() |
| 621 | + self.wlst_helper.start_edit() |
| 622 | + except BundleAwareException, ex: |
| 623 | + raise ex |
| 624 | + |
| 625 | + def __locate_dynamic_attribute(self, cluster): |
| 626 | + |
| 627 | + location = LocationContext() |
| 628 | + location.append_location(CLUSTER) |
| 629 | + location.add_name_token(self.aliases.get_name_token(location), cluster) |
| 630 | + location.append_location(DYNAMIC_SERVERS) |
| 631 | + list_path = self.aliases.get_wlst_list_path(location) |
| 632 | + existing_names = self.wlst_helper.get_existing_object_list(list_path) |
| 633 | + location.add_name_token(self.aliases.get_name_token(location), existing_names[0]) |
| 634 | + attributes_path = self.aliases.get_wlst_attributes_path(location) |
| 635 | + self.wlst_helper.cd(attributes_path) |
| 636 | + wlst_attribute = self.aliases.get_wlst_attribute_name(location, DYNAMIC_CLUSTER_SIZE) |
| 637 | + return wlst_attribute |
0 commit comments