|
1 |
| -# Copyright (c) 2023, Oracle and/or its affiliates. |
| 1 | +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. |
2 | 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
3 | 3 | #
|
4 | 4 | # ------------
|
|
8 | 8 | # These filters are applied to a merged, substituted model.
|
9 | 9 | # They apply any updates to a specified update model, to support use cases with multiple models.
|
10 | 10 | # These operations can be invoked as a single call, or independently of each other.
|
| 11 | + |
11 | 12 | from oracle.weblogic.deploy.util import PyOrderedDict
|
12 | 13 |
|
13 | 14 | from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME
|
14 | 15 | from wlsdeploy.aliases.model_constants import CLUSTER
|
15 | 16 | from wlsdeploy.aliases.model_constants import DEFAULT_ADMIN_SERVER_NAME
|
16 | 17 | from wlsdeploy.aliases.model_constants import DYNAMIC_SERVERS
|
| 18 | +from wlsdeploy.aliases.model_constants import LISTEN_PORT |
17 | 19 | from wlsdeploy.aliases.model_constants import SERVER
|
18 | 20 | from wlsdeploy.aliases.model_constants import SERVER_NAME_PREFIX
|
19 | 21 | from wlsdeploy.aliases.model_constants import TOPOLOGY
|
20 | 22 | from wlsdeploy.logging.platform_logger import PlatformLogger
|
21 | 23 | from wlsdeploy.util import dictionary_utils
|
| 24 | +from wlsdeploy.util import unicode_helper as str_helper |
22 | 25 |
|
23 | 26 | _class_name = 'wko_final_filter'
|
24 | 27 | _logger = PlatformLogger('wlsdeploy.tool.util')
|
|
27 | 30 | def filter_final_model(model, update_model, model_context):
|
28 | 31 | """
|
29 | 32 | Perform the following operations on the specified model:
|
30 |
| - - Remove any online-only attributes |
31 | 33 | - Check if dynamic cluster prefixes are specified and unique
|
| 34 | + - Check if servers in each static cluster have matching port numbers |
32 | 35 | :param model: the model to be filtered
|
33 | 36 | :param update_model: the model to be updated with any changes
|
34 | 37 | :param model_context: used by nested filters
|
35 | 38 | """
|
36 | 39 | check_dynamic_cluster_prefixes(model, update_model, model_context)
|
| 40 | + check_static_cluster_server_ports(model, update_model, model_context) |
37 | 41 |
|
38 | 42 |
|
39 | 43 | def filter_final_model_for_wko(model, update_model, model_context):
|
@@ -107,6 +111,42 @@ def check_dynamic_cluster_prefixes(model, update_model, _model_context):
|
107 | 111 | server_name_prefixes.append(server_name_prefix)
|
108 | 112 |
|
109 | 113 |
|
| 114 | +def check_static_cluster_server_ports(model, _update_model, _model_context): |
| 115 | + """ |
| 116 | + Warn if servers in a static cluster have different ports in the specified model. |
| 117 | + :param model: the model to be checked |
| 118 | + :param _update_model: unused, passed by filter_helper if called independently |
| 119 | + :param _model_context: unused, passed by filter_helper if called independently |
| 120 | + """ |
| 121 | + _method_name = 'check_static_cluster_server_ports' |
| 122 | + |
| 123 | + server_port_map = {} |
| 124 | + topology_folder = dictionary_utils.get_dictionary_element(model, TOPOLOGY) |
| 125 | + servers_folder = dictionary_utils.get_dictionary_element(topology_folder, SERVER) |
| 126 | + for server_name, server_fields in servers_folder.items(): |
| 127 | + server_cluster = dictionary_utils.get_element(server_fields, CLUSTER) |
| 128 | + server_port = dictionary_utils.get_element(server_fields, LISTEN_PORT) |
| 129 | + |
| 130 | + if server_cluster and (server_port is not None): |
| 131 | + server_port_text = str_helper.to_string(server_port) |
| 132 | + if '@@' in server_port_text: |
| 133 | + # prepareModel filters the model before and after it is tokenized, |
| 134 | + # so disregard variable values in the tokenized pass |
| 135 | + continue |
| 136 | + |
| 137 | + if server_cluster in server_port_map: |
| 138 | + cluster_info = server_port_map[server_cluster] |
| 139 | + first_server = cluster_info["firstServer"] |
| 140 | + cluster_port = cluster_info["serverPort"] |
| 141 | + if server_port_text != cluster_port: |
| 142 | + # issue a warning - we won't try to fix this |
| 143 | + _logger.warning('WLSDPLY-20203', SERVER, first_server, server_name, CLUSTER, |
| 144 | + server_cluster, LISTEN_PORT, cluster_port, server_port_text, |
| 145 | + class_name=_class_name, method_name=_method_name) |
| 146 | + else: |
| 147 | + server_port_map[server_cluster] = {"firstServer": server_name, "serverPort": server_port_text} |
| 148 | + |
| 149 | + |
110 | 150 | def check_admin_server_defined(model, update_model, _model_context):
|
111 | 151 | """
|
112 | 152 | Ensure that the AdminServerName attribute is set, and that the server is defined.
|
|
0 commit comments