Skip to content

Commit 46043b1

Browse files
Filter out Provider string in 1036 and 1211
1 parent 2516653 commit 46043b1

File tree

11 files changed

+434
-30
lines changed

11 files changed

+434
-30
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
GET_MBEAN_TYPE = 'get_mbean_type'
1919
GET_METHOD = 'get_method'
2020
MERGE = 'merge'
21+
METHOD = 'METHOD'
2122
MODEL_NAME = 'model_name'
2223
NAME_VALUE = 'name_value'
2324
PASSWORD_TOKEN = "--FIX ME--"
@@ -59,6 +60,7 @@
5960
GET = 'GET'
6061
LSA = 'LSA'
6162
NONE = 'NONE'
63+
NAMES = 'NAMES'
6264

6365
# set_method values
6466
MBEAN = 'MBEAN'

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,21 @@ def get_wlst_create_path_for_location(self, location):
429429
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
430430
return result
431431

432+
def get_folder_get_method_for_location(self, location):
433+
"""
434+
Return the value of the folder get_method attribute if present.
435+
:param location: current location context of the folder
436+
:return: String value, or None if not present
437+
"""
438+
_method_name = 'get_folder_get_method_for_location'
439+
_logger.entering(str(location), class_name=_class_name, method_name=_method_name)
440+
folder_dict = self.__get_dictionary_for_location(location, False)
441+
get_method = None
442+
if folder_dict is not None and GET_METHOD in folder_dict and len(folder_dict[GET_METHOD]) > 0:
443+
get_method = folder_dict[GET_METHOD]
444+
_logger.exiting(class_name=_class_name, method_name=_method_name, result=get_method)
445+
return get_method
446+
432447
def is_location_child_folder_type(self, location, child_folders_type):
433448
"""
434449
Does the location folder have the specified child_folders_type?
@@ -1092,6 +1107,7 @@ def __apply_wlst_context_changes(self, path_name, alias_dict, parent_dict):
10921107
#
10931108
# First, determine if this dictionary is even relevant to the current WLS version.
10941109
#
1110+
self.__resolve_folder_params(path_name, alias_dict)
10951111
if not self.__use_alias_dict(path_name, alias_dict, parent_dict):
10961112
return None
10971113

@@ -1122,6 +1138,9 @@ def __apply_wlst_context_changes(self, path_name, alias_dict, parent_dict):
11221138
if DEFAULT_NAME_VALUE in alias_dict:
11231139
result[DEFAULT_NAME_VALUE] = self._resolve_curly_braces(alias_dict[DEFAULT_NAME_VALUE])
11241140

1141+
if GET_METHOD in alias_dict:
1142+
result[GET_METHOD] = self._resolve_curly_braces(alias_dict[GET_METHOD])
1143+
11251144
if WLST_PATHS in alias_dict:
11261145
wlst_paths = alias_dict[WLST_PATHS]
11271146
result_wlst_paths = dict()
@@ -1242,7 +1261,7 @@ def __test_dictionary(self, path_name, alias_dict):
12421261
return self.__is_version(path_name, alias_dict) and self.__is_wlst_mode(path_name, alias_dict)
12431262

12441263
def __use_alias_dict(self, path_name, alias_dict, parent_dict):
1245-
self.__resolve_folder_params(path_name, alias_dict)
1264+
12461265
if not self.__is_version(path_name, alias_dict):
12471266
_add_to_unresolved_folders(path_name, parent_dict, alias_utils.get_dictionary_version(alias_dict))
12481267
return False
@@ -1259,6 +1278,9 @@ def __resolve_folder_params(self, path_name, alias_dict):
12591278
contain folder parameters that are different depending on the combination. Once
12601279
a folder parameter version has been selected, then all the folder parameters in the
12611280
valid entry are added to the alias_dict dictionary parameters.
1281+
1282+
Do not add attributes or folders from the folder_params to the folder. These are not allowed.
1283+
Resolve the folder params curly braces
12621284
:param alias_dict:
12631285
:return:
12641286
"""
@@ -1280,7 +1302,11 @@ def __resolve_folder_params(self, path_name, alias_dict):
12801302
add_entry = folder_set
12811303
break
12821304
for key, value in add_entry.iteritems():
1283-
alias_dict[key] = value
1305+
if key not in [ ATTRIBUTES, FOLDERS ]:
1306+
alias_dict[key] = value
1307+
else:
1308+
_logger.fine('WLSDPLY-08136', path_name, value, class_name=_class_name,
1309+
method_name=_method_name)
12841310

