host groups are used during deletion of them
Message-ID: <5134f9ea.a6Jcn0ZMtVhKPrD2%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 354d96b0e907aedb6cc4661dfec6d8266758ba14
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=354d96b0e907ae…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 4 20:43:51 2013 +0100
Also detecting wether or not service/host groups are used during deletion of them
---
web/htdocs/wato.py | 65 ++++++++++++++++++++++++++++++---------------------
1 files changed, 38 insertions(+), 27 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 7541070..6b11fdf 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -5647,16 +5647,10 @@ def save_configuration_vars(vars, filename):
# | Mode for editing host-, service- and contact groups |
# '----------------------------------------------------------------------'
-# Check if a group is currently in use and cannot be deleted
-# Returns a list of occurrances.
-# Possible usages:
-# - 1. rules: host to contactgroups, services to contactgroups
-# - 2. user memberships
-def find_usage_of_contact_groups(name):
- # Part 1: Rules
+def find_usages_of_group_in_rules(name, varnames):
used_in = []
rulesets = load_all_rulesets()
- for varname in [ 'host_contactgroups', 'service_contactgroups' ]:
+ for varname in varnames:
ruleset = rulesets[varname]
rulespec = g_rulespecs[varname]
for folder, rule in ruleset:
@@ -5664,6 +5658,16 @@ def find_usage_of_contact_groups(name):
if value == name:
used_in.append(("%s: %s" % (_("Ruleset"), g_rulespecs[varname]["title"]),
make_link([("mode", "edit_ruleset"), ("varname", varname)])))
+ return used_in
+
+# Check if a group is currently in use and cannot be deleted
+# Returns a list of occurrances.
+# Possible usages:
+# - 1. rules: host to contactgroups, services to contactgroups
+# - 2. user memberships
+def find_usages_of_contact_group(name):
+ # Part 1: Rules
+ used_in = find_usages_of_group_in_rules(name, [ 'host_contactgroups', 'service_contactgroups' ])
# Is the contactgroup assigned to a user?
users = filter_hidden_users(userdb.load_users())
@@ -5698,6 +5702,12 @@ def find_usage_of_contact_groups(name):
return used_in
+def find_usages_of_host_group(name):
+ return find_usages_of_group_in_rules(name, [ 'host_groups' ])
+
+def find_usages_of_service_group(name):
+ return find_usages_of_group_in_rules(name, [ 'service_groups' ])
+
def mode_groups(phase, what):
if what == "host":
what_name = _("host groups")
@@ -5727,23 +5737,24 @@ def mode_groups(phase, what):
delname = html.var("_delete")
if what == 'contact':
- usages = find_usage_of_contact_groups(delname)
- if usages:
- message = "<b>%s</b><br>%s:<ul>" % \
- (_("You cannot delete this contactgroup."),
- _("It is still in use by"))
- for title, link in usages:
- message += '<li><a href="%s">%s</a></li>\n' % (link, title)
- message += "</ul>"
- raise MKUserError(None, message)
+ usages = find_usages_of_contact_group(delname)
+ elif what == 'host':
+ usages = find_usages_of_host_group(delname)
+ elif what == 'service':
+ usages = find_usages_of_service_group(delname)
+
+ if usages:
+ message = "<b>%s</b><br>%s:<ul>" % \
+ (_("You cannot delete this %s group.") % what,
+ _("It is still in use by"))
+ for title, link in usages:
+ message += '<li><a href="%s">%s</a></li>\n' % (link, title)
+ message += "</ul>"
+ raise MKUserError(None, message)
- confirm_txt = _('Do you really want to delete the %s group %s?') % (what, delname)
- else:
- confirm_txt = _("Do you really want to delete the %s group %s? If there are still objects "
- "assigned to that group, the group will kept up (but without an alias). "
- "Removing all objects from the will make the group disappear completely. ") % (what, delname)
+ confirm_txt = _('Do you really want to delete the %s group "%s"?') % (what, delname)
- c = wato_confirm(_("Confirm deletion of group %s" % delname), confirm_txt)
+ c = wato_confirm(_("Confirm deletion of group \"%s\"" % delname), confirm_txt)
if c:
del groups[delname]
save_group_information(all_groups)
@@ -5952,7 +5963,7 @@ def mode_timeperiods(phase):
if phase == "action":
delname = html.var("_delete")
if html.transaction_valid():
- usages = find_usage_of_timeperiod(delname)
+ usages = find_usages_of_timeperiod(delname)
if usages:
message = "<b>%s</b><br>%s:<ul>" % \
(_("You cannot delete this timeperiod."),
@@ -6296,7 +6307,7 @@ class TimeperiodSelection(ElementSelection):
# - 1. rules: service/host-notification/check-period
# - 2. user accounts (notification period)
# - 3. excluded by other timeperiods
-def find_usage_of_timeperiod(tpname):
+def find_usages_of_timeperiod(tpname):
# Part 1: Rules
used_in = []
Module: check_mk
Branch: master
Commit: 2a40a1db0950a55f5471e1b39d632faaa73ba10e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2a40a1db0950a5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 4 19:45:23 2013 +0100
Updated bug entries #0906
---
.bugs/906 | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/.bugs/906 b/.bugs/906
index 7e3b977..dc2c2a1 100644
--- a/.bugs/906
+++ b/.bugs/906
@@ -1,9 +1,9 @@
Title: logwatch.ec: Need some fallback mechanism if processing takes too long
Component: checks
-State: open
+Class: bug
+State: done
Date: 2013-01-31 11:23:38
Targetversion: 1.2.2
-Class: bug
Nagios kills Check_MK when it takes too long. When e.g. logwatch.ec is taking
more than 60 seconds, the script is terminated and all unprocessed messages
@@ -25,3 +25,6 @@ logwatch.ec: Add a third message processing mode, which writes a file into
this spool directory named ".<hostname>_<item>_timestamp". Escape the "/"
with "\" in the file name. After writing rename the file to the same name
without the leading dot.
+
+2013-03-04 19:45:21: changed state open -> done
+Has been implemented.
Module: check_mk
Branch: master
Commit: 90b4386fd582fc3f98e1d95bcebc01dce15f34c6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=90b4386fd582fc…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 4 12:24:56 2013 +0100
Updated bug entries #0789
---
.bugs/789 | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/.bugs/789 b/.bugs/789
index c330767..c6b0813 100644
--- a/.bugs/789
+++ b/.bugs/789
@@ -1,7 +1,7 @@
Title: Settings in multisite.mk without default values persist in browser cache
Component: multisite
Class: bug
-State: wontfix
+State: open
Date: 2012-09-13 17:42:33
Targetversion: 1.2.3
@@ -11,6 +11,3 @@ must not modify files of the main distribution). If it once sets a value in
multisite.mk and that is later removed (factory settings) then the positive
settings survives in the browser cache. We need to find a method how extension
modules can define or declare default values for settings in multisite.mk
-
-2013-03-04 12:24:04: changed state open -> wontfix
-Wont fix this in 1.2.2.
Module: check_mk
Branch: master
Commit: f0c333a1ff2d0410d5b5ec13ec2026aacbb57cab
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f0c333a1ff2d04…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 4 12:24:11 2013 +0100
Updated bug entries #0789
---
.bugs/789 | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/.bugs/789 b/.bugs/789
index 46d43fe..c330767 100644
--- a/.bugs/789
+++ b/.bugs/789
@@ -1,9 +1,9 @@
Title: Settings in multisite.mk without default values persist in browser cache
Component: multisite
-State: open
+Class: bug
+State: wontfix
Date: 2012-09-13 17:42:33
Targetversion: 1.2.3
-Class: bug
If you write an extension (like mkeventd) that wants to put a settings
into multisite.mk then it cannot put a default value into config.py (it
@@ -11,3 +11,6 @@ must not modify files of the main distribution). If it once sets a value in
multisite.mk and that is later removed (factory settings) then the positive
settings survives in the browser cache. We need to find a method how extension
modules can define or declare default values for settings in multisite.mk
+
+2013-03-04 12:24:04: changed state open -> wontfix
+Wont fix this in 1.2.2.