Module: check_mk
Branch: master
Commit: 51657a8b638c9b19a1449f500b779e9cc384a372
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=51657a8b638c9b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Dec 18 09:37:19 2015 +0100
#2879 WATO-Replication of MKPs and files in the local/ hierarchy
Distributed WATO now offers a new checkbox <i>Replicate extensions (MKPs and
files in ~/local/)</i> in the settings of a site. When you check this then
all MKP extension packages and files below the <tt>~/local/</tt> filesystem
on the site will be replicated to the slaves. Note: existing files and MKPs
on the slave will be removed, so you have an exact replication.
Extension replication is activated per default now if you create a new
site connection. Your existing connections are not touched so this is a
compatible change.
Extension replication only works with CEE and CRE. Manual setups
(<tt>./setup.sh</tt>) are not supported.
---
.werks/2879 | 20 ++++++++++++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 18 +++++++++++++++++-
web/htdocs/watolib.py | 9 +++++++++
web/plugins/wato/backup_domains.py | 10 +++++++++-
5 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/.werks/2879 b/.werks/2879
new file mode 100644
index 0000000..0b80a9b
--- /dev/null
+++ b/.werks/2879
@@ -0,0 +1,20 @@
+Title: WATO-Replication of MKPs and files in the local/ hierarchy
+Level: 2
+Component: wato
+Compatible: compat
+Version: 1.2.7i4
+Date: 1450427671
+Class: feature
+
+Distributed WATO now offers a new checkbox <i>Replicate extensions (MKPs and
+files in ~/local/)</i> in the settings of a site. When you check this then
+all MKP extension packages and files below the <tt>~/local/</tt> filesystem
+on the site will be replicated to the slaves. Note: existing files and MKPs
+on the slave will be removed, so you have an exact replication.
+
+Extension replication is activated per default now if you create a new
+site connection. Your existing connections are not touched so this is a
+compatible change.
+
+Extension replication only works with CEE and CRE. Manual setups
+(<tt>./setup.sh</tt>) are not supported.
diff --git a/ChangeLog b/ChangeLog
index 63824c2..7e4b3ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -200,6 +200,7 @@
* 1302 Added new WATO permission to deactivate the function rename of hosts...
* 1311 netapp_api_volumes: Added option to configure inode levels in wato
* 2878 Rework of host search in WATO - allow all bulk operations on search
results...
+ * 2879 WATO-Replication of MKPs and files in the local/ hierarchy...
* 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 6cc74b7..5c2c731 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -8699,6 +8699,8 @@ def mode_sites(phase):
repl = _("Slave")
if site.get("replicate_ec"):
repl += ", " + _("EC")
+ if site.get("replicate_mkps") and defaults.omd_root:
+ repl += ", " + _("MKPs")
else:
repl = ""
table.cell(_("Replication"), repl)
@@ -8798,7 +8800,10 @@ def mode_edit_site(phase):
if cloneid:
site = sites[cloneid]
elif new:
- site = {}
+ if defaults.omd_root:
+ site = { "replicate_mkps" : True }
+ else:
+ site = { }
else:
site = sites.get(siteid, {})
@@ -9006,6 +9011,10 @@ def mode_edit_site(phase):
# Event Console Replication
new_site["replicate_ec"] = html.get_checkbox("replicate_ec")
+ # MKPs and ~/local/
+ if defaults.omd_root:
+ new_site["replicate_mkps"] =
html.get_checkbox("replicate_mkps")
+
# Secret is not checked here, just kept
if not new and "secret" in old_site:
new_site["secret"] = old_site["secret"]
@@ -9175,6 +9184,13 @@ def mode_edit_site(phase):
"as <i>need sync</i>. A synchronization will
automatically reload the Event Console of "
"the remote site."))
+ if defaults.omd_root:
+ forms.section(_("Extensions"), simple=True)
+ html.checkbox("replicate_mkps", site.get("replicate_mkps",
False), label = _("Replicate extensions (MKPs and files in
<tt>~/local/</tt>)"))
+ html.help(_("If you enable the replication of MKPs then during each
<i>Activate Changes</i> MKPs "
+ "that are installed on your master site and all other files
below the <tt>~/local/</tt> "
+ "directory will be also transferred to the "
+ "slave site. Note: <b>all other MKPs and files below
<tt>~/local/</tt> on the slave will be removed</b>."))
forms.end()
html.button("save", _("Save"))
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 3c5afe2..e0fafa4 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -64,6 +64,11 @@ def initialize_before_loading_plugins():
# know.
( "dir", "usersettings", defaults.var_dir + "/web"
),
]
+ if defaults.omd_root:
+ replication_paths += [
+ ( "dir", "mkps", defaults.var_dir + "/packages"
),
+ ( "dir", "local", defaults.omd_root + "/local"
),
+ ]
# Directories and files for backup & restore
global backup_paths
@@ -3186,6 +3191,10 @@ def create_sync_snapshot(site_id):
if not config.sites[site_id].get("replicate_ec"):
paths = [ e for e in paths if e[1] != "mkeventd" ]
+ # Remove extensions if site does not want them
+ if not config.sites[site_id].get("replicate_mkps"):
+ paths = [ e for e in paths if e[1] not in [ "local",
"mkps" ] ]
+
multitar.create(tmp_path, paths)
shutil.rmtree(site_tmp_dir)
os.rename(tmp_path, path)
diff --git a/web/plugins/wato/backup_domains.py b/web/plugins/wato/backup_domains.py
index 8822ab5..1948883 100644
--- a/web/plugins/wato/backup_domains.py
+++ b/web/plugins/wato/backup_domains.py
@@ -218,7 +218,15 @@ else:
],
"default" : True
},
-
+ "extensions" : {
+ "title" : _("Extensions in <tt>~/local/</tt>
and MKPs"),
+ "prefix" : defaults.omd_root,
+ "paths" : [
+ ("dir", "var/check_mk/packages" ),
+ ("dir", "local" ),
+ ],
+ "default" : True,
+ },
"dokuwiki": {
"title" : _("Doku Wiki Pages and Settings"),
"prefix" : defaults.omd_root,