From 8cccb3447b21f6a5cbcf0436c1e832f9f5082220 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Mon, 30 Jul 2018 10:25:59 +0200 Subject: [PATCH] add an option to include pvs in lvm_vgs this will be used for the lvm part of the disk management Signed-off-by: Dominik Csapak --- 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) }; + $vgs->{$name} = { size => int ($size), free => int ($free), lvcount => int($lvcount) } + if !$vgs->{$name}; + + if (defined($pvname) && defined($pvsize) && defined($pvfree)) { + push @{$vgs->{$name}->{pvs}}, { + name => $pvname, + size => int($pvsize), + free => int($pvfree), + }; + } }); }; my $err = $@;