12851311
def __resolve_attribute_by_wlst_context(self, path_name, attr_name, attrs_dict):
12861312
"""

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

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
from java.lang import String
@@ -35,7 +35,9 @@
3535
from wlsdeploy.aliases.alias_constants import LSA
3636
from wlsdeploy.aliases.alias_constants import MBEAN
3737
from wlsdeploy.aliases.alias_constants import MERGE
38+
from wlsdeploy.aliases.alias_constants import METHOD
3839
from wlsdeploy.aliases.alias_constants import MODEL_NAME
40+
from wlsdeploy.aliases.alias_constants import NAMES
3941
from wlsdeploy.aliases.alias_constants import PASSWORD
4042
from wlsdeploy.aliases.alias_constants import PASSWORD_TOKEN
4143
from wlsdeploy.aliases.alias_constants import PREFERRED_MODEL_TYPE
@@ -93,6 +95,13 @@ def get_mode_enum(self):
9395
"""
9496
return self._wlst_mode
9597

98+
def get_version(self):
99+
"""
100+
Get the version instance
101+
:return: version of this aliases instance
102+
"""
103+
return self._wls_version
104+
96105
def get_model_top_level_folder_names(self):
97106
"""
98107
Returns a list of the recognized top-level model folders corresponding to the known WLST top-level folders.
@@ -251,6 +260,24 @@ def requires_artificial_type_subfolder_handling(self, location):
251260
return self._alias_entries.is_location_child_folder_type(location,
252261
ChildFoldersTypes.MULTIPLE_WITH_TYPE_SUBFOLDER)
253262

263+
def get_folder_names_method(self, location):
264+
"""
265+
Return the method_name from the folder get_method attribute.
266+
None if not present for the folder. The get_method must start
267+
with "NAMES." or None is returned. The "NAMES." prefix is
268+
stripped from the method name. The NAMES method returns a
269+
list of mbean names at the current location.
270+
:param location: current location context
271+
:return: method name if NAMES method is defined for the folder
272+
"""
273+
names_method = None
274+
get_method = self._alias_entries.get_folder_get_method_for_location(location)
275+
method_type = NAMES + '.'
276+
if get_method and get_method.startswith(method_type):
277+
names_method = get_method[len(method_type):]
278+
279+
return names_method
280+
254281
def supports_single_mbean_instance(self, location):
255282
"""
256283
Does the location folder specified support only a single MBean instance of the parent node type?
@@ -500,14 +527,42 @@ def get_wlst_lsa_required_attribute_names(self, location):
500527

501528
return wlst_attribute_names
502529

530+
def get_wlst_method_required_attribute_names(self, location):
531+
"""
532+
Get the list of attribute names that have special methods that will get the attribute
533+
value using wlst.
534+
:param location: the location
535+
:return: map[string=string]: the map of attribute names and the get method to invoke
536+
:raises: AliasException: if an error occurs due to a bad location or bad alias data
537+
"""
538+
_method_name = 'get_wlst_method_required_attribute_names'
539+
540+
wlst_attribute_names = dict()
541+
542+
module_folder = self._alias_entries.get_dictionary_for_location(location)
543+
544+
if ATTRIBUTES not in module_folder:
545+
ex = exception_helper.create_alias_exception('WLSDPLY-08400', location.get_folder_path())
546+
self._logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
547+
raise ex
548+
549+
for key, value in module_folder[ATTRIBUTES].iteritems():
550+
if GET_METHOD in value and value[GET_METHOD].startswith(METHOD):
551+
get_method_value_components = value[GET_METHOD].split('.')
552+
if len(get_method_value_components) == 2:
553+
attr_get_method_name = get_method_value_components[1]
554+
wlst_attribute_names[value[WLST_NAME]] = attr_get_method_name
555+
556+
return wlst_attribute_names
557+
503558
def get_wlst_get_returns_mbean_attribute_names_and_types(self, location):
504559
"""
505560
Get the dictionary of attribute names and types that have their get_mbean_type specified.
506561
:param location: the location
507562
:return: dictionary: a dictionary with the attribute names as keys and the MBean types as values
508563
:raises: AliasException: if an error occurs due to a bad location or bad alias data
509564
"""
510-
_method_name = 'get_wlst_get_required_attribute_names'
565+
_method_name = 'get_wlst_get_returns_mbean_attribute_names_and_types'
511566

