Skip to content

Commit a4afbbf

Browse files
authored
Merge pull request #251 from oracle/Issue#168-Arrays-needed-to-version-folders
Issue#168 arrays needed to version folders
2 parents bfe8dfa + 3a9bc4e commit a4afbbf

File tree

9 files changed

+129
-30
lines changed

9 files changed

+129
-30
lines changed

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,7 @@ def __apply_wlst_context_changes(self, path_name, alias_dict, parent_dict):
10841084
#
10851085
# First, determine if this dictionary is even relevant to the current WLS version.
10861086
#
1087+
self.__resolve_folder_params(path_name, alias_dict)
10871088
if not self.__use_alias_dict(path_name, alias_dict, parent_dict):
10881089
return None
10891090

@@ -1234,7 +1235,7 @@ def __test_dictionary(self, path_name, alias_dict):
12341235
return self.__is_version(path_name, alias_dict) and self.__is_wlst_mode(path_name, alias_dict)
12351236

12361237
def __use_alias_dict(self, path_name, alias_dict, parent_dict):
1237-
self.__resolve_folder_params(path_name, alias_dict)
1238+
12381239
if not self.__is_version(path_name, alias_dict):
12391240
_add_to_unresolved_folders(path_name, parent_dict, alias_utils.get_dictionary_version(alias_dict))
12401241
return False
@@ -1251,6 +1252,9 @@ def __resolve_folder_params(self, path_name, alias_dict):
12511252
contain folder parameters that are different depending on the combination. Once
12521253
a folder parameter version has been selected, then all the folder parameters in the
12531254
valid entry are added to the alias_dict dictionary parameters.
1255+
1256+
Do not add attributes or folders from the folder_params to the folder. These are not allowed.
1257+
Resolve the folder params curly braces
12541258
:param alias_dict:
12551259
:return:
12561260
"""
@@ -1272,7 +1276,11 @@ def __resolve_folder_params(self, path_name, alias_dict):
12721276
add_entry = folder_set
12731277
break
12741278
for key, value in add_entry.iteritems():
1275-
alias_dict[key] = value
1279+
if key not in [ ATTRIBUTES, FOLDERS ]:
1280+
alias_dict[key] = value
1281+
else:
1282+
_logger.fine('WLSDPLY-08136', path_name, value, class_name=_class_name,
1283+
method_name=_method_name)
12761284

12771285
def __resolve_attribute_by_wlst_context(self, path_name, attr_name, attrs_dict):
12781286
"""

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

+15-2
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@ def is_custom_folder_allowed(self, location):
283283
return self._alias_entries.is_location_child_folder_type(location,
284284
ChildFoldersTypes.MULTIPLE_WITH_TYPE_SUBFOLDER)
285285

