Skip to content

Commit bebeb13

Browse files
Add MBean utility class to WDT to provide additional information about mbean attributes
1 parent 6abc8b9 commit bebeb13

File tree

9 files changed

+756
-37
lines changed

9 files changed

+756
-37
lines changed

core/src/__init__.py

Whitespace-only changes.

core/src/main/__init__.py

Whitespace-only changes.

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

Lines changed: 71 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from wlsdeploy.exception import exception_helper
1717
from wlsdeploy.exception.expection_types import ExceptionType
1818
from wlsdeploy.logging.platform_logger import PlatformLogger
19+
from wlsdeploy.tool.util.mbean_utils import MBeanUtils
1920
from wlsdeploy.tool.util.alias_helper import AliasHelper
2021
from wlsdeploy.tool.util.wlst_helper import WlstHelper
2122
from wlsdeploy.util import path_utils
@@ -51,6 +52,7 @@ def __init__(self, model_context, base_location, wlst_mode, aliases=None):
5152
self._weblogic_helper = WebLogicHelper(_logger)
5253
self._wls_version = self._weblogic_helper.get_actual_weblogic_version()
5354
self._wlst_helper = WlstHelper(_logger, ExceptionType.DISCOVER)
55+
self._mbean_utils = MBeanUtils(self._model_context, ExceptionType.DISCOVER)
5456

5557
# methods for use only by the subclasses
5658

@@ -69,50 +71,69 @@ def _populate_model_parameters(self, dictionary, location):
6971
if not self.wlst_cd(wlst_path, location):
7072
return
7173

