Skip to content

Commit 50e130c

Browse files
renaming variables to make the create_security_providers method easier to understand (#1232)
1 parent 75cf122 commit 50e130c

File tree

3 files changed

+40
-29
lines changed

3 files changed

+40
-29
lines changed

integration-tests/alias-test/generate/src/test/python/aliastest/generate/generator_offline.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ def __get_attributes(self, mbean_instance):
270270

271271
attribute_map = PyOrderedDict()
272272
lsa_map = generator_wlst.lsa_map()
273+
self.__logger.finer('lsa_map = {0}', lsa_map, class_name=self.__class_name, method_name=_method_name)
273274
not_found_mbean_list = list()
274275
if len(lsa_map) > 0:
275276
not_found_mbean_list = lsa_map.keys()
@@ -278,11 +279,15 @@ def __get_attributes(self, mbean_instance):
278279
method_helper = MBeanMethodHelper(mbean_instance, mbean_path)
279280
methods_map = method_helper.get_attributes()
280281
methods_attributes = methods_map.keys()
282+
self.__logger.finer('MBeanMethodHelper found attributes: {0}', methods_attributes,
283+
class_name=self.__class_name, method_name=_method_name)
281284

282285
# As the driver it needs to have all attributes
283286
info_helper = MBeanInfoHelper(mbean_instance, mbean_path)
284287
info_map = info_helper.get_all_attributes()
285288
mbean_type = info_helper.get_mbean_type()
289+
self.__logger.finer('MBeanInfoHelper for MBean type {0} found attributes: {1}', mbean_type, info_map,
290+
class_name=self.__class_name, method_name=_method_name)
286291

287292
for attribute, attribute_helper in info_map.iteritems():
288293
method_attribute_helper = None
@@ -415,24 +420,27 @@ def __get_attributes_offline_only(self, mbean_instance):
415420
def create_security_type(self, mbean_type):
416421
folder_dict = PyOrderedDict()
417422
folder_dict[TYPE] = 'Provider'
418-
types = self._sc_providers[mbean_type]
423+
provider_sub_types = self._sc_providers[mbean_type]
419424

420-
singular = mbean_type
421-
if singular.endswith('s'):
422-
# FIXME - This doesn't seem very rigorous, e.g., directories => directory
425+
singular_mbean_type = mbean_type
426+
if singular_mbean_type.endswith('s'):
423427
lenm = len(mbean_type)-1
424-
singular = mbean_type[0:lenm]
425-
for item in types:
426-
idx = item.rfind('.')
427-
short = item[idx + 1:]
428-
package = short
429-
mbean_instance = generator_wlst.create_security_provider(singular, short, package)
428+
singular_mbean_type = mbean_type[0:lenm]
429+
for provider_sub_type in provider_sub_types:
430+
# Remove the package name from the subclass.
431+
idx = provider_sub_type.rfind('.')
432+
shortened_provider_sub_type = provider_sub_type[idx + 1:]
433+
434+
mbean_name = shortened_provider_sub_type
435+
mbean_instance = \
436+
generator_wlst.create_security_provider(mbean_name, shortened_provider_sub_type, singular_mbean_type)
430437
orig = generator_wlst.current_path()
431-
folder_dict[short] = PyOrderedDict()
432-
folder_dict[short][ATTRIBUTES] = self.__get_attributes(mbean_instance)
438+
folder_dict[shortened_provider_sub_type] = PyOrderedDict()
439+
folder_dict[shortened_provider_sub_type][ATTRIBUTES] = self.__get_attributes(mbean_instance)
433440
generator_wlst.cd_mbean(orig)
434-
return True, singular, folder_dict
441+
return True, singular_mbean_type, folder_dict
435442

443+
# FIXME - This is dead code
436444
def _slim_maps_for_report(self, mbean_proxy, mbean_type, lsa_map, methods_map, mbean_info_map):
437445
# Unlike the slim_maps method, this report discards additional information to determine how
438446
# different is the usable information in LSA, versus cmo.getClass().getMethods versus
@@ -462,6 +470,7 @@ def _slim_maps_for_report(self, mbean_proxy, mbean_type, lsa_map, methods_map, m
462470
print(' lsa_map size ', len(lsa_map), ' methods_map size ', len(methods_map),
463471
' mbean_info_size ', len(mbean_info_map))
464472

473+
# FIXME - This is dead code
465474
def _report_differences(self, mbean_proxy, mbean_type, lsa_map, methods_map, mbean_info_map):
466475
print('*************************************************************')
467476
print('Reporting on MBean ', str(mbean_proxy))

integration-tests/alias-test/generate/src/test/python/aliastest/generate/generator_online.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,22 +315,22 @@ def __create_any_subfolders(self):
315315

316316
def generate_security_mbean(self, dictionary, mbean_type):
317317
dictionary[mbean_type][TYPE] = 'Provider'
318-
types = self._sc_providers[mbean_type]
318+
provider_subtypes = self._sc_providers[mbean_type]
319319
curr_path = generator_wlst.current_path()
320320
generator_wlst.cd_mbean(curr_path + '/' + mbean_type)
321321
existing = generator_wlst.lsc()
322322
generator_wlst.cd_mbean(curr_path)
323-
for item in types:
324-
idx = item.rfind('.')
325-
short = item[idx + 1:]
323+
for provider_subtype in provider_subtypes:
324+
idx = provider_subtype.rfind('.')
325+
name = provider_subtype[idx + 1:]
326326
orig = generator_wlst.current_path()
327-
if short not in existing:
328-
mbean_instance = generator_wlst.create_security_provider(mbean_type, short, item)
329-
generator_wlst.cd_mbean(curr_path + '/' + mbean_type + '/' + short)
327+
if name not in existing:
328+
mbean_instance = generator_wlst.create_security_provider(name, provider_subtype, mbean_type)
329+
generator_wlst.cd_mbean(curr_path + '/' + mbean_type + '/' + name)
330330
else:
331-
mbean_instance = generator_wlst.get_mbean_proxy(curr_path + '/' + mbean_type + '/' + short)
332-
dictionary[mbean_type][item] = PyOrderedDict()
333-
dictionary[mbean_type][item][ATTRIBUTES] = self.__get_attributes(mbean_instance)
331+
mbean_instance = generator_wlst.get_mbean_proxy(curr_path + '/' + mbean_type + '/' + name)
332+
dictionary[mbean_type][provider_subtype] = PyOrderedDict()
333+
dictionary[mbean_type][provider_subtype][ATTRIBUTES] = self.__get_attributes(mbean_instance)
334334
generator_wlst.cd_mbean(orig)
335335
generator_wlst.cd_mbean(curr_path)
336336

integration-tests/alias-test/generate/src/test/python/aliastest/generate/generator_wlst.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,27 +242,29 @@ def created(mbean_type, name):
242242
return True
243243

244244

245-
def create_security_provider(mbean_type, name, package):
245+
def create_security_provider(name, mbean_subtype, mbean_type):
246246
"""
247247
Create the MBean with the provided name at the current wlst location. WLST Exceptions are caught and returned
248248
as False from the method.
249249
:param mbean_type: MBean type to create
250250
:param name: Name of the MBean to create
251-
:param package: package name of the security provider to create
251+
:param mbean_subtype: the subtype of the security provider to create
252252
:return: True if successfully created
253253
"""
254-
_method_name = 'created'
254+
_method_name = 'create_security_provider'
255+
__logger.entering(name, mbean_subtype, mbean_type, class_name=__class_name, method_name=_method_name)
255256

256257
online_wlst_exception = _load_global('WLSTException')
257258
result = None
258259
try:
259260
local_create = _load_global('create')
260-
result = local_create(name, package, mbean_type)
261+
result = local_create(name, mbean_subtype, mbean_type)
261262
except (online_wlst_exception, offlineWLSTException, ClassCastException, NoSuchMethodException), e:
262-
__logger.fine('Unable to create MBean {0} with name {1} and provider name {2} at location {3} : {4}',
263-
mbean_type, name, package, current_path(), str(e),
263+
__logger.fine('Unable to create MBean {0} with name {1} and provider subtype {2} at location {3} : {4}',
264+
mbean_type, name, mbean_subtype, current_path(), str(e),
264265
class_name=__class_name, method_name=_method_name)
265266

267+
__logger.exiting(class_name=__class_name, method_name=_method_name, result=result)
266268
return result
267269

268270

0 commit comments

Comments
 (0)