Skip to content

Allow production mode default values for attributes #1314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 15, 2022
20 changes: 20 additions & 0 deletions core/src/main/python/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ def __discover(model_context, aliases, credential_injector, helper, extra_tokens
__connect_to_domain(model_context, helper)
try:
_add_domain_name(base_location, aliases, helper)
_establish_production_mode(aliases, helper)

DomainInfoDiscoverer(model_context, model.get_model_domain_info(), base_location, wlst_mode=__wlst_mode,
aliases=aliases, credential_injector=credential_injector).discover()
TopologyDiscoverer(model_context, model.get_model_topology(), base_location, wlst_mode=__wlst_mode,
Expand Down Expand Up @@ -277,6 +279,24 @@ def _add_domain_name(location, aliases, helper):
raise de


def _establish_production_mode(aliases, helper):
"""
Determine if production mode is enabled for the domain, and set it in the aliases.
:param aliases: aliases instance for discover
:param helper: wlst_helper instance
:raises DiscoverException: if an error occurs during discovery
"""
_method_name = '_establish_production_mode'
try:
helper.cd('/')
production_mode_enabled = helper.get(model_constants.PRODUCTION_MODE_ENABLED)
aliases.set_production_mode(production_mode_enabled)
except PyWLSTException, pe:
de = exception_helper.create_discover_exception('WLSDPLY-06036', pe.getLocalizedMessage())
__logger.throwing(class_name=_class_name, method_name=_method_name, error=de)
raise de


def __discover_multi_tenant(model, model_context, base_location, aliases, injector):
"""
Discover the multi-tenant-related parts of the domain, if they exist.
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/python/wlsdeploy/aliases/alias_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
PASSWORD_TOKEN = "--FIX ME--"
PATH_TOKEN = 'path_token'
PREFERRED_MODEL_TYPE = 'preferred_model_type'
PRODUCTION_DEFAULT = 'production_default'
RESTART_REQUIRED = 'restart_required'
SET_MBEAN_TYPE = 'set_mbean_type'
SET_METHOD = 'set_method'
Expand Down Expand Up @@ -73,6 +74,10 @@

# used when DEFAULT_VALUE has curly-brace value that resolves to null
NULL_VALUE_KEY = '__NULL__'
NULL_VALUE_KEY_FIELDS = [
DEFAULT_VALUE,
PRODUCTION_DEFAULT
]

# attribute wlst_type values
BOOLEAN = 'boolean'
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/python/wlsdeploy/aliases/alias_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from wlsdeploy.aliases.alias_constants import NAME_VALUE
from wlsdeploy.aliases.alias_constants import NONE_CHILD_FOLDERS_TYPE
from wlsdeploy.aliases.alias_constants import NULL_VALUE_KEY
from wlsdeploy.aliases.alias_constants import NULL_VALUE_KEY_FIELDS
from wlsdeploy.aliases.alias_constants import ONLINE_BEAN
from wlsdeploy.aliases.alias_constants import PATH_TOKEN
from wlsdeploy.aliases.alias_constants import SET_MBEAN_TYPE
Expand Down Expand Up @@ -1494,7 +1495,7 @@ def __resolve_attribute(self, attr_dict):
else:
result[key] = self._resolve_curly_braces(attr)
# resolve null key in curly brace values, such as "${__NULL__,Online}"
if key == DEFAULT_VALUE and result[key] == NULL_VALUE_KEY:
if key in NULL_VALUE_KEY_FIELDS and result[key] == NULL_VALUE_KEY:
result[key] = None

for key in [GET_METHOD, SET_METHOD, GET_MBEAN_TYPE, SET_MBEAN_TYPE]:
Expand Down
28 changes: 25 additions & 3 deletions core/src/main/python/wlsdeploy/aliases/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from wlsdeploy.aliases.alias_constants import PASSWORD
from wlsdeploy.aliases.alias_constants import PASSWORD_TOKEN
from wlsdeploy.aliases.alias_constants import PREFERRED_MODEL_TYPE
from wlsdeploy.aliases.alias_constants import PRODUCTION_DEFAULT
from wlsdeploy.aliases.alias_constants import PROPERTIES
from wlsdeploy.aliases.alias_constants import RESTART_REQUIRED
from wlsdeploy.aliases.alias_constants import RO
Expand All @@ -49,6 +50,7 @@
from wlsdeploy.exception import exception_helper
from wlsdeploy.exception.expection_types import ExceptionType
from wlsdeploy.logging.platform_logger import PlatformLogger
from wlsdeploy.util import dictionary_utils
from wlsdeploy.util import string_utils
from wlsdeploy.util import unicode_helper as str_helper

Expand Down Expand Up @@ -80,6 +82,13 @@ def __init__(self, model_context, wlst_mode=WlstModes.OFFLINE, wls_version=None,
self._wls_version = wls_version

self._alias_entries = AliasEntries(wlst_mode, self._wls_version)
self._production_mode_enabled = False

def set_production_mode(self, production_mode_enabled):
_method_name = 'set_production_mode'
if production_mode_enabled:
self._logger.info('WLSDPLY-19047', class_name=self._class_name, method_name=_method_name)
self._production_mode_enabled = production_mode_enabled

###########################################################################
# Model folder navigation-related methods #
Expand Down Expand Up @@ -674,7 +683,7 @@ def get_wlst_access_rod_attribute_names(self, location):
except AliasException, ae:
self._raise_exception(ae, _method_name, 'WLSDPLY-19046', location.get_current_model_folder(),
location.get_folder_path(), ae.getLocalizedMessage())

###########################################################################
# Model folder-related methods #
###########################################################################
Expand Down Expand Up @@ -1044,7 +1053,7 @@ def get_model_attribute_name_and_value(self, location, wlst_attribute_name, wlst
delimiter=delimiter)

model_attribute_name = attribute_info[MODEL_NAME]
default_value = attribute_info[DEFAULT_VALUE]
default_value = self._get_default_value_for_execution_mode(attribute_info)

#
# The logic below to compare the str() representation of the converted value and the default value
Expand Down Expand Up @@ -1259,7 +1268,7 @@ def get_model_attribute_default_value(self, location, model_attribute_name):
default_value = None
attribute_info = self._alias_entries.get_alias_attribute_entry_by_model_name(location, model_attribute_name)
if attribute_info is not None:
default_value = attribute_info[DEFAULT_VALUE]
default_value = self._get_default_value_for_execution_mode(attribute_info)
data_type, delimiter = \
alias_utils.compute_read_data_type_and_delimiter_from_attribute_info(
attribute_info, default_value)
Expand All @@ -1271,6 +1280,19 @@ def get_model_attribute_default_value(self, location, model_attribute_name):
self._raise_exception(ae, _method_name, 'WLSDPLY-19032', model_attribute_name, location.get_folder_path(),
ae.getLocalizedMessage())

def _get_default_value_for_execution_mode(self, attribute_info):
"""
Get the default value corresponding to the domain execution mode.
For example, return production mode default if domain is in production mode.
:param attribute_info: alias information for an attribute
:return: the correct default value for the execution mode
"""
if self._production_mode_enabled:
default_value = dictionary_utils.get_element(attribute_info, PRODUCTION_DEFAULT)
if default_value is not None:
return default_value
return dictionary_utils.get_element(attribute_info, DEFAULT_VALUE)

def get_ignore_attribute_names(self):
"""
Return the list of attribute names that are ignored by the aliases and not defined in the alias category
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ def _get_virtual_hosts(self):
location.add_name_token(name_token, vhost)
result[vhost] = OrderedDict()
self._populate_model_parameters(result[vhost], location)
self._discover_subfolders(result[vhost], location)
location.remove_name_token(name_token)

_logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
Expand Down Expand Up @@ -646,7 +647,7 @@ def get_managed_thread_factory_template(self):

_logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
return model_top_folder_name, result

def _get_ws_securities(self):
"""
Discover the Webservice Security configuration for the domain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
"BufferSizeKb": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "BufferSize${Kb:KB}", "wlst_path": "WP001", "default_value": 8, "wlst_type": "integer", "get_method": "LSA"} ],
"DateFormatPattern": [ {"version": "[10,12.2.1)", "wlst_mode": "both", "wlst_name": "DateFormatPattern", "wlst_path": "WP001", "default_value": "${__NULL__:MMM d, yyyy h:mm:ss a z}", "derived_default": "${:true}", "wlst_type": "string", "get_method": "${LSA:GET}", "restart_required": "true" } ,
{"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "DateFormatPattern", "wlst_path": "WP001", "default_value": "${__NULL__:MMM d, yyyy h:mm:SSS a z}", "derived_default": "${:true}" ,"wlst_type": "string", "get_method": "${LSA:GET}" } ],
"FileCount": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FileCount", "wlst_path": "WP001", "default_value": 7, "wlst_type": "integer" } ],
"FileMinSize": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FileMinSize", "wlst_path": "WP001", "default_value": 500, "wlst_type": "integer" } ],
"FileCount": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FileCount", "wlst_path": "WP001", "default_value": 7, "production_default": "${__NULL__:100}", "wlst_type": "integer" } ],
"FileMinSize": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FileMinSize", "wlst_path": "WP001", "default_value": 500, "production_default": "${__NULL__:5000}", "wlst_type": "integer" } ],
"FileName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FileName", "wlst_path": "WP001", "default_value": "${__NULL__:logs/jmsServers/%JMSSERVER%/jms.messages.log}", "derived_default": "${:true}", "wlst_type": "string", "restart_required": "true", "uses_path_tokens": "true" } ],
"FileTimeSpan": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FileTimeSpan", "wlst_path": "WP001", "default_value": 24, "wlst_type": "integer" } ],
"FileTimeSpanFactor": [ {"version": "[10,)", "wlst_mode": "offline", "wlst_name": "FileTimeSpanFactor", "wlst_path": "WP001", "default_value": 3600000, "wlst_type": "long" } ],
"LogFileRotationDir": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "LogFileRotationDir", "wlst_path": "WP001", "default_value": null, "wlst_type": "string", "uses_path_tokens": "true", "get_method": "${LSA:GET}" } ],
"Notes": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
"NumberOfFilesLimited": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "NumberOfFilesLimited", "wlst_path": "WP001", "default_value": "true", "wlst_type": "boolean" } ],
"RotateLogOnStartup": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RotateLogOnStartup", "wlst_path": "WP001", "default_value": "true", "wlst_type": "boolean" } ],
"RotateLogOnStartup": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RotateLogOnStartup", "wlst_path": "WP001", "default_value": "true", "production_default": "${__NULL__:false}", "wlst_type": "boolean" } ],
"RotationTime": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RotationTime", "wlst_path": "WP001", "default_value": "00:00", "wlst_type": "string" } ],
"RotationType": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RotationType", "wlst_path": "WP001", "default_value": "${__NULL__:bySize}", "wlst_type": "string" } ]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
{"version": "[12.2.1,)", "wlst_mode": "both", "wlst_name": "DateFormatPattern", "wlst_path": "WP001", "default_value": "${__NULL__:MMM d, yyyy h:mm:ss,SSS a z}", "derived_default": "${:true}", "wlst_type": "string", "get_method": "${LSA:GET}" } ],
"DomainLogBroadcastFilter": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "DomainLogBroadcastFilter", "wlst_path": "WP001", "default_value": null, "wlst_type": "string", "set_method": "MBEAN.set_log_filter_mbean", "set_mbean_type": "weblogic.management.configuration.LogFilterMBean" } ],
"DomainLogBroadcastSeverity": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "DomainLogBroadcastSeverity", "wlst_path": "WP001", "default_value": "${__NULL__:Notice}", "wlst_type": "string" } ],
"DomainLogBroadcasterBufferSize": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "DomainLogBroadcasterBufferSize", "wlst_path": "WP001", "default_value": 1, "wlst_type": "integer"} ],
"FileCount": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FileCount", "wlst_path": "WP001", "default_value": 7, "wlst_type": "integer"} ],
"FileMinSize": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FileMinSize", "wlst_path": "WP001", "default_value": 500, "wlst_type": "integer"} ],
"DomainLogBroadcasterBufferSize": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "DomainLogBroadcasterBufferSize", "wlst_path": "WP001", "default_value": 1, "production_default": "${__NULL__:10}", "wlst_type": "integer"} ],
"FileCount": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FileCount", "wlst_path": "WP001", "default_value": 7, "production_default": "${__NULL__:100}", "wlst_type": "integer"} ],
"FileMinSize": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FileMinSize", "wlst_path": "WP001", "default_value": 500, "production_default": "${__NULL__:5000}", "wlst_type": "integer"} ],
"FileName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FileName", "wlst_path": "WP001", "default_value": "${__NULL__:logs/%DOMAIN%.log}", "derived_default": "${:true}", "wlst_type": "string", "uses_path_tokens": "true" } ],
"FileTimeSpan": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "FileTimeSpan", "wlst_path": "WP001", "default_value": 24, "wlst_type": "integer"} ],
"FileTimeSpanFactor": [ {"version": "[10,)", "wlst_mode": "offline", "wlst_name": "FileTimeSpanFactor", "wlst_path": "WP001", "default_value": 3600000, "wlst_type": "long" } ],
Expand All @@ -31,13 +31,13 @@
"LoggerSeverityProperties": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "LoggerSeverityProperties", "wlst_path": "WP001", "default_value": null, "wlst_type": "properties", "preferred_model_type": "dict", "get_method": "GET" } ],
"MemoryBufferFilter": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "MemoryBufferFilter", "wlst_path": "WP001", "default_value": null, "wlst_type": "string", "set_method": "MBEAN.set_log_filter_mbean", "set_mbean_type": "weblogic.management.configuration.LogFilterMBean"} ],
"MemoryBufferSeverity": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "MemoryBufferSeverity", "wlst_path": "WP001", "default_value": "${__NULL__:Trace}", "wlst_type": "string" } ],
"MemoryBufferSize": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "MemoryBufferSize", "wlst_path": "WP001", "default_value": 10, "wlst_type": "integer"} ],
"MemoryBufferSize": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "MemoryBufferSize", "wlst_path": "WP001", "default_value": 10, "production_default": "${__NULL__:500}", "wlst_type": "integer"} ],
"Notes": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
"NumberOfFilesLimited": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "NumberOfFilesLimited", "wlst_path": "WP001", "default_value": "true", "wlst_type": "boolean"} ],
"PlatformLoggerLevels": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "PlatformLoggerLevels", "wlst_path": "WP001", "default_value": null, "wlst_type": "properties", "preferred_model_type": "dict", "get_method": "GET" } ],
"RedirectStderrToServerLogEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RedirectStderrToServerLogEnabled", "wlst_path": "WP001", "default_value": "false", "wlst_type": "boolean", "restart_required": "true"} ],
"RedirectStdoutToServerLogEnabled": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RedirectStdoutToServerLogEnabled", "wlst_path": "WP001", "default_value": "false", "wlst_type": "boolean", "restart_required": "true"} ],
"RotateLogOnStartup": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RotateLogOnStartup", "wlst_path": "WP001", "default_value": "true", "wlst_type": "boolean"} ],
"RotateLogOnStartup": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RotateLogOnStartup", "wlst_path": "WP001", "default_value": "true", "production_default": "${__NULL__:false}", "wlst_type": "boolean"} ],
"RotationTime": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RotationTime", "wlst_path": "WP001", "default_value": "00:00", "wlst_type": "string" } ],
"RotationType": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "RotationType", "wlst_path": "WP001", "default_value": "${__NULL__:bySize}", "wlst_type": "string" } ],
"ServerLoggingBridgeAtRootLoggerEnabled": [ {"version": "[12.1.3,)", "wlst_mode": "offline", "wlst_name": "ServerLoggingBridgeAtRootLoggerEnabled", "wlst_path": "WP001", "default_value": "true", "wlst_type": "boolean"} ],
Expand Down
Loading