Skip to content

Wdt 334 attributes not in lsa map not discovered #375

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added core/src/__init__.py
Empty file.
Empty file added core/src/main/__init__.py
Empty file.
188 changes: 81 additions & 107 deletions core/src/main/python/wlsdeploy/tool/discover/discoverer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from wlsdeploy.exception import exception_helper
from wlsdeploy.exception.expection_types import ExceptionType
from wlsdeploy.logging.platform_logger import PlatformLogger
from wlsdeploy.tool.util.mbean_utils import MBeanUtils
from wlsdeploy.tool.util.alias_helper import AliasHelper
from wlsdeploy.tool.util.wlst_helper import WlstHelper
from wlsdeploy.util import path_utils
Expand Down Expand Up @@ -51,6 +52,7 @@ def __init__(self, model_context, base_location, wlst_mode, aliases=None):
self._weblogic_helper = WebLogicHelper(_logger)
self._wls_version = self._weblogic_helper.get_actual_weblogic_version()
self._wlst_helper = WlstHelper(_logger, ExceptionType.DISCOVER)
self._mbean_utils = MBeanUtils(self._model_context, self._alias_helper, ExceptionType.DISCOVER)

# methods for use only by the subclasses

Expand All @@ -69,50 +71,76 @@ def _populate_model_parameters(self, dictionary, location):
if not self.wlst_cd(wlst_path, location):
return

