Module: check_mk
Branch: master
Commit: 19bf583cc28c4424fd74a658ebf6586d46e0ad24
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=19bf583cc28c44…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Oct 14 14:05:04 2015 +0200
#2651 Do not allow adding of duplicate hosts anymore
WATO now makes sure that you cannot add a host with a name that already
exists in some folder anymore. That avoids problems when later activating
changes (where duplicate hosts are not allowed anyway). Note: In previous
versions you <i>could</i> have created a host with the same name on different
sites. This is not possible anymore.
---
.werks/2651 | 13 +++++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 12 ++++++++++++
3 files changed, 26 insertions(+)
diff --git a/.werks/2651 b/.werks/2651
new file mode 100644
index 0000000..bce6b4a
--- /dev/null
+++ b/.werks/2651
@@ -0,0 +1,13 @@
+Title: Do not allow adding of duplicate hosts anymore
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.2.7i3
+Date: 1444824195
+Class: feature
+
+WATO now makes sure that you cannot add a host with a name that already
+exists in some folder anymore. That avoids problems when later activating
+changes (where duplicate hosts are not allowed anyway). Note: In previous
+versions you <i>could</i> have created a host with the same name on
different
+sites. This is not possible anymore.
diff --git a/ChangeLog b/ChangeLog
index 96903d4..8f6bb12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -290,6 +290,7 @@
* 2486 Remove special handling for non-distributed-setups in WATO...
* 2487 Remove dangerous <i>Factory Reset</i> button...
* 2649 Bulk renaming of hosts in WATO...
+ * 2651 Do not allow adding of duplicate hosts anymore...
* 2344 FIX: Improved validation of selected rules when editing BI aggregations...
* 2346 FIX: Notifications: Fixed garbled page when switching on/off
bulks/backlog/user rules
* 2372 FIX: Avoid freezing WATO during bulk discovery if hosts do not respond in a
timely manner
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 451ede8..dd4ca21 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2104,6 +2104,7 @@ def mode_edithost(phase, new, cluster):
go_to_diag = html.var("diag_host")
if html.check_transaction():
if new:
+ validate_host_uniqueness(hostname)
add_hosts_to_folder(g_folder, {hostname: host})
else:
update_hosts_in_folder(g_folder, {hostname: {"set":
host}})
@@ -19818,6 +19819,17 @@ def validate_all_hosts(hostnames, force_all = False):
else:
return {}
+
+def validate_host_uniqueness(host_name):
+ for existing_host_name, existing_host in collect_hosts(g_root_folder).items():
+ if existing_host_name == host_name:
+ folder = existing_host[".folder"]
+ folder_name = get_folder_aliaspath(folder)
+ folder_url = html.makeuri_contextless([("mode",
"folder"), ("folder", folder[".path"])])
+ 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, folder_url, folder_name))
+
#.
# .--Helpers-------------------------------------------------------------.
# | _ _ _ |