Module: check_mk
Branch: master
Commit: df186996b2cba8db66d5383ec1b114effe6ae0d1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=df186996b2cba8…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 22 08:15:23 2017 +0100
4510 FIX Checking for name conflict during host rename
The host rename function is now performing a check whether or not the
host name is already used by another host. In case the name is in use
an error is displayed.
Change-Id: Iffa6df31c24bada87fbcec8fd44d8f9db15a5c96
---
.bugs/2510 | 2 +-
.werks/4510 | 12 ++++++++++++
web/htdocs/wato.py | 9 +--------
web/htdocs/watolib.py | 14 +++++++++-----
4 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/.bugs/2510 b/.bugs/2510
index c9772a2..2e5a5b0 100644
--- a/.bugs/2510
+++ b/.bugs/2510
@@ -2,7 +2,7 @@ Title: local active checks
Component: checks
State: open
Date: 2017-02-23 13:11:32
-Targetversion: 1.4.0
+Targetversion: 1.5.0
Class: bug
The GUI is only using the active checks under ~/lib/nagios/plugins and
diff --git a/.werks/4510 b/.werks/4510
new file mode 100644
index 0000000..9e53d43
--- /dev/null
+++ b/.werks/4510
@@ -0,0 +1,12 @@
+Title: Checking for name conflict during host rename
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1490166831
+Class: fix
+
+The host rename function is now performing a check whether or not the
+host name is already used by another host. In case the name is in use
+an error is displayed.
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 9d916d7..ceb0b58 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -1466,19 +1466,12 @@ def action_edit_host(mode, hostname, is_cluster):
return "folder"
-def validate_host_uniqueness(host_name):
- host = Host.host(host_name)
- if host:
- raise MKUserError("host", _('A host with the name
<b><tt>%s</tt></b> already '
- 'exists in the folder <a href="%s">%s</a>.')
%
- (host_name, host.folder().url(), host.folder().alias_path()))
-
-
def check_new_host_name(varname, host_name):
if not host_name:
raise MKUserError(varname, _("Please specify a host name."))
elif Folder.current().has_host(host_name):
raise MKUserError(varname, _("A host with this name already exists in this
folder."))
+ validate_host_uniqueness(varname, host_name)
Hostname().validate_value(host_name, varname)
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index de2dff9..b445d9e 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -1728,11 +1728,7 @@ class Folder(BaseFolder):
for host_name, attributes, cluster_nodes in entries:
must_be_in_contactgroups(attributes.get("contactgroups"))
- existing_host = Host.host(host_name)
- if existing_host:
- raise MKUserError("host", _('A host with the name
<b><tt>%s</tt></b> already '
- 'exists in the folder <a
href="%s">%s</a>.') %
- (host_name, existing_host.folder().url(),
existing_host.folder().alias_path()))
+ validate_host_uniqueness("host", host_name)
# 2. Actual modification
self._load_hosts_on_demand()
@@ -1920,6 +1916,14 @@ class Folder(BaseFolder):
+def validate_host_uniqueness(varname, host_name):
+ host = Host.host(host_name)
+ if host:
+ raise MKUserError(varname, _('A host with the name
<b><tt>%s</tt></b> already '
+ 'exists in the folder <a href="%s">%s</a>.')
%
+ (host_name, host.folder().url(), host.folder().alias_path()))
+
+
#.
# .--Search Folder-------------------------------------------------------.
# | ____ _ _____ _ _ |