Merge pull request #2080 from UrBnW/stodup

enh(storage) Add --filter-duplicate option
This commit is contained in:
qgarnier 2020-06-30 11:39:00 +02:00 committed by GitHub
commit 1eb857fd9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -236,6 +236,7 @@ sub new {
'display-transform-dst:s' => { name => 'display_transform_dst' },
'show-cache' => { name => 'show_cache' },
'space-reservation:s' => { name => 'space_reservation' },
'filter-duplicate' => { name => 'filter_duplicate' },
'filter-storage-type:s' => { name => 'filter_storage_type', default => $self->default_storage_type() },
'add-access' => { name => 'add_access' },
});
@ -348,6 +349,18 @@ sub manage_selection {
next;
}
if (defined($self->{option_results}->{filter_duplicate})) {
my $sid = $_;
my @duplicate = grep {
($self->{storage}->{$_}->{allocation_units} == $result->{$oid_hrStorageAllocationUnits . "." . $sid}) &&
($self->{storage}->{$_}->{size} == $result->{$oid_hrStorageSize . "." . $sid}) &&
($self->{storage}->{$_}->{used} == $result->{$oid_hrStorageUsed . "." . $sid})
} keys $self->{storage};
if (scalar(@duplicate)) {
next;
}
}
$self->{storage}->{$_} = {
display => $name_storage,
allocation_units => $result->{$oid_hrStorageAllocationUnits . "." . $_},
@ -581,6 +594,10 @@ Display cache storage datas.
Some filesystem has space reserved (like ext4 for root).
The value is in percent of total (Default: none) (results like 'df' command).
=item B<--filter-duplicate>
Filter duplicate storages (in used size and total size).
=item B<--filter-storage-type>
Filter storage types with a regexp (Default: '^(hrStorageFixedDisk|hrStorageNetworkDisk|hrFSBerkeleyFFS)$').