Module: check_mk
Branch: master
Commit: dbd98b91ec123d7f89c2290fa8864bf5f11a5d14
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dbd98b91ec123d…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Dec 17 16:16:43 2015 +0100
New automation for removing unpackaged files
---
modules/automation.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/modules/automation.py b/modules/automation.py
index 4cca757..8622454 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -58,6 +58,8 @@ def do_automation(cmd, args):
result = automation_remove_or_release_package(args, "remove")
elif cmd == "release-package":
result = automation_remove_or_release_package(args, "release")
+ elif cmd == "remove-unpackaged-file":
+ result = automation_remove_unpackaged_file(args)
elif cmd == "notification-get-bulks":
result = automation_get_bulks(args)
else:
@@ -1361,3 +1363,21 @@ def automation_remove_or_release_package(args, mode):
remove_package(package)
else:
remove_package_info(package_name)
+
+
+def automation_remove_unpackaged_file(args):
+ load_module("packaging")
+ part_name = args[0]
+ if part_name not in [ p[0] for p in package_parts ]:
+ raise MKAutomationError("Invalid package part")
+
+ rel_path = args[1]
+ if "../" in rel_path or rel_path.startswith("/"):
+ raise MKAutomationError("Invalid file name")
+
+ for part, title, perm, dir in package_parts:
+ if part == part_name:
+ abspath = dir + "/" + rel_path
+ if not os.path.isfile(abspath):
+ raise MKAutomationError("No such file")
+ os.remove(abspath)