286+
def is_security_provider_type(self, location):
287+
"""
288+
Returns true if the specified location is a security provider type, such as AuthenticationProvider.
289+
This currently corresponds to all MULTIPLE_WITH_TYPE_SUBFOLDER entries.
290+
This will need to be refined if new custom types are added, or additional distinctions are required.
291+
:param location: the location to be checked
292+
:return: True if the location is a security provider type, False otherwise
293+
:raises: AliasException: if an error occurs while getting the folder for the location
294+
"""
295+
return self._alias_entries.is_location_child_folder_type(location,
296+
ChildFoldersTypes.MULTIPLE_WITH_TYPE_SUBFOLDER)
297+
286298
###########################################################################
287299
# WLST Folder create-related methods #
288300
###########################################################################
@@ -383,7 +395,8 @@ def get_wlst_attribute_name_and_value(self, location, model_attribute_name, mode
383395
else:
384396
wlst_attribute_name = attribute_info[WLST_NAME]
385397

386-
if self._model_context and USES_PATH_TOKENS in attribute_info and string_utils.to_boolean(attribute_info[USES_PATH_TOKENS]):
398+
if self._model_context and USES_PATH_TOKENS in attribute_info and \
399+
string_utils.to_boolean(attribute_info[USES_PATH_TOKENS]):
387400
model_attribute_value = self._model_context.replace_token_string(model_attribute_value)
388401

389402
data_type = attribute_info[WLST_TYPE]
@@ -524,7 +537,7 @@ def get_wlst_get_returns_mbean_attribute_names_and_types(self, location):
524537
:return: dictionary: a dictionary with the attribute names as keys and the MBean types as values
525538
:raises: AliasException: if an error occurs due to a bad location or bad alias data
526539
"""
527-
_method_name = 'get_wlst_get_required_attribute_names'
540+
_method_name = 'get_wlst_get_returns_mbean_attribute_names_and_types'
528541

529542
wlst_attribute_names = dict()
530543

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

+40-14
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def __init__(self, model_context, base_location, wlst_mode, aliases=None):
4848
self._aliases = Aliases(self._model_context, wlst_mode=self._wlst_mode)
4949
self._alias_helper = AliasHelper(self._aliases, _logger, ExceptionType.DISCOVER)
5050
self._att_handler_map = OrderedDict()
51-
self._wls_version = WebLogicHelper(_logger).get_actual_weblogic_version()
51+
self._weblogic_helper = WebLogicHelper(_logger)
52+
self._wls_version = self._weblogic_helper.get_actual_weblogic_version()
5253
self._wlst_helper = WlstHelper(_logger, ExceptionType.DISCOVER)
5354

5455
# methods for use only by the subclasses
@@ -100,7 +101,7 @@ def _populate_model_parameters(self, dictionary, location):
100101
wlst_value)
101102
except AliasException, de:
102103
_logger.info('WLSDPLY-06106', wlst_param, wlst_path, de.getLocalizedMessage(),
103-
class_name=_class_name, method_name=_method_name)
104+
class_name=_class_name, method_name=_method_name)
104105
continue
105106

106107
attr_dict[model_param] = wlst_value
@@ -167,15 +168,15 @@ def _is_defined_attribute(self, location, wlst_name):
167168
try:
168169
if self._aliases.get_model_attribute_name(location, wlst_name):
169170
attribute = True
170-
except AliasException, ae:
171+
except AliasException:
171172
pass
172173
return attribute
173174

174175
def _get_required_attributes(self, location):
175176
"""
176177
Use get for all online attributes, and use the attribute names in the
177-
:param location:
178-
:return:
178+
:param location: current location context
179+
:return: list of attributes that require wlst.get
179180
"""
180181
_method_name = '_get_required_attributes'
181182
attributes = []
@@ -240,6 +241,7 @@ def _find_names_in_folder(self, location):
240241
if wlst_helper.path_exists(folder_path):
241242
self.wlst_cd(folder_path, location)
242243
names = self._wlst_helper.lsc()
244+
_logger.finest('WLSDPLY-06146', names, location, class_name=_class_name, method_name=_method_name)
243245
return names
244246

245247
def _find_singleton_name_in_folder(self, location):
@@ -268,6 +270,7 @@ def _find_subfolders(self, location):
268270
return self._find_subfolders_offline(location)
269271
else:
270272
return self._find_subfolders_online(location)
273+
271274
def _find_subfolders_offline(self, location):
272275
"""
273276
Find the subfolders of the current location.
@@ -360,18 +363,19 @@ def _discover_artificial_folder(self, model_subfolder_name, location, name_token
360363
names = self._find_names_in_folder(location)
361364
if names is not None:
362365
for name in names:
363-
location.add_name_token(name_token, name)
366+
massaged = self._inspect_artificial_folder_name(name, location)
367+
location.add_name_token(name_token, massaged)
364368
artificial = self._get_artificial_type(location)
365369
if artificial is None:
366370
_logger.warning('WLSDPLY-06123', self._alias_helper.get_model_folder_path(location),
367371
class_name=_class_name, method_name=_method_name)
368372
else:
369-
_logger.finer('WLSDPLY-06120', artificial, name, model_subfolder_name, class_name=_class_name,
373+
_logger.finer('WLSDPLY-06120', artificial, massaged, model_subfolder_name, class_name=_class_name,
370374
method_name=_method_name)
371375
location.append_location(artificial)
372-
subfolder_result[name] = OrderedDict()
373-
subfolder_result[name][artificial] = OrderedDict()
374-
self._populate_model_parameters(subfolder_result[name][artificial], location)
376+
subfolder_result[massaged] = OrderedDict()
377+
subfolder_result[massaged][artificial] = OrderedDict()
378+
self._populate_model_parameters(subfolder_result[massaged][artificial], location)
375379
location.pop_location()
376380
location.remove_name_token(name_token)
377381
_logger.exiting(class_name=_class_name, method_name=_method_name, result=subfolder_result)
@@ -411,12 +415,13 @@ def _discover_subfolder(self, model_subfolder_name, location, result=None):
411415
"""
412416
Discover the subfolder indicated by the model subfolder name. Append the model subfolder to the
413417
current location context, and pop that location before return
414-
:param result: dictionary to store the discovered information
418+
:param model_subfolder_name: Name of the model subfolder
415419
:param location: context containing the current subfolder information
416420
:return: discovered dictionary
417421
"""
418422
_method_name = '_discover_subfolder'
419-
_logger.entering(model_subfolder_name, class_name=_class_name, method_name=_method_name)
423+
_logger.entering(model_subfolder_name, location.get_folder_path(), class_name=_class_name,
424+
method_name=_method_name)
420425
location.append_location(model_subfolder_name)
421426
_logger.finer('WLSDPLY-06115', model_subfolder_name, self._alias_helper.get_model_folder_path(location),
422427
class_name=_class_name, method_name=_method_name)
@@ -631,6 +636,27 @@ def wlst_cd(self, path, location):
631636
method_name=_method_name)
632637
return result
633638

639+
def _inspect_artificial_folder_name(self, folder_name, location):
640+
"""
641+
Perform any special handling for the folder or folder names.
642+
:param location: current context of location
643+
:return: Original name or processed name value
644+
"""
645+
return self._inspect_security_folder_name(folder_name, location)
646+
647+
def _inspect_security_folder_name(self, folder_name, location):
648+
# This is clunky - Some security providers in 11g offline have the name "Provider", and cannot be discovered.
649+
# If found, log and throw an exception here, and the SecurityConfiguration will be omitted from the model.
650+
651+
if (not self._weblogic_helper.is_version_in_12c()) and self._wlst_mode == WlstModes.OFFLINE and \
652+
self._alias_helper.is_security_provider_type(location) and 'Provider' == folder_name:
653+
raise exception_helper.create_discover_exception('WLSDPLY-06201', folder_name, location.get_folder_path())
654+
655+
_logger.fine('version {0} mode {1} type? {2} provider {3}', not self._weblogic_helper.is_version_in_12c(),
656+
self._wlst_mode == WlstModes.OFFLINE, self._alias_helper.is_security_provider_type(location),
657+
'Provider' == folder_name)
658+
return folder_name
659+
634660

635661
def add_to_model_if_not_empty(dictionary, entry_name, entry_value):
636662
"""
@@ -640,7 +666,7 @@ def add_to_model_if_not_empty(dictionary, entry_name, entry_value):
640666
:param entry_value: to add to dictionary
641667
:return: True if the value was not empty and added to the dictionary
642668
"""
643-
if entry_value:
669+
if entry_value and len(entry_value):
644670
dictionary[entry_name] = entry_value
645671
return True
646672
return False
@@ -694,7 +720,7 @@ def _is_attribute_type(attribute_info):
694720
_method_name = '_is_attribute_type'
695721
if not attribute_info.isWritable() and _is_deprecated(attribute_info):
696722
_logger.finer('WLSDPLY-06143', attribute_info.getName(), wlst_helper.get_pwd(),
697-
class_name=_class_name, method_name=_method_name)
723+
class_name=_class_name, method_name=_method_name)
698724
return attribute_info.getDescriptor().getFieldValue(
699725
'descriptorType') == 'Attribute' and attribute_info.getDescriptor().getFieldValue(
700726
'com.bea.relationship') is None and (attribute_info.isWritable() or not _is_deprecated(attribute_info))

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from java.io import File
66
from java.lang import IllegalArgumentException
77

8+
from oracle.weblogic.deploy.discover import DiscoverException
89
from oracle.weblogic.deploy.util import PyOrderedDict as OrderedDict
910
from oracle.weblogic.deploy.util import PyWLSTException
1011
from oracle.weblogic.deploy.util import StringUtils
@@ -289,8 +290,14 @@ def discover_security_configuration(self):
289290
security_configuration = self._find_singleton_name_in_folder(location)
290291
if security_configuration is not None:
291292
_logger.info('WLSDPLY-06622', class_name=_class_name, method_name=_method_name)
293+
location.add_name_token(self._alias_helper.get_name_token(location), security_configuration)
292294
self._populate_model_parameters(result, location)
293-
self._discover_subfolders(result, location)
295+
try:
296+
self._discover_subfolders(result, location)
297+
except DiscoverException, de:
298+
_logger.warning('WLSDPLY-06200', self._wls_version, de.getLocalizedMessage(),
299+
class_name=_class_name, method_name=_method_name)
300+
result = OrderedDict()
294301
_logger.exiting(class_name=_class_name, method_name=_method_name)
295302
return model_top_folder_name, result
296303

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

+18
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,24 @@ def is_custom_folder_allowed(self, location):
293293
raise ex
294294
return result
295295

296+
def is_security_provider_type(self, location):
297+
"""
298+
Returns true if the specified location is a security provider type.
299+
:param location: the location to be checked
300+
:return: True, if the location is a security provider type, False otherwise
301+
:raises: BundleAwareException of the specified type: if an error occurs
302+
"""
303+
_method_name = 'is_security_provider_type'
304+
305+
try:
306+
result = self.__aliases.is_security_provider_type(location)
307+
except AliasException, ae:
308+
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19036', str(location),
309+
ae.getLocalizedMessage(), error=ae)
310+
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
311+
raise ex
312+
return result
313+
296314
def get_wlst_mbean_name(self, location):
297315
"""
298316
Get the MBean name to use to create it for the specified location.

core/src/main/python/wlsdeploy/util/weblogic_helper.py

+7
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ def get_default_security_realm_name(self):
130130
"""
131131
return 'myrealm'
132132

