Don't return garbage in mpath discovery if command failed

This commit is contained in:
Daniel Berteaud 2020-10-22 20:42:26 +02:00
parent 975e8f1ccc
commit cd790587e6
1 changed files with 7 additions and 1 deletions

View File

@ -22,7 +22,13 @@ if (not defined $multipath){
exit 0;
}
foreach (qx($multipath -l -v1)){
my @dev = qx($multipath -l -v1);
# If command failed (eg no /etc/multipath.conf), then return an empty result
if ($? ne 0){
print to_json($json, { pretty => $pretty });
exit 1;
}
foreach (@dev){
chomp;
push @{$json}, { '{#MPATH_DEV}' => $_ };
}