Commit b951d481 authored by Ronny Bruska's avatar Ronny Bruska
Browse files

14120 FIX Fix error while removing event console rule MKPs

SUP-8526

Change-Id: Icc6172534e60432b4f2ee165a8ee4f77c5840b06
parent 6ab48131
Title: Fix error while removing event console rule MKPs
Class: fix
Compatible: compat
Component: wato
Date: 1653296177
Edition: cre
Knowledge: doc
Level: 1
State: unknown
Version: 2.2.0i1
If MKPs with event console rules were removed, the error "list assignment index
out of range" could occur.
......@@ -288,19 +288,18 @@ def remove(package: PackageInfo) -> None:
filenames = package["files"].get(part.ident, [])
if len(filenames) > 0:
logger.log(VERBOSE, " %s%s%s", tty.bold, part.title, tty.normal)
if part.ident == "ec_rule_packs":
_remove_packaged_rule_packs(filenames)
continue
for fn in filenames:
logger.log(VERBOSE, " %s", fn)
try:
path = part.path + "/" + fn
if part.ident == "ec_rule_packs":
_remove_packaged_rule_packs(filenames)
else:
with suppress(FileNotFoundError):
os.remove(path)
file_path = Path(part.path) / fn
file_path.unlink(missing_ok=True)
except Exception as e:
if cmk.utils.debug.enabled():
raise
raise Exception("Cannot remove %s: %s\n" % (path, e))
raise Exception("Cannot remove %s: %s\n" % (file_path, e))
(package_dir() / package["name"]).unlink()
......@@ -537,6 +536,7 @@ def _remove_packaged_rule_packs(file_names: Iterable[str], delete_export: bool =
del rule_packs[index]
if delete_export:
ec.remove_exported_rule_pack(id_)
rule_pack_ids.remove(id_)
ec.save_rule_packs(rule_packs)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment