From: Lukas Wagner Date: Tue, 14 Nov 2023 12:59:31 +0000 (+0100) Subject: env: switch to matcher-based notification system X-Git-Url: https://git.proxmox.com/?p=pve-ha-manager.git;a=commitdiff_plain;h=868d3cd4bb008f265c7e984bf3ce495cd12d7f41 env: switch to matcher-based notification system Signed-off-by: Lukas Wagner --- diff --git a/src/PVE/HA/Env/PVE2.pm b/src/PVE/HA/Env/PVE2.pm index ea9e6e4..fcb60a9 100644 --- a/src/PVE/HA/Env/PVE2.pm +++ b/src/PVE/HA/Env/PVE2.pm @@ -221,16 +221,10 @@ sub log { } sub send_notification { - my ($self, $subject, $text, $properties) = @_; + my ($self, $subject, $text, $template_data, $metadata_fields) = @_; eval { - my $dc_config = PVE::Cluster::cfs_read_file('datacenter.cfg'); - my $target = $dc_config->{notify}->{'target-fencing'} // PVE::Notify::default_target(); - my $notify = $dc_config->{notify}->{fencing} // 'always'; - - if ($notify eq 'always') { - PVE::Notify::error($target, $subject, $text, $properties); - } + PVE::Notify::error($subject, $text, $template_data, $metadata_fields); }; $self->log("warning", "could not notify: $@") if $@; diff --git a/src/PVE/HA/NodeStatus.pm b/src/PVE/HA/NodeStatus.pm index b264a36..e053c55 100644 --- a/src/PVE/HA/NodeStatus.pm +++ b/src/PVE/HA/NodeStatus.pm @@ -212,7 +212,7 @@ my $send_fence_state_email = sub { my $haenv = $self->{haenv}; my $status = $haenv->read_manager_status(); - my $notification_properties = { + my $template_data = { "status-data" => { manager_status => $status, node_status => $self->{status} @@ -222,11 +222,18 @@ my $send_fence_state_email = sub { "subject" => $subject, }; + my $metadata_fields = { + type => 'fencing', + hostname => $node, + }; + $haenv->send_notification( $subject_template, $body_template, - $notification_properties + $template_data, + $metadata_fields, ); + };