Skip to content

Commit 2d76a20

Browse files
committed
Merge branch 'jira-wdt-924-computed' into 'main'
Improve default value detection for 14.1.2 offline attributes marked as @computed See merge request weblogic-cloud/weblogic-deploy-tooling!1768
2 parents 6608da3 + 4ed297d commit 2d76a20

File tree

24 files changed

+396
-261
lines changed

24 files changed

+396
-261
lines changed

core/src/main/python/wlsdeploy/aliases/model_constants.py

Lines changed: 5 additions & 1 deletion
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

@@ -19,6 +19,9 @@
1919
ADMIN_CONSOLE = 'AdminConsole'
2020
ADMIN_PASSWORD = 'AdminPassword'
2121
ADMIN_SERVER_NAME = 'AdminServerName'
22+
ADMINISTRATION_PORT = 'AdministrationPort'
23+
ADMINISTRATION_PORT_ENABLED = 'AdministrationPortEnabled'
24+
ADMINISTRATION_PROTOCOL = 'AdministrationProtocol'
2225
ADMIN_USERNAME = 'AdminUserName'
2326
APP_DEPLOYMENTS = 'appDeployments'
2427
APP_DIR = 'AppDir'
@@ -170,6 +173,7 @@
170173
LDAP_AUTHENTICATOR = 'LDAPAuthenticator'
171174
LDAP_X509_IDENTITY_ASSERTER = 'LDAPX509IdentityAsserter'
172175
LIBRARY = 'Library'
176+
LISTEN_PORT_ENABLED = "ListenPortEnabled"
173177
LOAD_BALANCING_PARAMS = 'LoadBalancingParams'
174178
LOG = 'Log'
175179
LOG_FILTER = 'LogFilter'

core/src/main/python/wlsdeploy/tool/discover/discoverer.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,25 @@ def _get_named_resources(self, folder_name):
228228
_logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
229229
return model_top_folder_name, result
230230

231-
def _uses_is_set(self, location, wlst_param):
231+
def _uses_is_set(self, location, model_attribute):
232232
"""
233233
Determine if the specified attribute should call WLST.is_set() to be included in the model.
234234
Attributes with derived defaults need to call is_set(), since their values are dynamic.
235235
Avoid calling wlst_helper.is_set() unless derived, it slows down online discovery,
236236
and non-derived offline attributes will not return the correct values.
237237
:param location: the location of the attribute to be examined
238-
:param wlst_param: the name of the attribute to be examined
238+
:param model_attribute: the name of the attribute to be examined
239239
:return: True if attribute should use WLST.is_set(), False otherwise
240240
"""
241-
return self._aliases.is_derived_default(location, wlst_param)
241+
return self._aliases.is_derived_default(location, model_attribute)
242+
243+
def _needs_is_set_revision(self, location, model_attribute):
244+
"""
245+
Determine if the attribute value needs revision because it uses the unreliable version of isSet()
246+
:param location: the location of the attribute to be examined
247+
:param model_attribute: the model name of the attribute to be examined
248+
"""
249+
return self._uses_is_set(location, model_attribute) and self._wlst_helper.is_unreliable_is_set()
242250

243251
def _get_attribute_value_with_get(self, wlst_get_param, wlst_path):
244252
_method_name = '_get_attribute_value_with_get'
@@ -298,7 +306,8 @@ def _get_model_name_and_value(self, location, wlst_name, wlst_value, wlst_path):
298306
try:
299307
# if this attribute uses WLST is_set, ignore a matching default value.
300308
# we may reset the model value to None later if is_set() returns False.
301-
uses_is_set = self._uses_is_set(location, wlst_name)
309+
model_name = self._aliases.get_model_attribute_name(location, wlst_name)
310+
uses_is_set = self._uses_is_set(location, model_name)
302311

