7
7
import java .lang .Boolean as Boolean
8
8
import java .lang .Exception as JException
9
9
import java .lang .Object as JObject
10
- import java .util .logging .Level as Level
11
10
import javax .management .ObjectName as JObjectName
12
11
13
12
import org .python .core .PyArray as PyArray
@@ -61,11 +60,11 @@ class GeneratorBase(object):
61
60
Common helper methods for generation of folder and attribute information for both online and offline
62
61
generators.
63
62
"""
64
- __logger = PlatformLogger ('test.aliases.generate' )
65
- __logger .set_level (Level .FINER )
63
+ __logger = PlatformLogger ('test.aliases.generate.base' )
66
64
67
65
def __init__ (self , model_context , dictionary ):
68
66
self .__class_name = self .__class__ .__name__
67
+ self ._model_context = model_context
69
68
self ._dictionary = dictionary
70
69
self ._aliases = \
71
70
Aliases (model_context , model_context .get_target_wlst_mode (), model_context .get_target_wls_version ())
@@ -111,9 +110,9 @@ def add_default_value(self, dictionary, lsa_map, cmo_helper, method_helper, attr
111
110
if get_value != FAIL :
112
111
dictionary [GET_TYPE ] = self .type_it (mbean_type , attribute_name , get_attr_type )
113
112
dictionary [GET_DEFAULT ] = self .convert_attribute (attribute_name , get_value , value_type = dictionary [GET_TYPE ])
114
- self .__logger .finest ('Attribute {0} {1} is {2} and {3} is {4}' , attribute_name , GET_TYPE ,
115
- dictionary [GET_TYPE ], GET_DEFAULT , dictionary [GET_DEFAULT ],
116
- class_name = self .__class_name , method_name = _method_name )
113
+ self .__logger .finer ('Attribute {0} {1} is {2} and {3} is {4}' , attribute_name , GET_TYPE ,
114
+ dictionary [GET_TYPE ], GET_DEFAULT , dictionary [GET_DEFAULT ],
115
+ class_name = self .__class_name , method_name = _method_name )
117
116
118
117
lsa_attr_type , lsa_value = self ._get_lsa_type_and_value (lsa_map , attribute_name )
119
118
if lsa_value != FAIL :
@@ -125,9 +124,11 @@ def add_default_value(self, dictionary, lsa_map, cmo_helper, method_helper, attr
125
124
dictionary [LSA_TYPE ] = self .type_it (mbean_type , attribute_name , lsa_attr_type )
126
125
dictionary [LSA_DEFAULT ] = self .convert_attribute (attribute_name , lsa_value , value_type = dictionary [LSA_TYPE ])
127
126
self ._add_lsa_readwrite (dictionary , attribute_name )
128
- self .__logger .finest ('Attribute {0} {1} is {2} and {3} is {4}' , attribute_name , LSA_TYPE ,
129
- dictionary [LSA_TYPE ], LSA_DEFAULT , dictionary [LSA_DEFAULT ],
130
- class_name = self .__class_name , method_name = _method_name )
127
+ self .__logger .finer ('Attribute {0} {1} is {2} and {3} is {4} and {5} is {6}' , attribute_name , LSA_TYPE ,
128
+ dictionary [LSA_TYPE ], LSA_DEFAULT , dictionary [LSA_DEFAULT ], READ_TYPE ,
129
+ dictionary [READ_TYPE ], class_name = self .__class_name , method_name = _method_name )
130
+ else :
131
+ self .__logger .finer ('Attribute {0} has lsa_value of {1} so skipping' , attribute_name , FAIL )
131
132
132
133
if lsa_value == FAIL and get_value == FAIL and cmo_value == FAIL :
133
134
self .__logger .fine (BAD_ATTR_ERR , attribute_name , class_name = self .__class_name , method_name = _method_name )
@@ -354,6 +355,9 @@ def convert_attribute(self, attribute, value, value_type=None):
354
355
else :
355
356
return_value = value
356
357
358
+ if generator_wlst .is_path_field (attribute ):
359
+ return_value = generator_wlst .tokenize_path_value (self ._model_context , attribute , value )
360
+
357
361
self .__logger .exiting (class_name = self .__class_name , method_name = _method_name , result = return_value )
358
362
return return_value
359
363
@@ -415,26 +419,50 @@ def type_it(self, mbean_type, attr_name, attr_type):
415
419
return return_type
416
420
417
421
def _add_lsa_readwrite (self , attribute_map , lsa_name ):
418
- _method_name = '_get_lsa_readwrite '
422
+ _method_name = '_add_lsa_readwrite '
419
423
self .__logger .entering (lsa_name , class_name = self .__class_name , method_name = _method_name )
420
424
425
+ # We cannot simply parse the attribute name out of the lsa_string() results. If the attribute name is too
426
+ # long, it will run into the value making it difficult to separate the name from the value. For example,
427
+ # the first field below will never have a value for attr because there is no space between the
428
+ # attribute name and value.
429
+ #
430
+ # -rw- CustomClusterConfigurationFileLastUpdatedTimestamp0
431
+ # -rw- CustomClusterConfigurationFileName null
432
+ # -rw- Name foo
433
+ # -rw- Version null
434
+ #
435
+ # Figuring out if the row matches the lsa_name or not is tricky. But, we can rely on the lsa_string to have
436
+ # the fields in alphabetical order such that the first <rest-of-the-row>.startswith(lsa_name) match should
437
+ # always be the correct row.
438
+ #
421
439
attributes_str = generator_wlst .lsa_string ()
422
440
read_type = None
423
441
if attributes_str is not None :
424
442
for attribute_str in attributes_str .split ('\n ' ):
425
443
if attribute_str :
426
444
read_type = attribute_str [0 :4 ].strip ()
427
445
attr = attribute_str [7 :attribute_str .find (' ' , 7 )+ 1 ].strip ()
428
- if attr == lsa_name :
446
+
447
+ if attr == lsa_name or (len (attr ) == 0 and attributes_str [7 :].strip ().startswith (lsa_name )):
448
+ self .__logger .finer ('Attribute {0} has read_type {1}' , lsa_name , read_type ,
449
+ class_name = self .__class_name , method_name = _method_name )
429
450
if read_type == '-rw-' :
430
451
attribute_map [READ_TYPE ] = READ_WRITE
431
452
elif read_type == '-r--' :
432
453
attribute_map [READ_TYPE ] = READ_ONLY
454
+ else :
455
+ self .__logger .warning ('READ_TYPE for attribute {0} with read_type "{1}"'
456
+ ' not added to attribute map' , lsa_name , read_type ,
457
+ class_name = self .__class_name , method_name = _method_name )
433
458
break
459
+ else :
460
+ self .__logger .finer ('Attribute "{0}" not a match with the lsa_name "{1}"' ,
461
+ attr , lsa_name , class_name = self .__class_name , method_name = _method_name )
434
462
435
463
self .__logger .finer ('MBeanInfo property descriptors has attribute {0} access {1}' , lsa_name , read_type ,
436
464
class_name = self .__class_name , method_name = _method_name )
437
- self .__logger .exiting (class_name = self .__class_name , method_name = _method_name )
465
+ self .__logger .exiting (class_name = self .__class_name , method_name = _method_name , result = attribute_map [ READ_TYPE ] )
438
466
439
467
def _can_get (self , mbean_type , attribute_name , index = 0 ):
440
468
success = generator_wlst .can_get (mbean_type , attribute_name )
@@ -522,7 +550,3 @@ def _is_valid_folder(self, attribute_helper):
522
550
523
551
self .__logger .exiting (class_name = self .__class_name , method_name = _method_name , result = Boolean (result ))
524
552
return result
525
-
526
-
527
- def filename ():
528
- return 'generated'
0 commit comments