Skip to content

Commit caf60e3

Browse files
committed
Merge branch 'filter-fixes' into 'main'
Move static cluster server port checks to final filter See merge request weblogic-cloud/weblogic-deploy-tooling!1789
2 parents f95f053 + 3de625f commit caf60e3

File tree

3 files changed

+47
-34
lines changed

3 files changed

+47
-34
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2017, 2025, 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 imp
@@ -11,6 +11,7 @@
1111
from wlsdeploy.tool.util.filters import wko_final_filter
1212
from wlsdeploy.util import dictionary_utils
1313
from wlsdeploy.util import path_helper
14+
from wlsdeploy.util import target_configuration
1415
from wlsdeploy.util.model_translator import FileToPython
1516
import wlsdeploy.util.unicode_helper as str_helper
1617

@@ -65,7 +66,8 @@ def apply_filters(model, tool_type, model_context):
6566
if model_context and model_context.get_target():
6667
__filter_file_location = model_context.get_target_configuration_file()
6768
filters_dictionary = model_context.get_target_configuration().get_model_filters()
68-
target_path = _path_helper.local_join('targets', model_context.get_target())
69+
target_key = target_configuration.get_target_configuration_key(model_context.get_target())
70+
target_path = _path_helper.local_join('targets', target_key)
6971

7072
# Fix the tokenized path in the filter path
7173
for filter_list in filters_dictionary:

core/src/main/python/wlsdeploy/tool/util/filters/wko_filter.py

+1-30
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from wlsdeploy.aliases.model_constants import CLUSTER_MESSAGING_MODE
1919
from wlsdeploy.aliases.model_constants import DATABASE_LESS_LEASING_BASIS
2020
from wlsdeploy.aliases.model_constants import DYNAMIC_SERVERS
21-
from wlsdeploy.aliases.model_constants import LISTEN_PORT
2221
from wlsdeploy.aliases.model_constants import MACHINE
2322
from wlsdeploy.aliases.model_constants import MIGRATION_BASIS
2423
from wlsdeploy.aliases.model_constants import NM_PROPERTIES
@@ -45,7 +44,6 @@
4544
from wlsdeploy.logging.platform_logger import PlatformLogger
4645
from wlsdeploy.tool.util.filters.model_traverse import ModelTraverse
4746
from wlsdeploy.util import dictionary_utils
48-
import wlsdeploy.util.unicode_helper as str_helper
4947

5048
_class_name = 'wko_filter'
5149
_logger = PlatformLogger('wlsdeploy.tool.util')
@@ -99,7 +97,6 @@ def filter_online_attributes(model, model_context):
9997
def check_clustered_server_ports(model, _model_context):
10098
"""
10199
Set the CalculatedListenPorts attribute to false for dynamic clusters in the specified model.
102-
Warn if servers in a static cluster have different ports in the specified model.
103100
:param model: the model to be filtered
104101
:param _model_context: unused, passed by filter_helper if called independently
105102
"""
@@ -119,32 +116,6 @@ def check_clustered_server_ports(model, _model_context):
119116
method_name=_method_name)
120117
dynamic_folder[CALCULATED_LISTEN_PORTS] = PyRealBoolean(False)
121118

122-
# be sure every server assigned to a cluster has the same listen port
123-
124-
server_port_map = {}
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-
_logger.warning('WLSDPLY-20203', SERVER, first_server, server_name, CLUSTER, server_cluster,
143-
LISTEN_PORT, cluster_port, server_port_text, class_name=_class_name,
144-
method_name=_method_name)
145-
else:
146-
server_port_map[server_cluster] = {"firstServer": server_name, "serverPort": server_port_text}
147-
148119

149120
def filter_domain_info(_model, _model_context):
150121
"""
@@ -192,7 +163,7 @@ def filter_topology(model, _model_context):
192163
server_templates = dictionary_utils.get_dictionary_element(topology, SERVER_TEMPLATE)
193164
for key in server_templates:
194165
server_template = server_templates[key]
195-
auto_migration_enabled = server_template[AUTO_MIGRATION_ENABLED]
166+
auto_migration_enabled = dictionary_utils.get_element(server_template, AUTO_MIGRATION_ENABLED)
196167
if auto_migration_enabled is None or alias_utils.convert_boolean(auto_migration_enabled):
197168
server_template[AUTO_MIGRATION_ENABLED] = PyRealBoolean(False)
198169
for delete_key in [MACHINE, SERVER_START]:

core/src/main/python/wlsdeploy/tool/util/filters/wko_final_filter.py

+42-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2023, 2025, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
#
44
# ------------
@@ -8,17 +8,20 @@
88
# These filters are applied to a merged, substituted model.
99
# They apply any updates to a specified update model, to support use cases with multiple models.
1010
# These operations can be invoked as a single call, or independently of each other.
11+
1112
from oracle.weblogic.deploy.util import PyOrderedDict
1213

1314
from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME
1415
from wlsdeploy.aliases.model_constants import CLUSTER
1516
from wlsdeploy.aliases.model_constants import DEFAULT_ADMIN_SERVER_NAME
1617
from wlsdeploy.aliases.model_constants import DYNAMIC_SERVERS
18+
from wlsdeploy.aliases.model_constants import LISTEN_PORT
1719
from wlsdeploy.aliases.model_constants import SERVER
1820
from wlsdeploy.aliases.model_constants import SERVER_NAME_PREFIX
1921
from wlsdeploy.aliases.model_constants import TOPOLOGY
2022
from wlsdeploy.logging.platform_logger import PlatformLogger
2123
from wlsdeploy.util import dictionary_utils
24+
from wlsdeploy.util import unicode_helper as str_helper
2225

2326
_class_name = 'wko_final_filter'
2427
_logger = PlatformLogger('wlsdeploy.tool.util')
@@ -27,13 +30,14 @@
2730
def filter_final_model(model, update_model, model_context):
2831
"""
2932
Perform the following operations on the specified model:
30-
- Remove any online-only attributes
3133
- Check if dynamic cluster prefixes are specified and unique
34+
- Check if servers in each static cluster have matching port numbers
3235
:param model: the model to be filtered
3336
:param update_model: the model to be updated with any changes
3437
:param model_context: used by nested filters
3538
"""
3639
check_dynamic_cluster_prefixes(model, update_model, model_context)
40+
check_static_cluster_server_ports(model, update_model, model_context)
3741

3842

3943
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):
107111
server_name_prefixes.append(server_name_prefix)
108112

109113

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+
110150
def check_admin_server_defined(model, update_model, _model_context):
111151
"""
112152
Ensure that the AdminServerName attribute is set, and that the server is defined.

0 commit comments

Comments
 (0)