]> git.proxmox.com Git - pve-storage.git/commitdiff
add an option to include pvs in lvm_vgs
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 30 Jul 2018 08:25:59 +0000 (10:25 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 2 Aug 2018 07:38:27 +0000 (09:38 +0200)
this will be used for the lvm part of the disk management

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/Storage/LVMPlugin.pm

index eb376eafdc255581765bcdcddb88380addf5ffaa..b4ae74491149c29586a734528ff26ed7082011e3 100644 (file)
@@ -89,10 +89,18 @@ sub lvm_create_volume_group {
 }
 
 sub lvm_vgs {
+    my ($includepvs) = @_;
 
     my $cmd = ['/sbin/vgs', '--separator', ':', '--noheadings', '--units', 'b',
-              '--unbuffered', '--nosuffix', '--options',
-              'vg_name,vg_size,vg_free'];
+              '--unbuffered', '--nosuffix', '--options'];
+
+    my $cols = [qw(vg_name vg_size vg_free lv_count)];
+
+    if ($includepvs) {
+       push @$cols, qw(pv_name pv_size pv_free);
+    }
+
+    push @$cmd, join(',', @$cols);
 
     my $vgs = {};
     eval {
@@ -101,9 +109,18 @@ sub lvm_vgs {
 
            $line = trim($line);
 
-           my ($name, $size, $free) = split (':', $line);
+           my ($name, $size, $free, $lvcount, $pvname, $pvsize, $pvfree) = split (':', $line);
+
+           $vgs->{$name} = { size => int ($size), free => int ($free), lvcount => int($lvcount) }
+               if !$vgs->{$name};
 
-           $vgs->{$name} = { size => int ($size), free => int ($free) };
+           if (defined($pvname) && defined($pvsize) && defined($pvfree)) {
+               push @{$vgs->{$name}->{pvs}}, {
+                   name => $pvname,
+                   size => int($pvsize),
+                   free => int($pvfree),
+               };
+           }
         });
     };
     my $err = $@;