]> git.proxmox.com Git - pve-ha-manager.git/blobdiff - src/PVE/HA/Sim/Hardware.pm
sim: service add command: allow to override state
[pve-ha-manager.git] / src / PVE / HA / Sim / Hardware.pm
index af7cade8ab97145f3b5125c6d6cade50cd3d63c0..0754ec14320d9b47d4101bec366f54d5a4a0e97e 100644 (file)
@@ -175,6 +175,7 @@ sub add_service {
     die "resource ID '$sid' already defined\n" if $conf->{$sid};
 
     $conf->{$sid} = $opts;
+    $conf->{$sid}->@{qw(type name)} = split(/:/, $sid);
 
     $self->write_service_config($conf);
 
@@ -554,7 +555,8 @@ sub sim_hardware_cmd {
 
        my $cstatus = $self->read_hardware_status_nolock();
 
-       my ($cmd, $objid, $action, $param) = split(/\s+/, $cmdstr);
+       my ($cmd, $objid, $action, @params) = split(/\s+/, $cmdstr);
+       my $param = $params[0]; # for convenience/legacy
 
        die "sim_hardware_cmd: no node or service for command specified"
            if !$objid;
@@ -670,7 +672,7 @@ sub sim_hardware_cmd {
 
            } elsif ($action eq 'add') {
 
-               $self->add_service($sid, {state => 'started', node => $param});
+               $self->add_service($sid, {state => $params[1] || 'started', node => $param});
 
            } elsif ($action eq 'delete') {