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

Dominik Csapak d.csapak at proxmox.com
Mon Jul 23 15:16: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 | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/PVE/Storage/LVMPlugin.pm b/PVE/Storage/LVMPlugin.pm
index eb376ea..e580555 100644
--- a/PVE/Storage/LVMPlugin.pm
+++ b/PVE/Storage/LVMPlugin.pm
@@ -89,6 +89,7 @@ sub lvm_create_volume_group {
 }
 
 sub lvm_vgs {
+    my ($includepvs) = @_;
 
     my $cmd = ['/sbin/vgs', '--separator', ':', '--noheadings', '--units', 'b',
 	       '--unbuffered', '--nosuffix', '--options',
@@ -112,6 +113,33 @@ sub lvm_vgs {
     # but output is still OK (list without clustered VGs)
     warn $err if $err;
 
+    if ($includepvs) {
+	$cmd = ['/sbin/pvs', '--separator', ':', '--noheadings', '--units', 'b',
+	    '--unbuffered', '--nosuffix', '--options',
+	    'pv_name,pv_size,vg_name,pv_free'];
+
+	eval {
+	    run_command($cmd, outfunc => sub {
+		    my $line = shift;
+
+		    $line = trim($line);
+
+		    my ($pvname, $size, $vgname, $free) = split(':', $line);
+
+		    push @{$vgs->{$vgname}->{pvs}}, {
+			name => $pvname,
+			size => int($size),
+			free => int($free),
+		    };
+		});
+	};
+	my $err = $@;
+
+	# just warn (pvs return error code 5 if clvmd does not run)
+	# but output is still OK (list without clustered VGs)
+	warn $err if $err;
+    }
+
     return $vgs;
 }
 
-- 
2.11.0





More information about the pve-devel mailing list