Skip to content

Commit f98d049

Browse files
committed
Fix conversion of metrics and topology panels
1 parent 43c4dc8 commit f98d049

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

sdcclient/_monitor.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,14 @@ def convert_group(prop_name, old_widget, new_widget):
972972

973973
new_widget['groupingLabelsIds'] = migrated
974974

975+
def convert_override_filter(prop_name, old_widget, new_widget):
976+
if old_widget['showAs'] == 'map':
977+
# override scope always true if scope is set
978+
new_widget['overrideScope'] = True
979+
else:
980+
new_widget['overrideScope'] = old_widget[prop_name]
981+
982+
975983
def convert_name(prop_name, old_widget, new_widget):
976984
#
977985
# enforce unique name (on old dashboard, before migration)
@@ -1013,6 +1021,21 @@ def convert_property_name(prop_name, old_metric, new_metric):
10131021

10141022
migrated_metrics.append(migrated_metric)
10151023

1024+
# Property name convention:
1025+
# timestamp: k0 (if present)
1026+
# other keys: k* (from 0 or 1, depending on timestamp)
1027+
# values: v* (from 0)
1028+
timestamp_key = filter(lambda m: m['id'] == 'timestamp' and not ('timeAggregation' in m and m['timeAggregation'] is not None), migrated_metrics)
1029+
no_timestamp_keys = filter(lambda m: m['id'] != 'timestamp' and not ('timeAggregation' in m and m['timeAggregation'] is not None), migrated_metrics)
1030+
values = filter(lambda m: 'timeAggregation' in m and m['timeAggregation'] is not None, migrated_metrics)
1031+
if timestamp_key:
1032+
timestamp_key[0]['propertyName'] = 'k0'
1033+
k_offset = 1 if timestamp_key else 0
1034+
for i in range(0, len(no_timestamp_keys)):
1035+
no_timestamp_keys[i]['propertyName'] = 'k{}'.format(i + k_offset)
1036+
for i in range(0, len(values)):
1037+
values[i]['propertyName'] = 'v{}'.format(i)
1038+
10161039
new_widget['metrics'] = migrated_metrics
10171040

10181041
widget_migrations = {
@@ -1027,7 +1050,7 @@ def convert_property_name(prop_name, old_metric, new_metric):
10271050
'markdownSource': when_set(keep_as_is),
10281051
'metrics': with_default(convert_metrics, []),
10291052
'name': with_default(convert_name, 'Panel'),
1030-
'overrideFilter': rename_to('overrideScope'),
1053+
'overrideFilter': convert_override_filter,
10311054
'paging': drop_it,
10321055
'scope': with_default(keep_as_is, None),
10331056
'showAs': keep_as_is,

0 commit comments

Comments
 (0)