72-
wlst_params = self._get_attributes_for_current_location(location)
73-
_logger.finest('WLSDPLY-06102', self._wlst_helper.get_pwd(), wlst_params, class_name=_class_name,
74+
wlst_lsa_params = self._get_attributes_for_current_location(location)
75+
_logger.finest('WLSDPLY-06102', self._wlst_helper.get_pwd(), wlst_lsa_params, class_name=_class_name,
7476
method_name=_method_name)
7577
wlst_get_params = self._get_required_attributes(location)
7678
_logger.finest('WLSDPLY-06103', str(location), wlst_get_params,
7779
class_name=_class_name, method_name=_method_name)
78-
attr_dict = OrderedDict()
79-
if wlst_params:
80-
for wlst_param in wlst_params:
81-
if wlst_param in wlst_get_params:
82-
_logger.finest('WLSDPLY-06104', wlst_param, class_name=_class_name, method_name=_method_name)
83-
try:
84-
wlst_value = wlst_helper.get(wlst_param)
85-
except PyWLSTException, pe:
86-
_logger.warning('WLSDPLY-06127', wlst_param, wlst_path,
87-
pe.getLocalizedMessage(), class_name=_class_name, method_name=_method_name)
80+
if wlst_lsa_params is not None:
81+
for wlst_lsa_param in wlst_lsa_params:
82+
if wlst_lsa_param in wlst_get_params:
83+
success, wlst_value = self._get_attribute_value_with_get(wlst_lsa_param, wlst_path)
84+
if not success:
8885
continue
8986
else:
90-
_logger.finer('WLSDPLY-06131', wlst_param, class_name=_class_name, method_name=_method_name)
91-
wlst_value = wlst_params[wlst_param]
87+
_logger.finer('WLSDPLY-06131', wlst_lsa_param, class_name=_class_name, method_name=_method_name)
88+
wlst_value = wlst_lsa_params[wlst_lsa_param]
89+
self._add_to_dictionary(dictionary, location, wlst_lsa_param, wlst_value, wlst_path)
9290

93-
# if type(wlst_value) == str and len(wlst_value) == 0:
94-
# wlst_value = None
95-
96-
_logger.finer('WLSDPLY-06105', wlst_param, wlst_value, wlst_path, class_name=_class_name,
97-
method_name=_method_name)
98-
try:
99-
model_param, model_value = self._aliases.get_model_attribute_name_and_value(location,
100-
wlst_param,
101-
wlst_value)
102-
except AliasException, de:
103-
_logger.info('WLSDPLY-06106', wlst_param, wlst_path, de.getLocalizedMessage(),
91+
# These will come after the lsa / get params in the ordered dictionary
92+
wlst_extra_params = self._get_additional_parameters(location)
93+
_logger.finest('WLSDPLY-06149', str(location), wlst_extra_params,
94+
class_name=_class_name, method_name=_method_name)
95+
if wlst_extra_params is not None:
96+
for wlst_extra_param in wlst_extra_params:
97+
if wlst_extra_param not in wlst_get_params:
98+
_logger.info('WLSDPLY-06148', wlst_extra_param, str(location),
10499
class_name=_class_name, method_name=_method_name)
105-
continue
100+
success, wlst_value = self._get_attribute_value_with_get(wlst_extra_param, wlst_path)
101+
if success:
102+
self._add_to_dictionary(dictionary, location, wlst_extra_param, wlst_value, wlst_path)
103+
104+
def _get_attribute_value_with_get(self, wlst_get_param, wlst_path):
105+
_method_name = '_get_attribute_value_with_get'
106+
_logger.finest('WLSDPLY-06104', wlst_get_param, class_name=_class_name, method_name=_method_name)
107+
success = False
108+
wlst_value = None
109+
try:
110+
wlst_value = self._wlst_helper.get(wlst_get_param)
111+
success = True
112+
except DiscoverException, pe:
113+
_logger.warning('WLSDPLY-06127', wlst_get_param, wlst_path, pe.getLocalizedMessage(),
114+
class_name=_class_name, method_name=_method_name)
115+
return success, wlst_value
106116

107-
attr_dict[model_param] = wlst_value
108-
model_value = self._check_attribute(model_param, model_value, location)
109-
if model_value is not None:
110-
_logger.finer('WLSDPLY-06107', model_param, model_value, class_name=_class_name,
111-
method_name=_method_name)
112-
dictionary[model_param] = model_value
113-
elif model_param is None:
114-
_logger.finest('WLSDPLY-06108', model_param, class_name=_class_name, method_name=_method_name)
115-
return attr_dict
117+
def _add_to_dictionary(self, dictionary, location, wlst_param, wlst_value, wlst_path):
118+
_method_name = '_add_to_dictionary'
119+
_logger.finer('WLSDPLY-06105', wlst_param, wlst_value, wlst_path, class_name=_class_name,
120+
method_name=_method_name)
121+
try:
122+
model_param, model_value = self._aliases.get_model_attribute_name_and_value(location,
123+
wlst_param,
124+
wlst_value)
125+
except AliasException, de:
126+
_logger.info('WLSDPLY-06106', wlst_param, wlst_path, de.getLocalizedMessage(),
127+
class_name=_class_name, method_name=_method_name)
128+
return
129+
130+
model_value = self._check_attribute(model_param, model_value, location)
131+
if model_value is not None:
132+
_logger.finer('WLSDPLY-06107', model_param, model_value, class_name=_class_name,
133+
method_name=_method_name)
134+
dictionary[model_param] = model_value
135+
elif model_param is None:
136+
_logger.finest('WLSDPLY-06108', model_param, class_name=_class_name, method_name=_method_name)
116137

117138
def _get_attributes_for_current_location(self, location):
118139
"""
@@ -179,7 +200,7 @@ def _get_required_attributes(self, location):
179200
:return: list of attributes that require wlst.get
180201
"""
181202
_method_name = '_get_required_attributes'
182-
attributes = []
203+
attributes = list()
183204
try:
184205
attributes = self._alias_helper.get_wlst_get_required_attribute_names(location)
185206
except DiscoverException, de:
@@ -188,6 +209,20 @@ def _get_required_attributes(self, location):
188209
class_name=_class_name, method_name=_method_name)
189210
return attributes
190211

212+
def _get_additional_parameters(self, location):
213+
_method_name = '_get_additional_parameters'
214+
other_attributes = list()
215+
try:
216+
other_attributes = self._mbean_utils.get_attributes_not_in_lsa_map(location)
217+
except DiscoverException, de:
218+
name = 'DomainConfig'
219+
folders = location.get_model_folders()
220+
if len(folders) > 0:
221+
name = location.get_model_folders()[-1]
222+
_logger.info('WLSDPLY-06150', name, location.get_folder_path(), de.getLocalizedMessage(),
223+
class_name=_class_name, method_name=_method_name)
224+
return other_attributes
225+
191226
def _mbean_names_exist(self, location):
192227
"""
193228
Check to see if there are any configured MBeans for the current location

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,16 @@ def decrypt_password(self, text):
742742
raise ex
743743
return result
744744

745+
def get_ignore_attribute_names(self):
746+
"""
747+
Return the list of ignored attribute names - the attributes for all MBeans that are not discovered or set.
748+
:return: list of MBean attribute names to ignore
749+
"""
750+
_method_name = 'get_ignore_attribute_names'
751+
result = self.__aliases.get_ignore_attribute_names()
752+
self.__logger.finest('WLSDPLY-19038', result, class_name=self.__class_name, method_name=_method_name)
753+
return result
754+
745755
###########################################################################
746756
# Convenience Methods #
747757
###########################################################################

0 commit comments

Comments
 (0)