77import java .lang .Boolean as Boolean
88import java .lang .Exception as JException
99import java .lang .Object as JObject
10- import java .util .logging .Level as Level
1110import javax .management .ObjectName as JObjectName
1211
1312import org .python .core .PyArray as PyArray
@@ -61,11 +60,11 @@ class GeneratorBase(object):
6160 Common helper methods for generation of folder and attribute information for both online and offline
6261 generators.
6362 """
64- __logger = PlatformLogger ('test.aliases.generate' )
65- __logger .set_level (Level .FINER )
63+ __logger = PlatformLogger ('test.aliases.generate.base' )
6664
6765 def __init__ (self , model_context , dictionary ):
6866 self .__class_name = self .__class__ .__name__
67+ self ._model_context = model_context
6968 self ._dictionary = dictionary
7069 self ._aliases = \
7170 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
111110 if get_value != FAIL :
112111 dictionary [GET_TYPE ] = self .type_it (mbean_type , attribute_name , get_attr_type )
113112 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 )
117116
118117 lsa_attr_type , lsa_value = self ._get_lsa_type_and_value (lsa_map , attribute_name )
119118 if lsa_value != FAIL :
@@ -125,9 +124,11 @@ def add_default_value(self, dictionary, lsa_map, cmo_helper, method_helper, attr
125124 dictionary [LSA_TYPE ] = self .type_it (mbean_type , attribute_name , lsa_attr_type )
126125 dictionary [LSA_DEFAULT ] = self .convert_attribute (attribute_name , lsa_value , value_type = dictionary [LSA_TYPE ])
127126 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 )
131132
132133 if lsa_value == FAIL and get_value == FAIL and cmo_value == FAIL :
133134 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):
354355 else :
355356 return_value = value
356357
358+ if generator_wlst .is_path_field (attribute ):
359+ return_value = generator_wlst .tokenize_path_value (self ._model_context , attribute , value )
360+
357361 self .__logger .exiting (class_name = self .__class_name , method_name = _method_name , result = return_value )
358362 return return_value
359363
@@ -415,26 +419,50 @@ def type_it(self, mbean_type, attr_name, attr_type):
415419 return return_type
416420
417421 def _add_lsa_readwrite (self , attribute_map , lsa_name ):
418- _method_name = '_get_lsa_readwrite '
422+ _method_name = '_add_lsa_readwrite '
419423 self .__logger .entering (lsa_name , class_name = self .__class_name , method_name = _method_name )
420424
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+ #
421439 attributes_str = generator_wlst .lsa_string ()
422440 read_type = None
423441 if attributes_str is not None :
424442 for attribute_str in attributes_str .split ('\n ' ):
425443 if attribute_str :
426444 read_type = attribute_str [0 :4 ].strip ()
427445 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 )
429450 if read_type == '-rw-' :
430451 attribute_map [READ_TYPE ] = READ_WRITE
431452 elif read_type == '-r--' :
432453 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 )
433458 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 )
434462
435463 self .__logger .finer ('MBeanInfo property descriptors has attribute {0} access {1}' , lsa_name , read_type ,
436464 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 ] )
438466
439467 def _can_get (self , mbean_type , attribute_name , index = 0 ):
440468 success = generator_wlst .can_get (mbean_type , attribute_name )
@@ -522,7 +550,3 @@ def _is_valid_folder(self, attribute_helper):
522550
523551 self .__logger .exiting (class_name = self .__class_name , method_name = _method_name , result = Boolean (result ))
524552 return result
525-
526-
527- def filename ():
528- return 'generated'
0 commit comments