This function returns true if we do an shutdown/poweroff and thus the
services should not get freezed but fenced if the node does not
comes back up fast enough.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
return $self->{plug}->write_lrm_status($status_obj);
}
+# check if we do a poweroff, can be used to decide if services should be freeze
+sub is_poweroff {
+ my ($self) = @_;
+
+ return $self->{plug}->is_poweroff();
+}
+
# implement a way to send commands to the CRM master
sub queue_crm_commands {
my ($self, $cmd) = @_;
PVE::HA::Config::write_lrm_status($node, $status_obj);
}
+# check if we do a poweroff, can be used to decide if services should be freezed
+sub is_poweroff {
+ my ($self) = @_;
+
+ my $poweroff;
+
+ my $code = sub {
+ my $line = shift;
+
+ $poweroff = 1 if ($line =~ m/poweroff\.target/);
+ };
+
+ my $cmd = ['/bin/systemctl', 'list-jobs'];
+ eval { PVE::Tools::run_command($cmd, outfunc => $code, noerr => 1); };
+
+ return $poweroff;
+}
+
sub queue_crm_commands {
my ($self, $cmd) = @_;
return $self->{hardware}->write_lrm_status($node, $status_obj);
}
+sub is_poweroff {
+ my ($self) = @_;
+
+ return 0; # default to freezing services if not overwritten by subclass
+}
sub service_config_exists {
my ($self) = @_;
return 0;
}
+sub is_poweroff {
+ my ($self) = @_;
+
+ my $node = $self->{nodename};
+ my $cstatus = $self->{hardware}->read_hardware_status_nolock();
+
+ die "undefined node status for node '$node'" if !defined($cstatus->{$node});
+
+ if (defined($cstatus->{$node}->{shutdown}) &&
+ $cstatus->{$node}->{shutdown} eq 'shutdown') {
+ return 1;
+ }
+
+ return 0;
+}
+
1;