fix(commvault-storagepools): avoid division by 0 (#5305, #5141)

Co-authored-by: Julio Jimenez Delgado <j.jimenez.delgado@ibermatica.com>

Refs: CTOR-851
This commit is contained in:
omercier 2024-11-29 14:23:34 +01:00 committed by GitHub
parent 2a81f01250
commit 69144e3895
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 7 deletions

View File

@ -128,14 +128,16 @@ sub manage_selection {
}
my ($total, $free) = ($_->{totalCapacity} * 1024 * 1024, $_->{totalFreeSpace} * 1024 * 1024);
my $fixed_total = ($total == 0) ? 1 : $total;
$self->{sp}->{ $_->{storagePoolEntity}->{storagePoolName} } = {
display => $_->{storagePoolEntity}->{storagePoolName},
status => defined($map_status_code->{ $_->{statusCode} }) ? $map_status_code->{ $_->{statusCode} } : lc($_->{status}),
total_space => $total,
used_space => $total - $free,
free_space => $free,
prct_used_space => 100 - ($free * 100 / $total),
prct_free_space => $free * 100 / $total
display => $_->{storagePoolEntity}->{storagePoolName},
status => defined($map_status_code->{ $_->{statusCode} }) ? $map_status_code->{ $_->{statusCode} } : lc($_->{status}),
total_space => $total,
used_space => $total - $free,
free_space => $free,
prct_used_space => 100 - ($free * 100 / $fixed_total),
prct_free_space => $free * 100 / $fixed_total
};
}