mirror of
git://git.proxmox.com/git/pve-ha-manager.git
synced 2025-01-18 10:03:53 +03:00
env: switch to matcher-based notification system
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
This commit is contained in:
parent
07284f1194
commit
868d3cd4bb
@ -221,16 +221,10 @@ sub log {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub send_notification {
|
sub send_notification {
|
||||||
my ($self, $subject, $text, $properties) = @_;
|
my ($self, $subject, $text, $template_data, $metadata_fields) = @_;
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
my $dc_config = PVE::Cluster::cfs_read_file('datacenter.cfg');
|
PVE::Notify::error($subject, $text, $template_data, $metadata_fields);
|
||||||
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);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$self->log("warning", "could not notify: $@") if $@;
|
$self->log("warning", "could not notify: $@") if $@;
|
||||||
|
@ -212,7 +212,7 @@ my $send_fence_state_email = sub {
|
|||||||
my $haenv = $self->{haenv};
|
my $haenv = $self->{haenv};
|
||||||
my $status = $haenv->read_manager_status();
|
my $status = $haenv->read_manager_status();
|
||||||
|
|
||||||
my $notification_properties = {
|
my $template_data = {
|
||||||
"status-data" => {
|
"status-data" => {
|
||||||
manager_status => $status,
|
manager_status => $status,
|
||||||
node_status => $self->{status}
|
node_status => $self->{status}
|
||||||
@ -222,11 +222,18 @@ my $send_fence_state_email = sub {
|
|||||||
"subject" => $subject,
|
"subject" => $subject,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
my $metadata_fields = {
|
||||||
|
type => 'fencing',
|
||||||
|
hostname => $node,
|
||||||
|
};
|
||||||
|
|
||||||
$haenv->send_notification(
|
$haenv->send_notification(
|
||||||
$subject_template,
|
$subject_template,
|
||||||
$body_template,
|
$body_template,
|
||||||
$notification_properties
|
$template_data,
|
||||||
|
$metadata_fields,
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user