[pve-devel] [PATCH storage 4/8] extend list_thinpools for multiple vgs and more information

Dominik Csapak d.csapak at proxmox.com
Mon Jul 30 10:26:02 CEST 2018


if no vg is given, give back all thinpools from all vgs
if verbose is 1, then give back the information about the thinpools
(like size and free)

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/Storage/LvmThinPlugin.pm | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/PVE/Storage/LvmThinPlugin.pm b/PVE/Storage/LvmThinPlugin.pm
index db25ee3..c1719d6 100644
--- a/PVE/Storage/LvmThinPlugin.pm
+++ b/PVE/Storage/LvmThinPlugin.pm
@@ -175,14 +175,23 @@ sub list_images {
 }
 
 sub list_thinpools {
-    my ($vg) = @_;
+    my ($vg, $verbose) = @_;
 
     my $lvs = PVE::Storage::LVMPlugin::lvm_list_volumes($vg);
     my $thinpools = [];
-
-    foreach my $lvname (keys %{$lvs->{$vg}}) {
-	next if $lvs->{$vg}->{$lvname}->{lv_type} ne 't';
-	push @$thinpools, { lv => $lvname };
+    my $vgs = defined($vg) ? [ $vg ] : [keys %$lvs];
+
+    foreach my $vg (@$vgs) {
+	foreach my $lvname (keys %{$lvs->{$vg}}) {
+	    next if $lvs->{$vg}->{$lvname}->{lv_type} ne 't';
+	    if ($verbose) {
+		my $lv = $lvs->{$vg}->{$lvname};
+		$lv->{lv} = $lvname;
+		push @$thinpools, $lv;
+	    } else {
+		push @$thinpools, { lv => $lvname };
+	    }
+	}
     }
 
     return $thinpools;
-- 
2.11.0





More information about the pve-devel mailing list