Module: check_mk
Branch: master
Commit: bfbfb19d2cefe46db31dc2d77129a108b8840ba6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bfbfb19d2cefe4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Sep 4 16:54:42 2018 +0200
site status snapin: Fixed handling of missing sites and cleaned up unused variables
Change-Id: Ie66e26e8879db93714000e7d558f9171f37973aa
---
cmk/gui/plugins/sidebar/site_status.py | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/cmk/gui/plugins/sidebar/site_status.py
b/cmk/gui/plugins/sidebar/site_status.py
index e6c4954..4ac1321 100644
--- a/cmk/gui/plugins/sidebar/site_status.py
+++ b/cmk/gui/plugins/sidebar/site_status.py
@@ -69,37 +69,32 @@ class SiteStatus(SidebarSnapin):
for sitename, sitealias in config.sorted_sites():
site = config.site(sitename)
- state = sites.state(sitename, {})
+ state = sites.state(sitename, {}).get("state")
- if state.get("state") == None:
+ if state is None:
state = "missing"
- text = _("Missing site")
- title = _("Site %s does not exist") % sitename
+ switch = "missing"
+ text = sitename
else:
- if state["state"] == "disabled":
+ if state == "disabled":
switch = "on"
text = site["alias"]
- title = _("Site %s is switched off") %
site["alias"]
else:
switch = "off"
text = render_link(site["alias"],
"view.py?view_name=sitehosts&site=%s" % sitename)
- ex = state.get("exception")
- shs = state.get("status_host_state")
-
- if ex:
- title = ex
- else:
- title = "Site %s is online" % site["alias"]
html.open_tr()
html.open_td(class_="left")
html.write(text)
html.close_td()
html.open_td(class_="state")
- html.status_label_button(content=state["state"],
status=state["state"],
- help=_("%s this site") % (state["state"] ==
"disabled" and _("enable") or _("disable")),
- onclick="switch_site('_site_switch=%s:%s')" %
(sitename, switch))
+ if switch == "missing":
+ html.status_label(content=state, status=state, help=_("Site is
missing"))
+ else:
+ html.status_label_button(content=state, status=state,
+ help=_("enable this site") if state == "disabled"
else _("disable this site"),
+ onclick="switch_site('_site_switch=%s:%s')" %
(sitename, switch))
html.close_tr()
html.close_table()