Module: check_mk
Branch: master
Commit: b5fb884d4670e612cc44b83480b38ea2c7c2f6cb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b5fb884d4670e6…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Tue Nov 17 14:31:16 2015 +0100
#1302 Added new WATO permission to deactivate the function rename of hosts
Whit this new role permission it's no possible to control who can or not can rename
hosts.
---
.werks/1302 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 18 ++++++++++++++++--
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/.werks/1302 b/.werks/1302
new file mode 100644
index 0000000..a782629
--- /dev/null
+++ b/.werks/1302
@@ -0,0 +1,10 @@
+Title: Added new WATO permission to deactivate the function rename of hosts
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.2.7i4
+Date: 1447767011
+Class: feature
+
+Whit this new role permission it's no possible to control who can or not can rename
hosts.
+
diff --git a/ChangeLog b/ChangeLog
index d9530f7..6aeab0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -107,6 +107,7 @@
WATO:
* 2442 WATO remove host: improved cleanup of obsolete host files...
* 2785 WATO Web-API: i18n of error messages and intitial validation of incoming
request...
+ * 1302 Added new WATO permission to deactivate the function rename of hosts...
* 2666 FIX: Fix search for global configuration variables: ignore case now
* 2715 FIX: Fixed visibility of BI aggregations in editor
* 2716 FIX: Fixed error reporting on disabled checks page in case of broken man
pages
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 54d336c..07a6af8 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -875,7 +875,8 @@ def mode_folder(phase):
if config.may("wato.services"):
html.context_button(_("Bulk Discovery"),
make_link([("mode", "bulkinventory"), ("all",
"1")]),
"inventory")
- html.context_button(_("Bulk Renaming"), make_link([("mode",
"bulk_rename_host")]), "rename_host")
+ if config.may("wato.rename_hosts"):
+ html.context_button(_("Bulk Renaming"),
make_link([("mode", "bulk_rename_host")]), "rename_host")
if not g_folder.get(".lock_hosts") and
config.may("wato.parentscan") and auth_write:
html.context_button(_("Parent scan"), make_link([("mode",
"parentscan"), ("all", "1")]),
"parentscan")
@@ -2063,7 +2064,7 @@ def mode_edithost(phase, new, cluster):
if config.may('wato.rulesets'):
html.context_button(_("Parameters"),
make_link([("mode", "object_parameters"),
("host", hostname)]), "rulesets")
- if not g_folder.get(".lock_hosts"):
+ if config.may("wato.rename_hosts") and not
g_folder.get(".lock_hosts"):
html.context_button(_("Rename %s") % (cluster and
_("Cluster") or _("Host")),
make_link([("mode", "rename_host"),
("host", hostname)]), "rename_host")
if not cluster:
@@ -2280,6 +2281,10 @@ def check_edit_host_permissions(folder, host, hostname):
# '----------------------------------------------------------------------'
def mode_bulk_rename_host(phase):
+
+ if not config.may("wato.rename_hosts"):
+ raise MKGeneralException(_("You don't have the right to rename
hosts"))
+
if phase == "title":
return _("Bulk renaming of hosts")
@@ -2513,6 +2518,9 @@ def mode_rename_host(phase):
if hostname not in g_folder[".hosts"]:
raise MKGeneralException(_("You called this page with an invalid host
name."))
+ if not config.may("wato.rename_hosts"):
+ raise MKGeneralException(_("You don't have the right to rename
hosts"))
+
check_host_permissions(hostname)
host = g_folder[".hosts"][hostname]
@@ -20500,6 +20508,12 @@ def load_plugins():
"<i>Modify existing hosts</i>."),
[ "admin", "user" ])
+ config.declare_permission("wato.rename_hosts",
+ _("Rename existing hosts"),
+ _("Rename existing hosts. Please also add the permission "
+ "<i>Modify existing hosts</i>."),
+ [ "admin" ])
+
config.declare_permission("wato.manage_hosts",
_("Add & remove hosts"),
_("Add hosts to the monitoring and remove hosts "