133+
def is_version_in_12c(self):
134+
"""
135+
Is the weblogic version a 12c version?
136+
:return: True if the version is 12c
137+
"""
138+
return self.is_weblogic_version_or_above('12.1.2')
139+
133140
# This method should be deleted once all of the old code is converted to the new model.
134141
def get_wlst_exception_content(self, message):
135142
"""

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/SecurityConfiguration.json

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
"wlst_paths": {
8989
"WP001": "/SecurityConfiguration/%SEC_CONFIG%/Realm${:s}/%REALM%/Adjudicator/%PROVIDER%"
9090
}
91-
9291
}
9392
},
9493
"attributes" : { },

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

+7
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,12 @@ WLSDPLY-06145=Subfolder list {0} at location {1} does not match the mbi containm
469469
WLSDPLY-06146=Discovered WLST MBean names {0} at location {1}
470470
WLSDPLY-06147=Call method {0} to get the value for wlst attribute {1} at wlst path {2}
471471

472+
# mbean_getter.py, attribute_getter.py specific to discover
473+
WLSDPLY-06200=Unable to get the Security Realm Provider name in version {0} with offline wlst. \
474+
The SecurityConfiguration will not be added to the model. The work-around is to \
475+
manually add the Security Configuration to the model or to discover the domain in online mode : {1}.
476+
WLSDPLY-06201=Invalid Security Provider name "{0}" found for provider type at location {1}
477+
472478
# resources_discoverer.py
473479
WLSDPLY-06300=Discovering domain model resources
474480

@@ -1113,6 +1119,7 @@ WLSDPLY-19033=Failed to determine if location ({0}) is version valid, or not
11131119
WLSDPLY-19034=Failed to get the model attribute list that require a special processing via a method for model \
11141120
folder ({0}) at location ({1}): {2}
11151121
WLSDPLY-19035=Failed to determine if the location ({0}) allows custom folder types: {1}
1122+
WLSDPLY-19036=Failed to determine if the location ({0}) is a security provider: {1}
11161123

11171124
# wlsdeploy/tool/util/wlst_helper.py
11181125
WLSDPLY-19100=Failed to change to the WLST directory {0}: {1}

0 commit comments

Comments
 (0)