512567
wlst_attribute_names = dict()
513568

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

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
import javaos as os
@@ -16,6 +16,8 @@
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.attribute_getter import AttributeGetter
20+
from wlsdeploy.tool.util.mbean_getter import MBeanGetter
1921
from wlsdeploy.tool.util.alias_helper import AliasHelper
2022
from wlsdeploy.tool.util.wlst_helper import WlstHelper
2123
from wlsdeploy.util import path_utils
@@ -50,6 +52,7 @@ def __init__(self, model_context, base_location, wlst_mode, aliases=None):
5052
self._att_handler_map = OrderedDict()
5153
self._wls_version = WebLogicHelper(_logger).get_actual_weblogic_version()
5254
self._wlst_helper = WlstHelper(_logger, ExceptionType.DISCOVER)
55+
self._mbean_getter = MBeanGetter(self._aliases, ExceptionType.DISCOVER, _logger)
5356

5457
# methods for use only by the subclasses
5558

@@ -174,8 +177,8 @@ def _is_defined_attribute(self, location, wlst_name):
174177
def _get_required_attributes(self, location):
175178
"""
176179
Use get for all online attributes, and use the attribute names in the
177-
:param location:
178-
:return:
180+
:param location: current location context
181+
:return: list of attributes that require wlst.get
179182
"""
180183
_method_name = '_get_required_attributes'
181184
attributes = []
@@ -187,6 +190,22 @@ def _get_required_attributes(self, location):
187190
class_name=_class_name, method_name=_method_name)
188191
return attributes
189192

