Skip to content

Commit 9dc86de

Browse files
Merge pull request #375 from oracle/WDT-334-attributes-not-in-lsa-map-not-discovered
Wdt 334 attributes not in lsa map not discovered
2 parents 50976e2 + c5fdc78 commit 9dc86de

File tree

13 files changed

+977
-114
lines changed

13 files changed

+977
-114
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: 81 additions & 107 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, self._alias_helper, ExceptionType.DISCOVER)
5456

5557
# methods for use only by the subclasses
5658

@@ -69,50 +71,76 @@ 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 in wlst_get_params:
98+
success, wlst_value = self._get_attribute_value_with_get(wlst_extra_param, wlst_path)
99+
if success:
100+
self._add_to_dictionary(dictionary, location, wlst_extra_param, wlst_value, wlst_path)
101+
else:
102+
_logger.info('WLSDPLY-06152', wlst_extra_param, location.get_folder_path(),
103+
class_name=_class_name, method_name=_method_name)
104+
elif self._is_defined_attribute(location, wlst_extra_param):
105+
_logger.info('WLSDPLY-06154', wlst_extra_param, location.get_folder_path(),
106+
class_name=_class_name, method_name=_method_name)
107+
else:
108+
_logger.info('WLSDPLY-06153', wlst_extra_param, location.get_folder_path(),
104109
class_name=_class_name, method_name=_method_name)
105-
continue
106110

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
111+
def _get_attribute_value_with_get(self, wlst_get_param, wlst_path):
112+
_method_name = '_get_attribute_value_with_get'
113+
_logger.finest('WLSDPLY-06104', wlst_get_param, class_name=_class_name, method_name=_method_name)
114+
success = False
115+
wlst_value = None
116+
try:
117+
wlst_value = self._wlst_helper.get(wlst_get_param)
118+
success = True
119+
except DiscoverException, pe:
120+
_logger.warning('WLSDPLY-06127', wlst_get_param, wlst_path, pe.getLocalizedMessage(),
121+
class_name=_class_name, method_name=_method_name)
122+
return success, wlst_value
123+
124+
def _add_to_dictionary(self, dictionary, location, wlst_param, wlst_value, wlst_path):
125+
_method_name = '_add_to_dictionary'
126+
_logger.finer('WLSDPLY-06105', wlst_param, wlst_value, wlst_path, class_name=_class_name,
127+
method_name=_method_name)
128+
try:
129+
model_param, model_value = self._aliases.get_model_attribute_name_and_value(location,
130+
wlst_param,
131+
wlst_value)
132+
except AliasException, de:
133+
_logger.info('WLSDPLY-06106', wlst_param, wlst_path, de.getLocalizedMessage(),
134+
class_name=_class_name, method_name=_method_name)
135+
return
136+
137+
model_value = self._check_attribute(model_param, model_value, location)
138+
if model_value is not None:
139+
_logger.finer('WLSDPLY-06107', model_param, model_value, class_name=_class_name,
140+
method_name=_method_name)
141+
dictionary[model_param] = model_value
142+
elif model_param is None:
143+
_logger.finest('WLSDPLY-06108', model_param, class_name=_class_name, method_name=_method_name)
116144

117145
def _get_attributes_for_current_location(self, location):
118146
"""
@@ -121,13 +149,7 @@ def _get_attributes_for_current_location(self, location):
121149
:param location: context with the current location information
122150
:return: list of attributes
123151
"""
124-
if self._wlst_mode == WlstModes.OFFLINE:
125-
return self._get_attributes_for_current_location_offline(location)
126-
else:
127-
return self._get_attributes_for_current_location_online(location)
128-
129-
def _get_attributes_for_current_location_offline(self, location):
130-
_method_name = '_get_attributes_for_current_location_offline'
152+
_method_name = '_get_attributes_for_current_location'
131153
attributes = []
132154
path = self._alias_helper.get_wlst_attributes_path(location)
133155
try:
@@ -138,37 +160,12 @@ def _get_attributes_for_current_location_offline(self, location):
138160
method_name=_method_name)
139161
return attributes
140162

141-
def _get_attributes_for_current_location_online(self, location):
142-
_method_name = '_get_attributes_for_current_location_online'
143-
lsa_attributes = dict()
144-
path = self._alias_helper.get_wlst_attributes_path(location)
145-
try:
146-
lsa_attributes = wlst_helper.lsa(path)
147-
mbi_attributes = _get_mbi_attribute_list(path)
148-
if mbi_attributes:
149-
for lsa_attribute_name in lsa_attributes:
150-
if lsa_attribute_name in lsa_attributes and lsa_attribute_name not in mbi_attributes:
151-
_logger.finer('WLSDPLY-06142', lsa_attribute_name)
152-
del lsa_attributes[lsa_attribute_name]
153-
for mbi_attribute_name in mbi_attributes:
154-
if mbi_attribute_name not in lsa_attributes and mbi_attribute_name in mbi_attributes:
155-
# don't count on the item in the get required list in caller, just get the value
156-
# and add it to our lsa list
157-
_logger.finer('WLSDPLY-06141', mbi_attribute_name, class_name=_class_name,
158-
method_name=_method_name)
159-
lsa_attributes[mbi_attribute_name] = wlst_helper.get(mbi_attribute_name)
160-
except PyWLSTException, pe:
161-
name = location.get_model_folders()[-1]
162-
_logger.fine('WLSDPLY-06109', name, str(location), pe.getLocalizedMessage(), class_name=_class_name,
163-
method_name=_method_name)
164-
return lsa_attributes
165-
166163
def _is_defined_attribute(self, location, wlst_name):
167164
attribute = False
168165
try:
169-
if self._aliases.get_model_attribute_name(location, wlst_name):
166+
if self._alias_helper.get_model_attribute_name(location, wlst_name, check_read_only=False):
170167
attribute = True
171-
except AliasException:
168+
except DiscoverException:
172169
pass
173170
return attribute
174171