wlst_params = self._get_attributes_for_current_location(location)
_logger.finest('WLSDPLY-06102', self._wlst_helper.get_pwd(), wlst_params, class_name=_class_name,
wlst_lsa_params = self._get_attributes_for_current_location(location)
_logger.finest('WLSDPLY-06102', self._wlst_helper.get_pwd(), wlst_lsa_params, class_name=_class_name,
method_name=_method_name)
wlst_get_params = self._get_required_attributes(location)
_logger.finest('WLSDPLY-06103', str(location), wlst_get_params,
class_name=_class_name, method_name=_method_name)
attr_dict = OrderedDict()
if wlst_params:
for wlst_param in wlst_params:
if wlst_param in wlst_get_params:
_logger.finest('WLSDPLY-06104', wlst_param, class_name=_class_name, method_name=_method_name)
try:
wlst_value = wlst_helper.get(wlst_param)
except PyWLSTException, pe:
_logger.warning('WLSDPLY-06127', wlst_param, wlst_path,
pe.getLocalizedMessage(), class_name=_class_name, method_name=_method_name)
if wlst_lsa_params is not None:
for wlst_lsa_param in wlst_lsa_params:
if wlst_lsa_param in wlst_get_params:
success, wlst_value = self._get_attribute_value_with_get(wlst_lsa_param, wlst_path)
if not success:
continue
else:
_logger.finer('WLSDPLY-06131', wlst_param, class_name=_class_name, method_name=_method_name)
wlst_value = wlst_params[wlst_param]
_logger.finer('WLSDPLY-06131', wlst_lsa_param, class_name=_class_name, method_name=_method_name)
wlst_value = wlst_lsa_params[wlst_lsa_param]
self._add_to_dictionary(dictionary, location, wlst_lsa_param, wlst_value, wlst_path)

# if type(wlst_value) == str and len(wlst_value) == 0:
# wlst_value = None

_logger.finer('WLSDPLY-06105', wlst_param, wlst_value, wlst_path, class_name=_class_name,
method_name=_method_name)
try:
model_param, model_value = self._aliases.get_model_attribute_name_and_value(location,
wlst_param,
wlst_value)
except AliasException, de:
_logger.info('WLSDPLY-06106', wlst_param, wlst_path, de.getLocalizedMessage(),
# These will come after the lsa / get params in the ordered dictionary
wlst_extra_params = self._get_additional_parameters(location)
_logger.finest('WLSDPLY-06149', str(location), wlst_extra_params,
class_name=_class_name, method_name=_method_name)
if wlst_extra_params is not None:
for wlst_extra_param in wlst_extra_params:
if wlst_extra_param in wlst_get_params:
success, wlst_value = self._get_attribute_value_with_get(wlst_extra_param, wlst_path)
if success:
self._add_to_dictionary(dictionary, location, wlst_extra_param, wlst_value, wlst_path)
else:
_logger.info('WLSDPLY-06152', wlst_extra_param, location.get_folder_path(),
class_name=_class_name, method_name=_method_name)
elif self._is_defined_attribute(location, wlst_extra_param):
_logger.info('WLSDPLY-06154', wlst_extra_param, location.get_folder_path(),
class_name=_class_name, method_name=_method_name)
else:
_logger.info('WLSDPLY-06153', wlst_extra_param, location.get_folder_path(),
class_name=_class_name, method_name=_method_name)
continue

attr_dict[model_param] = wlst_value
model_value = self._check_attribute(model_param, model_value, location)
if model_value is not None:
_logger.finer('WLSDPLY-06107', model_param, model_value, class_name=_class_name,
method_name=_method_name)
dictionary[model_param] = model_value
elif model_param is None:
_logger.finest('WLSDPLY-06108', model_param, class_name=_class_name, method_name=_method_name)
return attr_dict
def _get_attribute_value_with_get(self, wlst_get_param, wlst_path):
_method_name = '_get_attribute_value_with_get'
_logger.finest('WLSDPLY-06104', wlst_get_param, class_name=_class_name, method_name=_method_name)
success = False
wlst_value = None
try:
wlst_value = self._wlst_helper.get(wlst_get_param)
success = True
except DiscoverException, pe:
_logger.warning('WLSDPLY-06127', wlst_get_param, wlst_path, pe.getLocalizedMessage(),
class_name=_class_name, method_name=_method_name)
return success, wlst_value

def _add_to_dictionary(self, dictionary, location, wlst_param, wlst_value, wlst_path):
_method_name = '_add_to_dictionary'
_logger.finer('WLSDPLY-06105', wlst_param, wlst_value, wlst_path, class_name=_class_name,
method_name=_method_name)
try:
model_param, model_value = self._aliases.get_model_attribute_name_and_value(location,
wlst_param,
wlst_value)
except AliasException, de:
_logger.info('WLSDPLY-06106', wlst_param, wlst_path, de.getLocalizedMessage(),
class_name=_class_name, method_name=_method_name)
return

model_value = self._check_attribute(model_param, model_value, location)
if model_value is not None:
_logger.finer('WLSDPLY-06107', model_param, model_value, class_name=_class_name,
method_name=_method_name)
dictionary[model_param] = model_value
elif model_param is None:
_logger.finest('WLSDPLY-06108', model_param, class_name=_class_name, method_name=_method_name)

def _get_attributes_for_current_location(self, location):
"""
Expand All @@ -121,13 +149,7 @@ def _get_attributes_for_current_location(self, location):
:param location: context with the current location information
:return: list of attributes
"""
if self._wlst_mode == WlstModes.OFFLINE:
return self._get_attributes_for_current_location_offline(location)
else:
return self._get_attributes_for_current_location_online(location)

def _get_attributes_for_current_location_offline(self, location):
_method_name = '_get_attributes_for_current_location_offline'
_method_name = '_get_attributes_for_current_location'
attributes = []
path = self._alias_helper.get_wlst_attributes_path(location)
try:
Expand All @@ -138,37 +160,12 @@ def _get_attributes_for_current_location_offline(self, location):
method_name=_method_name)
return attributes

def _get_attributes_for_current_location_online(self, location):
_method_name = '_get_attributes_for_current_location_online'
lsa_attributes = dict()
path = self._alias_helper.get_wlst_attributes_path(location)
try:
lsa_attributes = wlst_helper.lsa(path)
mbi_attributes = _get_mbi_attribute_list(path)
if mbi_attributes:
for lsa_attribute_name in lsa_attributes:
if lsa_attribute_name in lsa_attributes and lsa_attribute_name not in mbi_attributes:
_logger.finer('WLSDPLY-06142', lsa_attribute_name)
del lsa_attributes[lsa_attribute_name]
for mbi_attribute_name in mbi_attributes:
if mbi_attribute_name not in lsa_attributes and mbi_attribute_name in mbi_attributes:
# don't count on the item in the get required list in caller, just get the value
# and add it to our lsa list
_logger.finer('WLSDPLY-06141', mbi_attribute_name, class_name=_class_name,
method_name=_method_name)
lsa_attributes[mbi_attribute_name] = wlst_helper.get(mbi_attribute_name)
except PyWLSTException, pe:
name = location.get_model_folders()[-1]
_logger.fine('WLSDPLY-06109', name, str(location), pe.getLocalizedMessage(), class_name=_class_name,
method_name=_method_name)
return lsa_attributes

def _is_defined_attribute(self, location, wlst_name):
attribute = False
try:
if self._aliases.get_model_attribute_name(location, wlst_name):
if self._alias_helper.get_model_attribute_name(location, wlst_name, check_read_only=False):
attribute = True
except AliasException:
except DiscoverException:
pass
return attribute

Expand All @@ -179,7 +176,7 @@ def _get_required_attributes(self, location):
:return: list of attributes that require wlst.get
"""
_method_name = '_get_required_attributes'
attributes = []
attributes = list()
try:
attributes = self._alias_helper.get_wlst_get_required_attribute_names(location)
except DiscoverException, de:
Expand All @@ -188,6 +185,20 @@ def _get_required_attributes(self, location):
class_name=_class_name, method_name=_method_name)
return attributes

def _get_additional_parameters(self, location):
_method_name = '_get_additional_parameters'
other_attributes = list()
try:
other_attributes = self._mbean_utils.get_attributes_not_in_lsa_map(location)
except DiscoverException, de:
name = 'DomainConfig'
folders = location.get_model_folders()
if len(folders) > 0:
name = location.get_model_folders()[-1]
_logger.info('WLSDPLY-06150', name, location.get_folder_path(), de.getLocalizedMessage(),
class_name=_class_name, method_name=_method_name)
return other_attributes

def _mbean_names_exist(self, location):
"""
Check to see if there are any configured MBeans for the current location
Expand Down Expand Up @@ -687,47 +698,10 @@ def convert_to_absolute_path(relative_to, file_name):
return file_name


def _get_mbi_attribute_list(path):
attribute_list = []
for mbean_attribute_info in wlst_helper.get_mbi(path).getAttributes():
if _is_attribute(mbean_attribute_info):
attribute_list.append(mbean_attribute_info.getName())
return attribute_list


def _is_attribute(attributes_info):
return _is_attribute_type(attributes_info) or _is_valid_reference(attributes_info)


def _is_valid_reference(attribute_info):
# check again after all done to see whether need to use get deprecated
return _is_reference(attribute_info) and (
attribute_info.isWritable() or not _is_deprecated(attribute_info))


def _is_reference(mbean_attribute_info):
return mbean_attribute_info.getDescriptor().getFieldValue('com.bea.relationship') == 'reference'


def _is_deprecated(mbean_attribute_info):
deprecated_version = mbean_attribute_info.getDescriptor().getFieldValue('deprecated')
return deprecated_version is not None and deprecated_version != 'null' and len(deprecated_version) > 1


def _is_containment(mbean_attribute_info):
return mbean_attribute_info.getDescriptor().getFieldValue('com.bea.relationship') == 'containment'


def _is_attribute_type(attribute_info):
_method_name = '_is_attribute_type'
if not attribute_info.isWritable() and _is_deprecated(attribute_info):
_logger.finer('WLSDPLY-06143', attribute_info.getName(), wlst_helper.get_pwd(),
class_name=_class_name, method_name=_method_name)
return attribute_info.getDescriptor().getFieldValue(
'descriptorType') == 'Attribute' and attribute_info.getDescriptor().getFieldValue(
'com.bea.relationship') is None and (attribute_info.isWritable() or not _is_deprecated(attribute_info))


def _massage_online_folders(lsc_folders):
_method_name = '_massage_online_folders'
location = wlst_helper.get_pwd()
Expand Down
32 changes: 32 additions & 0 deletions core/src/main/python/wlsdeploy/tool/util/alias_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ def get_model_attribute_name_and_value(self, location, wlst_name, wlst_value):
raise ex
return model_name, model_value

def get_model_attribute_name(self, location, wlst_attribute_name, check_read_only=True):
"""
Returns the model attribute name for the specified WLST attribute name. If the model attribute name
is not valid for the version or the attribute is marked as read-only, and the check_read_only flag
is True, return None

:param location: the location
:param wlst_attribute_name: the WLST attribute name
:param check_read_only: Defaults to True. If False, return the WLST attribute name even if read only
:return: matching model attribute name
:raises: BundleAwareException: if a AliasException is thrown by the aliases
"""
_method_name = 'get_model_attribute_name'
try:
model_name = self.__aliases.get_model_attribute_name(location, wlst_attribute_name, check_read_only)
except AliasException, ae:
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19039', str(location),
ae.getLocalizedMessage(), error=ae)
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
raise ex
return model_name

def get_model_subfolder_names(self, location):
"""
Get the model subfolder names for the specified location.
Expand Down Expand Up @@ -742,6 +764,16 @@ def decrypt_password(self, text):
raise ex
return result

def get_ignore_attribute_names(self):
"""
Return the list of ignored attribute names - the attributes for all MBeans that are not discovered or set.
:return: list of MBean attribute names to ignore
"""
_method_name = 'get_ignore_attribute_names'
result = self.__aliases.get_ignore_attribute_names()
self.__logger.finest('WLSDPLY-19038', result, class_name=self.__class_name, method_name=_method_name)
return result

###########################################################################
# Convenience Methods #
###########################################################################
Expand Down
Loading