Skip to content

Commit

Permalink
adds possibility for pre-configured tags
Browse files Browse the repository at this point in the history
  • Loading branch information
gurubert committed Dec 16, 2024
1 parent af90890 commit f7e80b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions holidays/bin/holidays.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,20 @@ def add_holiday_timeperiod(country=default_country, state=None, all_states=False
'documentation_url': '',
},
}

for key1, value1 in config["notification_rule_config"].items():
if key1 in rule_config:
for key2, value2 in value1.items():
rule_config[key1][key2] = value2
if key2 in rule_config[key1]:
if key1 == "conditions":
if rule_config[key1][key2]["state"] == "disabled":
rule_config[key1][key2] = value2
else:
if key2 == "match_host_tags":
rule_config[key1][key2]["value"].extend(value2["value"])
else:
rule_config[key1][key2] = value2
else:
rule_config[key1][key2] = value2
else:
rule_config[key1] = value1

Expand Down Expand Up @@ -439,7 +448,7 @@ def add_holiday_timeperiod(country=default_country, state=None, all_states=False
if args.func == "cleanup":
nrs, etag = cmk.get_all_notification_rules()
for nr in nrs['value']:
if nr['extensions']['rule_config']['rule_properties']['comment'] == created_by:
if nr['extensions']['rule_config']['rule_properties']['comment'].strip() == created_by:
if args.debug:
print(f"removing notification rule {nr['id']}")
cmk.delete_notification_rule(nr['id'])
Expand Down
Binary file removed holidays/holidays-2.2.0.mkp
Binary file not shown.
Binary file added holidays/holidays-2.2.1.mkp
Binary file not shown.

0 comments on commit f7e80b4

Please sign in to comment.