Module: check_mk
Branch: master
Commit: 3fa852e57d29b50d85ab08e81a1450b6a67e70f3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3fa852e57d29b5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Oct 27 15:51:32 2011 +0200
wato: Added option to download "latest" snapshot
---
ChangeLog | 1 +
web/htdocs/wato.py | 17 ++++++++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7981b2d..f38ba3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,7 @@
attributes of a host
* Added API function num_hosts_in_folder() to count the number of hosts
below the given folder
+ * Added option to download "latest" snapshot
Multisite:
* FIX: Fixed encoding problem when opening dashboard
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 3fe1acb..8456f75 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -3438,13 +3438,24 @@ def mode_snapshot(phase):
return
elif phase == "action":
if html.has_var("_download_file"):
- # FIXME: HTML Variable pruefen, kein join verwenden
- download_file = os.path.join(snapshot_dir,
html.var("_download_file"))
+ download_file = html.var("_download_file")
+ if not download_file.startswith('wato-snapshot') and download_file !=
'latest':
+ raise MKUserError(None, _("Invalid download file specified"))
+
+ # Find the latest snapshot file
+ if download_file == 'latest':
+ snapshots = os.listdir(snapshot_dir)
+ if not snapshots:
+ return False
+ download_file = snapshots[-1]
+
+ download_file = os.path.join(snapshot_dir, download_file)
if os.path.exists(download_file):
- html.req.headers_out['Content-Disposition'] = 'Attachment;
filename=' + html.var("_download_file")
+ html.req.headers_out['Content-Disposition'] = 'Attachment;
filename=' + download_file
html.req.headers_out['content_type'] =
'application/x-tar'
html.write(open(download_file).read())
return False
+
# create snapshot
elif html.has_var("_create_snapshot"):
if html.check_transaction():