Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/main/python/wlsdeploy/aliases/model_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
MAIL_SESSION = 'MailSession'
MAIL_SESSION_OVERRIDE = 'MailSessionOverride'
MAIL_SESSION_PROPERTIES = 'Properties'
MAX_DYNAMIC_SERVER_COUNT = 'MaximumDynamicServerCount'
MAX_THREADS_CONSTRAINT = 'MaxThreadsConstraint'
MIGRATABLE_TARGET = 'MigratableTarget'
MIN_THREADS_CONSTRAINT = 'MinThreadsConstraint'
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/python/wlsdeploy/tool/deploy/deployer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from wlsdeploy.aliases.model_constants import JDBC_DRIVER_PARAMS
from wlsdeploy.aliases.model_constants import JDBC_RESOURCE
from wlsdeploy.aliases.model_constants import JDBC_SYSTEM_RESOURCE
from wlsdeploy.aliases.model_constants import MAX_DYNAMIC_SERVER_COUNT
from wlsdeploy.aliases.model_constants import SERVER
from wlsdeploy.aliases.model_constants import SERVER_NAME_PREFIX
from wlsdeploy.aliases.model_constants import SERVER_NAME_START_IDX
Expand Down Expand Up @@ -570,7 +571,11 @@ def check_if_dynamic_cluster(server_name, cluster_name, aliases):
_wlst_helper.cd(attr_path)
except DeployException:
return False
attr_name = aliases.get_wlst_attribute_name(location, DYNAMIC_CLUSTER_SIZE)
present, __ = aliases.is_valid_model_attribute_name(location, DYNAMIC_CLUSTER_SIZE)
if present == ValidationCodes.VALID:
attr_name = aliases.get_wlst_attribute_name(location, DYNAMIC_CLUSTER_SIZE)
else:
attr_name = aliases.get_wlst_attribute_name(location, MAX_DYNAMIC_SERVER_COUNT)
dynamic_size = _wlst_helper.get(attr_name)
attr_name = aliases.get_wlst_attribute_name(location, SERVER_NAME_PREFIX)
prefix = _wlst_helper.get(attr_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,16 @@ def _dynamic_server(self, server, location):
if self._wlst_helper.path_exists(wlst_path):
_logger.fine('WLSDPLY-06613', server, class_name=_class_name, method_name=_method_name)
self._wlst_helper.cd(wlst_path)
attr_name = self._aliases.get_wlst_attribute_name(cluster_location,
model_constants.DYNAMIC_CLUSTER_SIZE)
present, __ = self._aliases.is_valid_model_attribute_name(location,
model_constants.DYNAMIC_CLUSTER_SIZE)
if present == ValidationCodes.VALID:
attr_name = self._aliases.get_wlst_attribute_name(cluster_location,
model_constants.DYNAMIC_CLUSTER_SIZE)
else:
attr_name = self._aliases.get_wlst_attribute_name(cluster_location,
model_constants.MAX_DYNAMIC_SERVER_COUNT)
dynamic_size = self._wlst_helper.get(attr_name)

attr_name = self._aliases.get_wlst_attribute_name(cluster_location,
model_constants.SERVER_NAME_PREFIX)
prefix = self._wlst_helper.get(attr_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ def _update_resource_dictionary(self, resource_dict):
cluster_list = list()
spec_section[CLUSTERS] = cluster_list
for cluster_name, cluster_values in model_clusters.items():
server_count = k8s_helper.get_server_count(cluster_name, cluster_values, self._model.get_model())
server_count = k8s_helper.get_server_count(cluster_name, cluster_values, self._model.get_model(),
self._aliases)
cluster_dict = PyOrderedDict()
cluster_dict[CLUSTER_NAME] = cluster_name
cluster_dict[REPLICAS] = server_count
Expand Down
17 changes: 15 additions & 2 deletions core/src/main/python/wlsdeploy/tool/util/k8s_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
import re

from wlsdeploy.aliases import alias_utils
from wlsdeploy.aliases.location_context import LocationContext
from wlsdeploy.aliases.model_constants import CLUSTER
from wlsdeploy.aliases.model_constants import DYNAMIC_CLUSTER_SIZE
from wlsdeploy.aliases.model_constants import DYNAMIC_SERVERS
from wlsdeploy.aliases.model_constants import MAX_DYNAMIC_SERVER_COUNT
from wlsdeploy.aliases.model_constants import SERVER
from wlsdeploy.aliases.model_constants import TOPOLOGY
from wlsdeploy.aliases.validation_codes import ValidationCodes
from wlsdeploy.util import dictionary_utils


Expand All @@ -29,18 +32,28 @@ def get_domain_uid(domain_name):
return result


def get_server_count(cluster_name, cluster_values, model_dictionary):
def get_server_count(cluster_name, cluster_values, model_dictionary, aliases):
"""
Determine the number of servers associated with a cluster.
:param cluster_name: the name of the cluster
:param cluster_values: the value map for the cluster
:param model_dictionary: the model dictionary
:param aliases: aliases instance for validation
:return: the number of servers
"""
if DYNAMIC_SERVERS in cluster_values:
# for dynamic clusters, return the value of DynamicClusterSize
dynamic_servers_dict = cluster_values[DYNAMIC_SERVERS]
cluster_size_value = dictionary_utils.get_element(dynamic_servers_dict, DYNAMIC_CLUSTER_SIZE)
location = LocationContext()
location.append_location(CLUSTER)
location.add_name_token(aliases.get_name_token(location), 'cluster')
location.append_location(DYNAMIC_SERVERS)
location.add_name_token(aliases.get_name_token(location), 'server')
present, __ = aliases.is_valid_model_attribute_name(location, DYNAMIC_CLUSTER_SIZE)
if present == ValidationCodes.VALID:
cluster_size_value = dictionary_utils.get_element(dynamic_servers_dict, DYNAMIC_CLUSTER_SIZE)
else:
cluster_size_value = dictionary_utils.get_element(dynamic_servers_dict, MAX_DYNAMIC_SERVER_COUNT)
if cluster_size_value is not None:
return alias_utils.convert_to_type('integer', cluster_size_value)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _build_template_hash(model, model_context, aliases, credential_injector):
cluster_hash[CLUSTER_NAME] = cluster_name

cluster_values = dictionary_utils.get_dictionary_element(cluster_list, cluster_name)
server_count = k8s_helper.get_server_count(cluster_name, cluster_values, model.get_model())
server_count = k8s_helper.get_server_count(cluster_name, cluster_values, model.get_model(), aliases)
cluster_hash[REPLICAS] = str(server_count)
clusters.append(cluster_hash)

Expand Down