34
34
import oracle .weblogic .deploy .util .TranslateException as TranslateException
35
35
from wlsdeploy .aliases import alias_utils
36
36
from wlsdeploy .aliases .alias_constants import ALIAS_LIST_TYPES
37
+ from wlsdeploy .aliases .alias_constants import PROPERTIES
37
38
from wlsdeploy .aliases .aliases import Aliases
38
39
from wlsdeploy .aliases .location_context import LocationContext
39
40
from wlsdeploy .aliases .model_constants import KUBERNETES
@@ -253,15 +254,18 @@ def calculate_changed_model(self):
253
254
254
255
def _parse_change_path (self , path ):
255
256
"""
256
- Determine the location and attribute name (if specified) for the specified change path
257
+ Determine the location and attribute name (if specified) for the specified change path.
258
+ Include a property key for property attribute paths.
257
259
:param path: delimited change path, such as "resources|JDBCSystemResource|Generic2|JdbcResource"
258
- :return: tuple - location for path, attribute name from path or None
260
+ :return: tuple - ( location from path, attribute name from path, property key from path)
259
261
"""
260
262
_method_name = '_parse_change_path'
261
263
262
264
location = LocationContext ()
263
265
attribute_name = None
266
+ property_key = None
264
267
name_token_next = False
268
+ property_key_next = False
265
269
266
270
path_tokens = path .split (PATH_TOKEN )
267
271
folder_names = self .aliases .get_model_section_top_level_folder_names (path_tokens [0 ])
@@ -279,6 +283,8 @@ def _parse_change_path(self, path):
279
283
token_name = self .aliases .get_name_token (location )
280
284
location .add_name_token (token_name , path_token )
281
285
name_token_next = False
286
+ elif property_key_next :
287
+ property_key = path_token
282
288
elif path_token in folder_names :
283
289
location .append_location (path_token )
284
290
folder_names = self .aliases .get_model_subfolder_names (location )
@@ -294,13 +300,16 @@ def _parse_change_path(self, path):
294
300
location .add_name_token (token_name , "TOKEN" )
295
301
elif path_token in attribute_names :
296
302
attribute_name = path_token
303
+ attribute_type = self .aliases .get_model_attribute_type (location , attribute_name )
304
+ if attribute_type == PROPERTIES :
305
+ property_key_next = True
297
306
name_token_next = False
298
307
else :
299
308
ex = exception_helper .create_compare_exception ('WLSDPLY-05712' , path_token , path )
300
309
_logger .throwing (ex , class_name = _class_name , method_name = _method_name )
301
310
raise ex
302
311
303
- return location , attribute_name
312
+ return location , attribute_name , property_key
304
313
305
314
def _add_results (self , change_paths , is_delete = False ):
306
315
"""
@@ -312,7 +321,7 @@ def _add_results(self, change_paths, is_delete=False):
312
321
for change_path in change_paths :
313
322
# change_path is the keys of changes in the piped format, such as:
314
323
# resources|JDBCSystemResource|Generic2|JdbcResource|JDBCConnectionPoolParams|TestConnectionsOnReserve
315
- location , attribute_name = self ._parse_change_path (change_path )
324
+ location , attribute_name , property_key = self ._parse_change_path (change_path )
316
325
is_folder_path = attribute_name is None
317
326
318
327
if is_delete and not is_folder_path :
@@ -361,10 +370,13 @@ def _add_results(self, change_paths, is_delete=False):
361
370
if current_folder :
362
371
current_value = current_folder [key ]
363
372
previous_value = dictionary_utils .get_element (previous_folder , key )
364
- change_value , comment = self ._get_change_info (current_value , previous_value , location , attribute_name )
373
+ change_value , comment = self ._get_change_info (current_value , previous_value , location , attribute_name ,
374
+ property_key )
365
375
366
376
if comment :
367
- change_folder [COMMENT_MATCH ] = comment
377
+ # make comment key unique, key will not appear in output
378
+ comment_key = COMMENT_MATCH + comment
379
+ change_folder [comment_key ] = comment
368
380
change_folder [key ] = change_value
369
381
else :
370
382
change_folder [key ] = None
@@ -397,13 +409,14 @@ def _add_results(self, change_paths, is_delete=False):
397
409
else :
398
410
pointer_dict [parent_key ]['!' + app_key ] = PyOrderedDict ()
399
411
400
- def _get_change_info (self , current_value , previous_value , location , attribute_name ):
412
+ def _get_change_info (self , current_value , previous_value , location , attribute_name , property_key ):
401
413
"""
402
414
Determine the value and comment to put in the change model based on the supplied arguments.
403
415
:param current_value: the current value from the new model
404
416
:param previous_value: the previous value from the old model
405
417
:param location: the location of the value in the model
406
418
:param attribute_name: the name of the attribute, or None if this is a folder path
419
+ :param property_key: a key in a property value, or None if a different type
407
420
:return: a tuple with the change value and comment, either can be None
408
421
"""
409
422
change_value = current_value
@@ -430,6 +443,8 @@ def _get_change_info(self, current_value, previous_value, location, attribute_na
430
443
current_text = ',' .join (current_list )
431
444
previous_text = ',' .join (previous_list )
432
445
comment = attribute_name + ": '" + previous_text + "' -> '" + current_text + "'"
446
+ elif attribute_type == PROPERTIES :
447
+ comment = property_key + ": '" + str (previous_value ) + "'"
433
448
elif not isinstance (previous_value , dict ):
434
449
comment = attribute_name + ": '" + str (previous_value ) + "'"
435
450
0 commit comments