From 69144e389530486ba49b0ea0260c281053da3ed2 Mon Sep 17 00:00:00 2001 From: omercier <32134301+omercier@users.noreply.github.com> Date: Fri, 29 Nov 2024 14:23:34 +0100 Subject: [PATCH] fix(commvault-storagepools): avoid division by 0 (#5305, #5141) Co-authored-by: Julio Jimenez Delgado Refs: CTOR-851 --- .../commserve/restapi/mode/storagepools.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/apps/backup/commvault/commserve/restapi/mode/storagepools.pm b/src/apps/backup/commvault/commserve/restapi/mode/storagepools.pm index 94fa5a7a4..fbe7c7c9e 100644 --- a/src/apps/backup/commvault/commserve/restapi/mode/storagepools.pm +++ b/src/apps/backup/commvault/commserve/restapi/mode/storagepools.pm @@ -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 }; }