Module: check_mk
Branch: master
Commit: 0290a2458c9a38e1967cc6e16df52dce55ff67c2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0290a2458c9a38…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Dec 21 10:13:27 2015 +0100
Reworked commands for scheduled downtimes
---
web/plugins/views/commands.py | 37 ++++++++++++++++++-------------------
1 file changed, 18 insertions(+), 19 deletions(-)
diff --git a/web/plugins/views/commands.py b/web/plugins/views/commands.py
index a4dd6fb..db8de3b 100644
--- a/web/plugins/views/commands.py
+++ b/web/plugins/views/commands.py
@@ -495,6 +495,14 @@ multisite_commands.append({
# | |
# '----------------------------------------------------------------------'
+recurring_types = {
+ 1: _("hour"),
+ 2: _("day"),
+ 3: _("week"),
+ 4: _("second week"),
+ 5: _("fourth week"),
+}
+
config.declare_permission("action.downtimes",
_("Set/Remove Downtimes"),
_("Schedule and remove downtimes on hosts and services"),
@@ -505,28 +513,19 @@ def command_downtime(cmdtag, spec, row):
down_to = None
if html.get_checkbox("_down_do_recur"):
- recurring_type = html.var("_down_recurring")
- if recurring_type == "1":
- title_start = _("schedule a hourly recurring")
- elif recurring_type == "2":
- title_start = _("schedule a daily recurring")
- elif recurring_type == "3":
- title_start = _("schedule a weekly recurring")
- elif recurring_type == "4":
- title_start = _("schedule a two-weekly recurring")
- elif recurring_type == "5":
- title_start = _("schedule a four-weekly recurring")
+ recurring_type = int(html.var("_down_recurring"))
+ title_start = _("schedule a periodic downtime every %s") %
recurring_types[recurring_type]
else:
- title_start = _("schedule an immediate")
+ title_start = _("schedule an immediate downtime")
if html.var("_down_2h"):
down_to = down_from + 7200
- title = _("<b>%s 2-hour downtime</b> on") % title_start
+ title = _("<b>%s of 2 hours length</b> on") % title_start
elif html.var("_down_today"):
br = time.localtime(down_from)
down_to = time.mktime((br.tm_year, br.tm_mon, br.tm_mday, 23, 59, 59, 0, 0,
br.tm_isdst)) + 1
- title = _("<b>%s downtime until 24:00:00</b> on") %
title_start
+ title = _("<b>%s until 24:00:00</b> on") % title_start
elif html.var("_down_week"):
br = time.localtime(down_from)
@@ -534,7 +533,7 @@ def command_downtime(cmdtag, spec, row):
days_plus = 6 - wday
down_to = time.mktime((br.tm_year, br.tm_mon, br.tm_mday, 23, 59, 59, 0, 0,
br.tm_isdst)) + 1
down_to += days_plus * 24 * 3600
- title = _("<b>%s downtime until sunday night</b> on") %
title_start
+ title = _("<b>%s until sunday night</b> on") % title_start
elif html.var("_down_month"):
br = time.localtime(down_from)
@@ -545,12 +544,12 @@ def command_downtime(cmdtag, spec, row):
else:
new_year = br.tm_year
down_to = time.mktime((new_year, new_month, 1, 0, 0, 0, 0, 0, br.tm_isdst))
- title = _("<b>%s downtime until end of month</b> on") %
title_start
+ title = _("<b>%s until end of month</b> on") % title_start
elif html.var("_down_year"):
br = time.localtime(down_from)
down_to = time.mktime((br.tm_year, 12, 31, 23, 59, 59, 0, 0, br.tm_isdst)) + 1
- title = _("<b>%s downtime until end of %d</b> on") %
(title_start, br.tm_year)
+ title = _("<b>%s until end of %d</b> on") % (title_start,
br.tm_year)
elif html.var("_down_from_now"):
try:
@@ -562,12 +561,12 @@ def command_downtime(cmdtag, spec, row):
raise MKUserError("_down_minutes", _("Please enter a positive
number of minutes."))
down_to = time.time() + minutes * 60
- title = _("<b>%s downtime for the next %d minutes</b> on" %
(title_start, minutes))
+ title = _("<b>%s for the next %d minutes</b> on" %
(title_start, minutes))
elif html.var("_down_adhoc"):
minutes = config.adhoc_downtime.get("duration",0)
down_to = time.time() + minutes * 60
- title = _("<b>%s downtime for the next %d minutes</b> on" %
(title_start, minutes))
+ title = _("<b>%s for the next %d minutes</b> on" %
(title_start, minutes))
elif html.var("_down_custom"):
down_from = html.get_datetime_input("_down_from")