Skip to content

Commit 345d608

Browse files
authored
Derive replica count from DynamicClusterSize or MaximumDynamicServerCount, regardless of WLS version (#957)
1 parent 189777d commit 345d608

File tree

4 files changed

+16
-26
lines changed

4 files changed

+16
-26
lines changed

core/src/main/python/extract_resource.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2020, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55
The entry point for the extractDomainResource tool.
@@ -71,17 +71,16 @@ def __process_args(args):
7171
return model_context
7272

7373

74-
def __extract_resource(model, model_context, aliases):
74+
def __extract_resource(model, model_context):
7575
"""
7676
Offline deployment orchestration
7777
:param model: the model
7878
:param model_context: the model context
79-
:param aliases: the aliases object
8079
:raises: DeployException: if an error occurs
8180
"""
8281
_method_name = '__extract_resource'
8382

84-
resource_extractor = DomainResourceExtractor(model, model_context, aliases, __logger)
83+
resource_extractor = DomainResourceExtractor(model, model_context, __logger)
8584
resource_extractor.extract()
8685
return 0
8786

@@ -118,7 +117,7 @@ def main(args):
118117

119118
try:
120119
model = Model(model_dictionary)
121-
exit_code = __extract_resource(model, model_context, aliases)
120+
exit_code = __extract_resource(model, model_context)
122121
except DeployException, ex:
123122
__logger.severe('WLSDPLY-09015', _program_name, ex.getLocalizedMessage(), error=ex,
124123
class_name=_class_name, method_name=_method_name)

core/src/main/python/wlsdeploy/tool/extract/domain_resource_extractor.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2020, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55
import re
@@ -64,10 +64,9 @@ class DomainResourceExtractor:
6464
"""
6565
_class_name = "DomainResourceExtractor"
6666

67-
def __init__(self, model, model_context, aliases, logger):
67+
def __init__(self, model, model_context, logger):
6868
self._model = model
6969
self._model_context = model_context
70-
self._aliases = aliases
7170
self._logger = logger
7271
return
7372

@@ -255,7 +254,7 @@ def _update_resource_dictionary(self, resource_dict):
255254
server_count = spec_section[REPLICAS]
256255
else:
257256
server_count = k8s_helper.get_server_count(cluster_name, cluster_values,
258-
self._model.get_model(), self._aliases)
257+
self._model.get_model())
259258
cluster_dict = PyOrderedDict()
260259
cluster_dict[CLUSTER_NAME] = cluster_name
261260
cluster_dict[REPLICAS] = server_count

core/src/main/python/wlsdeploy/tool/util/k8s_helper.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
import re
99

1010
from wlsdeploy.aliases import alias_utils
11-
from wlsdeploy.aliases.location_context import LocationContext
1211
from wlsdeploy.aliases.model_constants import CLUSTER
1312
from wlsdeploy.aliases.model_constants import DYNAMIC_CLUSTER_SIZE
1413
from wlsdeploy.aliases.model_constants import DYNAMIC_SERVERS
1514
from wlsdeploy.aliases.model_constants import MAX_DYNAMIC_SERVER_COUNT
1615
from wlsdeploy.aliases.model_constants import SERVER
1716
from wlsdeploy.aliases.model_constants import TOPOLOGY
18-
from wlsdeploy.aliases.validation_codes import ValidationCodes
1917
from wlsdeploy.util import dictionary_utils
2018

2119

@@ -41,30 +39,24 @@ def get_dns_name(name):
4139
return result
4240

4341

44-
def get_server_count(cluster_name, cluster_values, model_dictionary, aliases):
42+
def get_server_count(cluster_name, cluster_values, model_dictionary):
4543
"""
4644
Determine the number of servers associated with a cluster.
4745
:param cluster_name: the name of the cluster
4846
:param cluster_values: the value map for the cluster
4947
:param model_dictionary: the model dictionary
50-
:param aliases: aliases instance for validation
5148
:return: the number of servers
5249
"""
5350
if DYNAMIC_SERVERS in cluster_values:
5451
# for dynamic clusters, return the value of DynamicClusterSize
5552
dynamic_servers_dict = cluster_values[DYNAMIC_SERVERS]
56-
location = LocationContext()
57-
location.append_location(CLUSTER)
58-
location.add_name_token(aliases.get_name_token(location), 'cluster')
59-
location.append_location(DYNAMIC_SERVERS)
60-
location.add_name_token(aliases.get_name_token(location), 'server')
61-
present, __ = aliases.is_valid_model_attribute_name(location, DYNAMIC_CLUSTER_SIZE)
62-
if present == ValidationCodes.VALID:
63-
cluster_size_value = dictionary_utils.get_element(dynamic_servers_dict, DYNAMIC_CLUSTER_SIZE)
64-
else:
65-
cluster_size_value = dictionary_utils.get_element(dynamic_servers_dict, MAX_DYNAMIC_SERVER_COUNT)
66-
if cluster_size_value is not None:
67-
return alias_utils.convert_to_type('integer', cluster_size_value)
53+
54+
# model may contain DYNAMIC_CLUSTER_SIZE or MAX_DYNAMIC_SERVER_COUNT
55+
cluster_size = dictionary_utils.get_element(dynamic_servers_dict, DYNAMIC_CLUSTER_SIZE)
56+
if cluster_size is None:
57+
cluster_size = dictionary_utils.get_element(dynamic_servers_dict, MAX_DYNAMIC_SERVER_COUNT)
58+
if cluster_size is not None:
59+
return alias_utils.convert_to_type('integer', cluster_size)
6860
else:
6961
# for other clusters, return the number of servers assigned to this cluster
7062
count = 0

core/src/main/python/wlsdeploy/tool/util/targets/additional_output_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def _build_template_hash(model, model_context, aliases, credential_injector):
146146
cluster_hash[CLUSTER_NAME] = cluster_name
147147

148148
cluster_values = dictionary_utils.get_dictionary_element(cluster_list, cluster_name)
149-
server_count = k8s_helper.get_server_count(cluster_name, cluster_values, model.get_model(), aliases)
149+
server_count = k8s_helper.get_server_count(cluster_name, cluster_values, model.get_model())
150150
cluster_hash[REPLICAS] = str(server_count)
151151
clusters.append(cluster_hash)
152152

0 commit comments

Comments
 (0)