Module: check_mk
Branch: master
Commit: 765f4c9334abe5c525daed76718efa3713b25388
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=765f4c9334abe5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 27 15:43:50 2014 +0100
#1537 FIX Added transformation code for user dashboards created between 2014-08 and
2014-10
Installations which were using early versions of the dashboard editor, which was first
available
our nightly builds from 2014-08 till 2014-10 and created dashoards with it, have now
dashboards
saved in a format, which can not be interpreted by the current dashboard code.
For some time, we assumed that there were not many installations with such files, therefor
we
did not implement any migration code and asked the users to migrate by hand. But now we
have
a bit too many users which are having trouble here, so we decided to implement a
migration
routine for these dashboards.
---
.werks/1537 | 16 ++++++++++++++++
ChangeLog | 1 +
web/htdocs/dashboard.py | 25 +++++++++++++++++++++++++
web/htdocs/views.py | 7 ++-----
web/htdocs/visuals.py | 13 +++++++++++++
5 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/.werks/1537 b/.werks/1537
new file mode 100644
index 0000000..016d73a
--- /dev/null
+++ b/.werks/1537
@@ -0,0 +1,16 @@
+Title: Added transformation code for user dashboards created between 2014-08 and 2014-10
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417099138
+Class: fix
+
+Installations which were using early versions of the dashboard editor, which was first
available
+our nightly builds from 2014-08 till 2014-10 and created dashoards with it, have now
dashboards
+saved in a format, which can not be interpreted by the current dashboard code.
+
+For some time, we assumed that there were not many installations with such files,
therefor we
+did not implement any migration code and asked the users to migrate by hand. But now we
have
+a bit too many users which are having trouble here, so we decided to implement a
migration
+routine for these dashboards.
diff --git a/ChangeLog b/ChangeLog
index bc01d24..2ffb784 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -72,6 +72,7 @@
* 1529 FIX: Mobile-GUI: Fixed "all host problems" view not showing all
problems...
* 1533 FIX: Fixed sorting of hosts with same name in "services of host"
view
* 1534 FIX: Fixed filtering views in distributed setup lead to empty views...
+ * 1537 FIX: Added transformation code for user dashboards created between 2014-08 and
2014-10...
WATO:
* 1170 Added buttons to move rules to top/bottom of the list to ruleset edit dialog
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index 4967b13..5fe7022 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -92,8 +92,31 @@ def load_dashboards():
global dashboards, available_dashboards
transform_builtin_dashboards()
dashboards = visuals.load('dashboards', builtin_dashboards)
+ transform_dashboards(dashboards)
available_dashboards = visuals.available('dashboards', dashboards)
+# During implementation of the dashboard editor and recode of the visuals
+# we had serveral different data structures, for example one where the
+# views in user dashlets were stored with a context_type instead of the
+# "single_info" key, which is the currently correct one.
+#
+# This code transforms views from user_dashboards.mk which have been
+# migrated/created with daily snapshots from 2014-08 till beginning 2014-10.
+# FIXME: Can be removed one day. Mark as incompatible change or similar.
+def transform_dashboards(dashboards):
+ for (u, n), dashboard in dashboards.items():
+ visuals.transform_old_visual(dashboard)
+
+ # Also transform dashlets
+ for dashlet in dashboard['dashlets']:
+ visuals.transform_old_visual(dashlet)
+
+ if dashlet['type'] == 'pnpgraph':
+ if 'service' not in dashlet['single_infos']:
+ dashlet['single_infos'].append('service')
+ if 'host' not in dashlet['single_infos']:
+ dashlet['single_infos'].append('host')
+
# be compatible to old definitions, where even internal dashlets were
# referenced by url, e.g. dashboard['url'] = 'hoststats.py'
# FIXME: can be removed one day. Mark as incompatible change or similar.
@@ -852,6 +875,8 @@ def page_edit_dashlet():
except IndexError:
raise MKGeneralException(_('The dashlet does not exist.'))
+ html.debug(dashlet)
+
ty = dashlet['type']
dashlet_type = dashlet_types[ty]
single_infos = dashlet['single_infos']
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index b6f0d13..fb601f9 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -91,6 +91,7 @@ def permitted_views():
return available_views
# Convert views that are saved in the pre 1.2.6-style
+# FIXME: Can be removed one day. Mark as incompatible change or similar.
def transform_old_views():
for view in multisite_views.values():
@@ -103,11 +104,7 @@ def transform_old_views():
if 'context_type' in view:
# This code transforms views from user_views.mk which have been migrated
with
# daily snapshots from 2014-08 till beginning 2014-10.
- if view['context_type'] in [ 'host', 'service',
'hostgroup', 'servicegroup' ]:
- view['single_infos'] = [view['context_type']]
- else:
- view['single_infos'] = [] # drop the context type and assume a
"multiple view"
- del view['context_type']
+ visuals.transform_old_visual(view)
elif 'single_infos' not in view:
# This tries to map the datasource and additional settings of the
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index b4b1943..e83ebcd 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -1244,6 +1244,19 @@ def collect_context_links_of(visual_type_name, this_visual,
active_filter_vars,
return context_links
+def transform_old_visual(visual):
+ if 'context_type' in visual:
+ if visual['context_type'] in [ 'host', 'service',
'hostgroup', 'servicegroup' ]:
+ visual['single_infos'] = [visual['context_type']]
+ else:
+ visual['single_infos'] = [] # drop the context type and assume a
"multiple visual"
+ del visual['context_type']
+ elif 'single_infos' not in visual:
+ visual['single_infos'] = []
+
+ visual.setdefault('context', {})
+
+
#.
# .--Popup Add-----------------------------------------------------------.
# | ____ _ _ _ |