193+
def _method_required_attributes(self, location):
194+
"""
195+
Use a special method to get the online attribute.
196+
:param location: current location context
197+
:return: map of attributes that require special processing via a method
198+
"""
199+
_method_name = '_method_required_attributes'
200+
attributes = dict()
201+
try:
202+
attributes = self._alias_helper.get_wlst_get_required_attribute_names(location)
203+
except DiscoverException, de:
204+
name = location.get_model_folders()[-1]
205+
_logger.warning('WLSDPLY-06109', name, location.get_folder_path(), de.getLocalizedMessage(),
206+
class_name=_class_name, method_name=_method_name)
207+
return attributes
208+
190209
def _mbean_names_exist(self, location):
191210
"""
192211
Check to see if there are any configured MBeans for the current location
@@ -239,7 +258,14 @@ def _find_names_in_folder(self, location):
239258
_logger.finest('WLSDPLY-06111', folder_path, class_name=_class_name, method_name=_method_name)
240259
if wlst_helper.path_exists(folder_path):
241260
self.wlst_cd(folder_path, location)
242-
names = self._wlst_helper.lsc()
261+
getter_method = self._alias_helper.get_folder_names_method(location)
262+
if getter_method:
263+
_logger.finer('WLSDPLY-06149', getter_method, location.get_folder_path(), class_name=_class_name,
264+
method_name=_method_name)
265+
names = self._call_method_to_get_mbean_names(location, getter_method)
266+
else:
267+
names = self._wlst_helper.lsc()
268+
_logger.finest('WLSDPLY-06146', names, location, class_name=_class_name, method_name=_method_name)
243269
return names
244270

245271
def _find_singleton_name_in_folder(self, location):
@@ -268,6 +294,7 @@ def _find_subfolders(self, location):
268294
return self._find_subfolders_offline(location)
269295
else:
270296
return self._find_subfolders_online(location)
297+
271298
def _find_subfolders_offline(self, location):
272299
"""
273300
Find the subfolders of the current location.
@@ -360,6 +387,7 @@ def _discover_artificial_folder(self, model_subfolder_name, location, name_token
360387
names = self._find_names_in_folder(location)
361388
if names is not None:
362389
for name in names:
390+
_logger.fine('Checking folder name {0}', name)
363391
location.add_name_token(name_token, name)
364392
artificial = self._get_artificial_type(location)
365393
if artificial is None:
@@ -613,6 +641,22 @@ def _get_wlst_attributes(self, location):
613641
continue
614642
return wlst_attributes
615643

644+
def _call_method_to_get_mbean_names(self, location, getter_method):
645+
_method_name = '_call_method_to_get_mbean_names'
646+
mbean_names = []
647+
if getter_method is not None:
648+
try:
649+
_logger.finest('WLSDPLY-12124', getter_method, location.get_folder_path(),
650+
class_name=_class_name, method_name=_method_name)
651+
get_method = getattr(self._mbean_getter, getter_method)
652+
mbean_names = get_method(location)
653+
except AttributeError, ae:
654+
ex = exception_helper.create_create_exception('WLSDPLY-12125', getter_method, location.get_folder_path()
655+
, error=ae)
656+
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
657+
raise ex
658+
return mbean_names
659+
616660
def wlst_cd(self, path, location):
617661
"""
618662
Change to the directory specified in the path. If the wlst.cd() fails, assume something is wrong with the
@@ -631,6 +675,22 @@ def wlst_cd(self, path, location):
631675
method_name=_method_name)
632676
return result
633677

678+
def call_get_names_method(self, location, wlst_method):
679+
_method_name = 'call_get_method'
680+
_logger.entering(str(location), wlst_method, class_name=_class_name, method_name=_method_name)
681+
try:
682+
_logger.fine('WLSDPLY-06147', wlst_method, self._alias_helper.get_model_folder_path(location),
683+
class_name=_class_name, method_name=_method_name)
684+
get_method = getattr(self._mbean_getter, wlst_method)
685+
mbean_names = get_method(location)
686+
except AttributeError, ae:
687+
ex = exception_helper.create_create_exception('WLSDPLY-06148', wlst_method,
688+
self._alias_helper.get_model_folder_path(location), error=ae)
689+
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
690+
raise ex
691+
_logger.exiting(class_name=_class_name, method_name=_method_name, result=mbean_names)
692+
return mbean_names
693+
634694

635695
def add_to_model_if_not_empty(dictionary, entry_name, entry_value):
636696
"""

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

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
from oracle.weblogic.deploy.aliases import AliasException
@@ -610,6 +610,25 @@ def get_wlst_get_required_attribute_names(self, location):
610610
raise ex
611611
return result
612612

613+
def get_wlst_method_required_attribute_names(self, location):
614+
"""
615+
Get the list of attribute names that require special processing via a method
616+
:param location: the location
617+
:return: dict[string=string]: the dictionary of attribute names and the attribute's method
618+
:raises: BundleAwareException of the specified type: if an error occurs
619+
"""
620+
_method_name = 'get_wlst_method_required_attribute_names'
621+
622+
try:
623+
result = self.__aliases.get_wlst_method_required_attribute_names(location)
624+
except AliasException, ae:
625+
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19034',
626+
location.get_current_model_folder(), location.get_folder_path(),
627+
ae.getLocalizedMessage(), error=ae)
628+
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
629+
raise ex
630+
return result
631+
613632
def get_model_subfolder_name(self, location, wlst_name):
614633
"""
615634
Get the model folder name for the WLST subfolder name at the specified location.
@@ -688,6 +707,24 @@ def get_model_attribute_default_value(self, location, model_attribute_name):
688707
raise ex
689708
return result
690709

710+
def get_folder_names_method(self, location):
711+
"""
712+
Get the method for retrieving the folder names for the folder at the current location
713+
:param location: current location context
714+
:return: method name or None if not present for the folder
715+
"""
716+
_method_name = 'get_folder_names_method'
717+
718+
try:
719+
getter_method = self.__aliases.get_folder_names_method(location)
720+
except AliasException, ae:
721+
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19035',
722+
location.get_model_folders()[-1], location.get_folder_path(),
723+
ae.getLocalizedMessage(), error=ae)
724+
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
725+
raise ex
726+
return getter_method
727+
691728
###########################################################################
692729
# Convenience Methods #
693730
###########################################################################

0 commit comments

Comments
 (0)