@@ -386,7 +386,7 @@ def _discover_subfolder_with_single_name(self, model_subfolder_name, location, n
386
386
_logger .exiting (class_name = _class_name , method_name = _method_name )
387
387
return result
388
388
389
- def _discover_artificial_folder (self , model_subfolder_type , location , name_token ):
389
+ def _discover_artificial_folder (self , model_subfolder_type , location , name_token , check_order = False ):
390
390
"""
391
391
Discover the subfolder that has an artificial connection; the subfolder contains multiple different types
392
392
under one MBean. The model must contain the subfolder type, the artificial type that specifies which it is,
@@ -395,13 +395,17 @@ def _discover_artificial_folder(self, model_subfolder_type, location, name_token
395
395
:param model_subfolder_type: type of the model subfolder
396
396
:param location: context containing the current location information
397
397
:param name_token: for use in the location to contain the folder name
398
+ :param check_order: if true, check the subfolders for order
398
399
:return: dictionary containing the discovered folder attributes
399
400
"""
400
401
_method_name = '_discover_artifical_folder'
401
402
_logger .entering (model_subfolder_type , str (location ), name_token , class_name = _class_name ,
402
403
method_name = _method_name )
403
404
subfolder_result = OrderedDict ()
404
405
names = self ._find_names_in_folder (location )
406
+ required_order = self ._aliases .get_subfolders_in_order (location )
407
+ attr_map = dict ()
408
+ default_list = list ()
405
409
if names is not None :
406
410
for name in names :
407
411
massaged = self ._inspect_artificial_folder_name (name , location )
@@ -411,6 +415,9 @@ def _discover_artificial_folder(self, model_subfolder_type, location, name_token
411
415
if self ._aliases .is_custom_folder_allowed (location ):
412
416
_logger .fine ('WLSDPLY-06148' , model_subfolder_type , massaged , location .get_folder_path (),
413
417
class_name = _class_name , method_name = _method_name )
418
+ # doesn't matter how many parameters, it is automatically a non-default name
419
+ default_list .append (massaged )
420
+ attr_map [massaged ] = 0
414
421
subfolder_result .update (
415
422
self ._custom_folder .discover_custom_mbean (location , model_subfolder_type , massaged ))
416
423
else :
@@ -423,8 +430,23 @@ def _discover_artificial_folder(self, model_subfolder_type, location, name_token
423
430
subfolder_result [massaged ] = OrderedDict ()
424
431
subfolder_result [massaged ][artificial ] = OrderedDict ()
425
432
self ._populate_model_parameters (subfolder_result [massaged ][artificial ], location )
433
+ default_list .append (artificial )
434
+ attr_map [artificial ] = len (subfolder_result [massaged ][artificial ])
426
435
location .pop_location ()
427
436
location .remove_name_token (name_token )
437
+
438
+ # check to see if the order and number of the subfolder list is same as required order
439
+ is_default = False
440
+ if check_order and len (required_order ) == len (default_list ):
441
+ is_default = True
442
+ idx = 0
443
+ while idx < len (required_order ):
444
+ if required_order [idx ] != default_list [idx ] or attr_map [default_list [idx ]] > 0 :
445
+ is_default = False
446
+ break
447
+ idx += 1
448
+ if is_default :
449
+ subfolder_result = None
428
450
_logger .exiting (class_name = _class_name , method_name = _method_name , result = subfolder_result )
429
451
return subfolder_result
430
452
@@ -458,12 +480,13 @@ def _discover_subfolder_with_names(self, model_subfolder_name, location, name_to
458
480
_logger .exiting (class_name = _class_name , method_name = _method_name )
459
481
return subfolder_result
460
482
461
- def _discover_subfolder (self , model_subfolder_name , location , result = None ):
483
+ def _discover_subfolder (self , model_subfolder_name , location , result = None , check_order = False ):
462
484
"""
463
485
Discover the subfolder indicated by the model subfolder name. Append the model subfolder to the
464
486
current location context, and pop that location before return
465
487
:param model_subfolder_name: Name of the model subfolder
466
488
:param location: context containing the current subfolder information
489
+ :param check_order: does the folder need to be checked for order
467
490
:return: discovered dictionary
468
491
"""
469
492
_method_name = '_discover_subfolder'
@@ -485,22 +508,29 @@ def _discover_subfolder(self, model_subfolder_name, location, result=None):
485
508
subfolder_result = self ._discover_subfolder_with_single_name (model_subfolder_name , location ,
486
509
name_token )
487
510
elif self ._aliases .requires_artificial_type_subfolder_handling (location ):
488
- subfolder_result = self ._discover_artificial_folder (model_subfolder_name , location , name_token )
511
+ subfolder_result = self ._discover_artificial_folder (
512
+ model_subfolder_name , location , name_token , check_order )
489
513
else :
490
514
subfolder_result = self ._discover_subfolder_with_names (model_subfolder_name , location ,
491
515
name_token )
492
516
else :
493
517
subfolder_result = self ._discover_subfolder_singleton (model_subfolder_name , location )
494
- add_to_model_if_not_empty (result , model_subfolder_name , subfolder_result )
518
+ # this is a really special case. Empty means not-default it is empty
519
+ if self ._aliases .requires_artificial_type_subfolder_handling (location ):
520
+ if subfolder_result is not None :
521
+ add_to_model (result , model_subfolder_name , subfolder_result )
522
+ else :
523
+ add_to_model_if_not_empty (result , model_subfolder_name , subfolder_result )
495
524
location .pop_location ()
496
525
_logger .exiting (class_name = _class_name , method_name = _method_name , result = result )
497
526
return result
498
527
499
- def _discover_subfolders (self , result , location ):
528
+ def _discover_subfolders (self , result , location , check_order = False ):
500
529
"""
501
530
Discover the rest of the mbean hierarchy at the current location.
502
531
:param result: dictionary where to store the discovered subfolders
503
532
:param location: context containing current location information
533
+ :param check_order: True if artificial folder has an order to check
504
534
:return: populated dictionary
505
535
"""
506
536
_method_name = '_discover_subfolders'
@@ -511,7 +541,7 @@ def _discover_subfolders(self, result, location):
511
541
model_subfolder_name = self ._get_model_name (location , wlst_subfolder )
512
542
# will return a None if subfolder not in current wls version
513
543
if model_subfolder_name is not None :
514
- result = self ._discover_subfolder (model_subfolder_name , location , result )
544
+ result = self ._discover_subfolder (model_subfolder_name , location , result , check_order )
515
545
_logger .finest ('WLSDPLY-06114' , str (location ), class_name = _class_name , method_name = _method_name )
516
546
_logger .exiting (class_name = _class_name , method_name = _method_name , result = result )
517
547
return result
@@ -790,6 +820,15 @@ def add_to_model_if_not_empty(dictionary, entry_name, entry_value):
790
820
return False
791
821
792
822
823
+ def add_to_model (dictionary , entry_name , entry_value ):
824
+ """
825
+ Add this to the model even if empty
826
+ :param dictionary: to add the value
827
+ :param entry_name: name of the key
828
+ :param entry_value: dictionary to add
829
+ """
830
+ dictionary [entry_name ] = entry_value
831
+
793
832
def convert_to_absolute_path (relative_to , file_name ):
794
833
"""
795
834
Transform the path by joining the relative_to before the file_name and converting the resulting path name to
0 commit comments