@@ -179,7 +176,7 @@ def _get_required_attributes(self, location):
179176
:return: list of attributes that require wlst.get
180177
"""
181178
_method_name = '_get_required_attributes'
182-
attributes = []
179+
attributes = list()
183180
try:
184181
attributes = self._alias_helper.get_wlst_get_required_attribute_names(location)
185182
except DiscoverException, de:
@@ -188,6 +185,20 @@ def _get_required_attributes(self, location):
188185
class_name=_class_name, method_name=_method_name)
189186
return attributes
190187

188+
def _get_additional_parameters(self, location):
189+
_method_name = '_get_additional_parameters'
190+
other_attributes = list()
191+
try:
192+
other_attributes = self._mbean_utils.get_attributes_not_in_lsa_map(location)
193+
except DiscoverException, de:
194+
name = 'DomainConfig'
195+
folders = location.get_model_folders()
196+
if len(folders) > 0:
197+
name = location.get_model_folders()[-1]
198+
_logger.info('WLSDPLY-06150', name, location.get_folder_path(), de.getLocalizedMessage(),
199+
class_name=_class_name, method_name=_method_name)
200+
return other_attributes
201+
191202
def _mbean_names_exist(self, location):
192203
"""
193204
Check to see if there are any configured MBeans for the current location
@@ -687,47 +698,10 @@ def convert_to_absolute_path(relative_to, file_name):
687698
return file_name
688699

689700

690-
def _get_mbi_attribute_list(path):
691-
attribute_list = []
692-
for mbean_attribute_info in wlst_helper.get_mbi(path).getAttributes():
693-
if _is_attribute(mbean_attribute_info):
694-
attribute_list.append(mbean_attribute_info.getName())
695-
return attribute_list
696-
697-
698-
def _is_attribute(attributes_info):
699-
return _is_attribute_type(attributes_info) or _is_valid_reference(attributes_info)
700-
701-
702-
def _is_valid_reference(attribute_info):
703-
# check again after all done to see whether need to use get deprecated
704-
return _is_reference(attribute_info) and (
705-
attribute_info.isWritable() or not _is_deprecated(attribute_info))
706-
707-
708-
def _is_reference(mbean_attribute_info):
709-
return mbean_attribute_info.getDescriptor().getFieldValue('com.bea.relationship') == 'reference'
710-
711-
712-
def _is_deprecated(mbean_attribute_info):
713-
deprecated_version = mbean_attribute_info.getDescriptor().getFieldValue('deprecated')
714-
return deprecated_version is not None and deprecated_version != 'null' and len(deprecated_version) > 1
715-
716-
717701
def _is_containment(mbean_attribute_info):
718702
return mbean_attribute_info.getDescriptor().getFieldValue('com.bea.relationship') == 'containment'
719703

720704

721-
def _is_attribute_type(attribute_info):
722-
_method_name = '_is_attribute_type'
723-
if not attribute_info.isWritable() and _is_deprecated(attribute_info):
724-
_logger.finer('WLSDPLY-06143', attribute_info.getName(), wlst_helper.get_pwd(),
725-
class_name=_class_name, method_name=_method_name)
726-
return attribute_info.getDescriptor().getFieldValue(
727-
'descriptorType') == 'Attribute' and attribute_info.getDescriptor().getFieldValue(
728-
'com.bea.relationship') is None and (attribute_info.isWritable() or not _is_deprecated(attribute_info))
729-
730-
731705
def _massage_online_folders(lsc_folders):
732706
_method_name = '_massage_online_folders'
733707
location = wlst_helper.get_pwd()

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@ def get_model_attribute_name_and_value(self, location, wlst_name, wlst_value):
3939
raise ex
4040
return model_name, model_value
4141

42+
def get_model_attribute_name(self, location, wlst_attribute_name, check_read_only=True):
43+
"""
44+
Returns the model attribute name for the specified WLST attribute name. If the model attribute name
45+
is not valid for the version or the attribute is marked as read-only, and the check_read_only flag
46+
is True, return None
47+
48+
:param location: the location
49+
:param wlst_attribute_name: the WLST attribute name
50+
:param check_read_only: Defaults to True. If False, return the WLST attribute name even if read only
51+
:return: matching model attribute name
52+
:raises: BundleAwareException: if a AliasException is thrown by the aliases
53+
"""
54+
_method_name = 'get_model_attribute_name'
55+
try:
56+
model_name = self.__aliases.get_model_attribute_name(location, wlst_attribute_name, check_read_only)
57+
except AliasException, ae:
58+
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19039', str(location),
59+
ae.getLocalizedMessage(), error=ae)
60+
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
61+
raise ex
62+
return model_name
63+
4264
def get_model_subfolder_names(self, location):
4365
"""
4466
Get the model subfolder names for the specified location.
@@ -742,6 +764,16 @@ def decrypt_password(self, text):
742764
raise ex
743765
return result
744766

767+
def get_ignore_attribute_names(self):
768+
"""
769+
Return the list of ignored attribute names - the attributes for all MBeans that are not discovered or set.
770+
:return: list of MBean attribute names to ignore
771+
"""
772+
_method_name = 'get_ignore_attribute_names'
773+
result = self.__aliases.get_ignore_attribute_names()
774+
self.__logger.finest('WLSDPLY-19038', result, class_name=self.__class_name, method_name=_method_name)
775+
return result
776+
745777
###########################################################################
746778
# Convenience Methods #
747779
###########################################################################

0 commit comments

Comments
 (0)