303312
model_name, model_value = \
304313
self._aliases.get_model_attribute_name_and_value(location, wlst_name, wlst_value,

core/src/main/python/wlsdeploy/tool/discover/topology_discoverer.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from oracle.weblogic.deploy.discover import DiscoverException
88
from oracle.weblogic.deploy.util import PyOrderedDict as OrderedDict
9+
from oracle.weblogic.deploy.util import PyRealBoolean
910
from oracle.weblogic.deploy.util import PyWLSTException
1011
from oracle.weblogic.deploy.util import StringUtils
1112
from oracle.weblogic.deploy.util import WLSDeployArchive
@@ -35,6 +36,19 @@
3536
_class_name = 'TopologyDiscoverer'
3637
_logger = PlatformLogger(discoverer.get_discover_logger_name())
3738

39+
# these are used to correct unreliable isSet() results
40+
DOMAIN_INHERITED_DEFAULT_MAPPINGS = {
41+
"/Server/AdministrationPort": "AdministrationPort",
42+
"/Server/AdministrationPortEnabled": "AdministrationPortEnabled",
43+
"/Server/AdministrationProtocol": "AdministrationProtocol",
44+
"/Server/ListenPortEnabled": "ListenPortEnabled",
45+
"/Server/SSL/Enabled": "SSLEnabled",
46+
"/ServerTemplate/AdministrationPort": "AdministrationPort",
47+
"/ServerTemplate/AdministrationPortEnabled": "AdministrationPortEnabled",
48+
"/ServerTemplate/AdministrationProtocol": "AdministrationProtocol",
49+
"/ServerTemplate/ListenPortEnabled": "ListenPortEnabled",
50+
"/ServerTemplate/SSL/Enabled": "SSLEnabled",
51+
}
3852

3953
class TopologyDiscoverer(Discoverer):
4054
"""
@@ -58,8 +72,17 @@ def __init__(self, model_context, topology_dictionary, base_location,
5872
self._add_jdbc_transaction_log_create_table_ddl_file_to_archive)
5973
self._add_att_handler(model_constants.CUSTOM_IDENTITY_KEYSTORE_FILE, self._add_keystore_file_to_archive)
6074
self._add_att_handler(model_constants.CUSTOM_TRUST_KEYSTORE_FILE, self._add_keystore_file_to_archive)
75+
76+
self._add_att_handler(model_constants.ADMINISTRATION_PORT, self._handle_inherited_default)
77+
self._add_att_handler(model_constants.ADMINISTRATION_PORT_ENABLED, self._handle_inherited_default)
78+
self._add_att_handler(model_constants.ADMINISTRATION_PROTOCOL, self._handle_inherited_default)
79+
self._add_att_handler(model_constants.LISTEN_PORT_ENABLED, self._handle_inherited_default)
80+
self._add_att_handler(model_constants.ENABLED, self._handle_inherited_default)
81+
6182
self._wlst_helper = WlstHelper(ExceptionType.DISCOVER)
6283

84+
self._domain_inherited_values = None # lazy load if needed for unreliable isSet()
85+
6386
def discover(self):
6487
"""
6588
Discover the clusters, servers and machines that describe the domain's topology and return
@@ -1092,6 +1115,48 @@ def _add_node_manager_keystore_file_to_archive(self, archive_file, file_path):
10921115
_logger.exiting(class_name=_class_name, method_name=_method_name, result=new_name)
10931116
return new_name
10941117

1118+
def _handle_inherited_default(self, model_name, model_value, location):
1119+
"""
1120+
An att_handler that checks against defaults that are inherited from the domain level.
1121+
If the defaults match, None will be returned, and the attribute will be removed from the model.
1122+
This is only for cases where the results from WLST offline isSet() are unreliable (WLS 14.1.2).
1123+
:param model_name: the name of the attribute
1124+
:param model_value: the calculated value for the model
1125+
:param location: the location of the attribute
1126+
:return: the revised attribute for the model
1127+
"""
1128+
_method_name = '_handle_inherited_default'
1129+
result = model_value
1130+
if self._needs_is_set_revision(location, model_name):
1131+
model_path = location.get_folder_path() + '/' + model_name
1132+
domain_attribute = dictionary_utils.get_element(DOMAIN_INHERITED_DEFAULT_MAPPINGS, model_path)
1133+
if domain_attribute is not None:
1134+
domain_values = self._get_domain_inherited_values()
1135+
domain_value = dictionary_utils.get_element(domain_values, domain_attribute)
1136+
if isinstance(model_value, PyRealBoolean):
1137+
model_value = model_value.getValue()
1138+
if domain_value == model_value:
1139+
_logger.info('WLSDPLY-06678', model_path, domain_attribute,
1140+
class_name=_class_name, method_name=_method_name)
1141+
result = None # remove from model
1142+
return result
1143+
1144+
def _get_domain_inherited_values(self):
1145+
"""
1146+
Returns a map of domain attributes and their values for use as default values
1147+
to compare with attributes whose WLST offline isSet() values are unreliable (WLS 14.1.2).
1148+
Lazy load this map the first time this method is called.
1149+
:return: a map of domain attributes and their values
1150+
"""
1151+
if not self._domain_inherited_values:
1152+
self._domain_inherited_values = {}
1153+
attribute_map = self._wlst_helper.lsa('/')
1154+
for domain_attribute in DOMAIN_INHERITED_DEFAULT_MAPPINGS.values():
1155+
if domain_attribute not in self._domain_inherited_values:
1156+
attribute_value = dictionary_utils.get_element(attribute_map, domain_attribute)
1157+
self._domain_inherited_values[domain_attribute] = attribute_value
1158+
return self._domain_inherited_values
1159+
10951160
def _get_server_name_from_location(self, location):
10961161
"""
10971162
Retrieve the server name from the location context.

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2019, 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2019, 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

@@ -164,7 +164,10 @@ def is_set(self, attribute):
164164
mbean_path = self.get_pwd()
165165

166166
try:
167-
if self.__check_online_connection():
167+
if self.is_unreliable_is_set():
168+
# put the value in the model; an att_handler may correct the value
169+
result = True
170+
elif self.__check_online_connection():
168171
mbean = self.get_mbean(mbean_path)
169172
# we may call for every attribute for online + local
170173
if 'isSet' not in dir(mbean):
@@ -189,6 +192,16 @@ def is_set(self, attribute):
189192
self.__logger.finest('WLSDPLY-00126', attribute, class_name=self.__class_name, method_name=_method_name)
190193
return result
191194

195+
def is_unreliable_is_set(self):
196+
"""
197+
Determine if this WLS version's implementation of the WLST isSet() method
198+
is not reliable for deciding to include an attribute value.
199+
Currently, all offline WLS versions that use isSet() (14.1.2+) are not reliable.
200+
Future WLS versions may support a more reliable version of isSet().
201+
:return: True if the implementation of isSet() is unreliable
202+
"""
203+
return not self.__check_online_connection()
204+
192205
def set_if_needed(self, wlst_name, wlst_value, masked=False):
193206
"""
194207
Set the WLST attribute to the specified value if the name and value are not None.

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/Cluster.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"copyright": "Copyright (c) 2017, 2024, Oracle and/or its affiliates.",
2+
"copyright": "Copyright (c) 2017, 2025, Oracle and/or its affiliates.",
33
"license": "Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl",
44
"wlst_type": "Cluster${:s}",
55
"online_bean": "weblogic.management.configuration.ClusterMBean",
@@ -108,7 +108,7 @@
108108
"CrossSiteRecoveryLeaseExpiration": [ {"version": "[12.2.1.1,)", "wlst_mode": "both", "wlst_name": "CrossSiteRecoveryLeaseExpiration", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": 30, "wlst_type": "integer" } ],
109109
"CrossSiteRecoveryLeaseUpdate": [ {"version": "[12.2.1.1,)", "wlst_mode": "both", "wlst_name": "CrossSiteRecoveryLeaseUpdate", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": 10, "wlst_type": "integer" } ],
110110
"CrossSiteRecoveryRetryInterval": [ {"version": "[12.2.1.1,)", "wlst_mode": "both", "wlst_name": "CrossSiteRecoveryRetryInterval", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": 60, "wlst_type": "integer" } ],
111-
"Determiner": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "Determiner${:s}", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
111+
"Determiner": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "Determiner${:s}", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
112112
"DeterminerCandidateResourceInfoList": [ {"version": "[12.2.1,)", "wlst_mode": "online", "wlst_name": "DeterminerCandidateResourceInfoList", "wlst_path": "WP001", "default_value": "", "wlst_type": "jarray", "access": "IGNORED" } ],
113113
"ForgetHeuristics": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "ForgetHeuristics", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": "true", "wlst_type": "boolean" } ],
114114
"LocalDomainSecurityCacheEnabled": [ {"version": "[14.1.2,)", "wlst_mode": "both", "wlst_name": "LocalDomainSecurityCacheEnabled", "wlst_path": "WP001", "default_value": "true", "wlst_type": "boolean" } ],
@@ -123,10 +123,10 @@
123123
"MaxXACallMillis": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "MaxXACallMillis", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": 120000, "wlst_type": "long" } ],
124124
"MigrationCheckpointIntervalSeconds": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "MigrationCheckpointIntervalSeconds", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": 60, "wlst_type": "integer" } ],
125125
"Notes": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
126-
"ParallelXADispatchPolicy": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "ParallelXADispatchPolicy", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
126+
"ParallelXADispatchPolicy": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "ParallelXADispatchPolicy", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
127127
"ParallelXAEnabled": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "ParallelXAEnabled", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": "true", "wlst_type": "boolean" } ],
128128
"PurgeResourceFromCheckpointIntervalSeconds": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "PurgeResourceFromCheckpointIntervalSeconds", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": 86400, "wlst_type": "integer" } ],
129-
"RecoverySiteName": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "RecoverySiteName", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
129+
"RecoverySiteName": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "RecoverySiteName", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
130130
"RecoveryThresholdMillis": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "RecoveryThresholdMillis", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": 300000, "wlst_type": "long" } ],
131131
"SecurityInteropMode": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "SecurityInteropMode", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": "${__NULL__:default}", "wlst_type": "string" } ],
132132
"SerializeEnlistmentsGCIntervalMillis": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "SerializeEnlistmentsGCIntervalMillis", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": 30000, "wlst_type": "long" } ],

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/CoherenceClusterSystemResource.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"copyright": "Copyright (c) 2017, 2024, Oracle and/or its affiliates.",
2+
"copyright": "Copyright (c) 2017, 2025, Oracle and/or its affiliates.",
33
"license": "Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl",
44
"wlst_type": "CoherenceClusterSystemResource${:s}",
55
"online_bean": "weblogic.management.configuration.CoherenceClusterSystemResourceMBean",
@@ -181,8 +181,8 @@
181181
"ClusterListenPort": [ {"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "ClusterListenPort", "wlst_path": "WP001", "default_value": 0, "wlst_type": "integer" } ],
182182
"ClusteringMode": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "ClusteringMode", "wlst_path": "WP001", "default_value": "${__NULL__:unicast}", "derived_default": "${:true}", "wlst_type": "string" } ],
183183
"GlobalSocketProvider": [
184-
{"version": "[14.1.1.0.0.221010,14.1.2)", "wlst_mode": "online", "wlst_name": "GlobalSocketProvider", "wlst_path": "WP001", "default_value": "false", "wlst_type": "boolean" },
185-
{"version": "[14.1.2,)", "wlst_mode": "both", "wlst_name": "GlobalSocketProvider", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" }
184+
{"version": "[14.1.1.0.0.221010,14.1.2)", "wlst_mode": "online", "wlst_name": "GlobalSocketProvider", "wlst_path": "WP001", "default_value": "false", "wlst_type": "boolean" },
185+
{"version": "[14.1.2,)", "wlst_mode": "both", "wlst_name": "GlobalSocketProvider", "wlst_path": "WP001", "default_value": null, "derived_default": "${:true}", "wlst_type": "string" }
186186
],
187187
"IgnoreHostnameVerification": [ {"version": "[14.1.2,)", "wlst_mode": "online", "wlst_name": "IgnoreHostnameVerification", "wlst_path": "WP001", "default_value": false, "wlst_type": "boolean" } ],
188188
"MulticastListenAddress": [ {"version": "[12.1.2,)", "wlst_mode": "both", "wlst_name": "MulticastListenAddress", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],

0 commit comments

Comments
 (0)