Skip to content

Commit 2d12813

Browse files
committed
fix: Fix Deploy task command run checks
1 parent 69b6cc6 commit 2d12813

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ netdiscovery/netinventory:
1616
* fix #768: Added Aerohive devices support
1717
* fix #769: Added Intelbras devices support
1818

19+
deploy:
20+
* Fix checks on command run and clarify reason of success or failure. This fixes
21+
"return code is not" and "command output doesn't contain" checks which was always
22+
failing.
23+
1924
1.11 Tue, 24 Sep 2024
2025

2126
core:

lib/GLPI/Agent/Task/Deploy/ActionProcessor/Action/Cmd.pm

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,40 @@ sub _evaluateRet {
2424
if ($retCheck->{type} eq 'okCode') {
2525
foreach (@{$retCheck->{values}}) {
2626
if ($exitStatus == $_) {
27-
return [ 1, "exit status is ok: $_" ];
27+
return [ 1, "ok, got expected exit status: $_" ];
2828
}
2929
}
30+
return [ 0, "not expected exit status: $exitStatus" ];
31+
3032
} elsif ($retCheck->{type} eq 'okPattern') {
3133
foreach (@{$retCheck->{values}}) {
3234
next unless length($_);
3335
if ($$buf =~ /$_/) {
34-
return [ 1, "ok pattern found in log: /$_/" ];
36+
return [ 1, "ok, pattern found in log: /$_/" ];
3537
}
3638
}
39+
return [ 0, "expected pattern not found in log" ];
40+
3741
} elsif ($retCheck->{type} eq 'errorCode') {
3842
foreach (@{$retCheck->{values}}) {
3943
if ($exitStatus == $_) {
40-
return [ 0, "exit status is not ok: `$_'" ];
44+
return [ 0, "found unwanted exit status: $exitStatus" ];
4145
}
4246
}
47+
return [ 1, "ok, not an unwanted exit status: $exitStatus" ];
48+
4349
} elsif ($retCheck->{type} eq 'errorPattern') {
4450
foreach (@{$retCheck->{values}}) {
4551
next unless length($_);
4652
if ($$buf =~ /$_/) {
4753
return [ 0, "error pattern found in log: /$_/" ];
4854
}
4955
}
56+
return [ 1, "ok, error pattern not found in log" ];
5057
}
5158
}
52-
return [ 0, '' ];
59+
60+
return [ 1, "nothing to check" ];
5361
}
5462

5563
sub _runOnUnix {

0 commit comments

Comments
 (0)