[pve-devel] [PATCH storage 1/8] add an option to include pvs in lvm_vgs

Dominik Csapak d.csapak at proxmox.com
Mon Jul 30 10:25:59 CEST 2018


this will be used for the lvm part of the disk management

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/Storage/LVMPlugin.pm | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/PVE/Storage/LVMPlugin.pm b/PVE/Storage/LVMPlugin.pm
index eb376ea..b4ae744 100644
--- a/PVE/Storage/LVMPlugin.pm
+++ b/PVE/Storage/LVMPlugin.pm
@@ -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 = $@;
-- 
2.11.0





More information about the pve-devel mailing list