]> git.proxmox.com Git - pve-ha-manager.git/blobdiff - src/PVE/HA/Sim/Hardware.pm
test/sim: allow to simulate cfs failures
[pve-ha-manager.git] / src / PVE / HA / Sim / Hardware.pm
index 6ba2210d6d8a77f5c5f08cb0173a5e6fbf40e71a..2019d8f158e16bbb8f0b862ed529200fc33846f4 100644 (file)
@@ -494,9 +494,22 @@ sub get_node_info {
     return ($node_info, $quorate);
 }
 
+# helper for Sim/ only
+sub get_cfs_state {
+    my ($self, $node, $state) = @_;
+
+    # TODO: ensure nolock is OK when adding this to RTSim
+    my $cstatus = $self->read_hardware_status_nolock();
+    my $res = $cstatus->{$node}->{cfs}->{$state};
+
+    # we assume default true if not defined
+    return !defined($res) || $res;
+}
+
 # simulate hardware commands
 # power <node> <on|off>
 # network <node> <on|off>
+# cfs <node> <rw|update> <work|fail>
 # reboot <node>
 # shutdown <node>
 # restart-lrm <node>
@@ -539,6 +552,7 @@ sub sim_hardware_cmd {
                    $d->{crm} = $self->crm_control('start', $d, $lock_fh) if !defined($d->{crm});
                    $d->{lrm} = $self->lrm_control('start', $d, $lock_fh) if !defined($d->{lrm});
                    $d->{lrm_restart} = undef;
+                   $cstatus->{$node}->{cfs} = {};
 
                } else {
 
@@ -572,6 +586,15 @@ sub sim_hardware_cmd {
 
            $self->write_hardware_status_nolock($cstatus);
 
+       } elsif ($cmd eq 'cfs') {
+           die "sim_hardware_cmd: unknown cfs action '$action' for node '$node'"
+               if $action !~ m/^(rw|update)$/;
+           die "sim_hardware_cmd: unknown cfs command '$target' for '$action' on node '$node'"
+               if $target !~ m/^(work|fail)$/;
+
+           $cstatus->{$node}->{cfs}->{$action} = $target eq 'work';
+           $self->write_hardware_status_nolock($cstatus);
+
        } elsif ($cmd eq 'reboot' || $cmd eq 'shutdown') {
            $cstatus->{$node}->{shutdown} = $cmd;