SI/lvm.pm
changeset 3 1b975c58c5bf
parent 1 b9ddf49db5b8
child 6 df6ca24871d4
equal deleted inserted replaced
2:1f1d347eff00 3:1b975c58c5bf
     3 use strict;
     3 use strict;
     4 use warnings;
     4 use warnings;
     5 use SI::tools;
     5 use SI::tools;
     6 
     6 
     7 sub vg_info($\%) {
     7 sub vg_info($\%) {
     8 	my ($file, $part) = @_;
     8     my ($file, $part) = @_;
     9 	foreach (map { (split /:/)[0] } map { /^\s*(.*)/; } `vgs --noheadings --separator :`) {
     9     foreach (map { (split /:/)[0] }
    10 		my $file = sprintf $file, $_;
    10         map { /^\s*(.*)/; } `vgs --noheadings --separator :`)
    11 		run("vgcfgbackup -f $file >/dev/null");
    11     {
    12 	}
    12         my $file = sprintf $file, $_;
       
    13         run("vgcfgbackup -f $file >/dev/null");
       
    14     }
    13 }
    15 }
    14 
    16 
    15 sub lv_info($\%) {
    17 sub lv_info($\%) {
    16 	my ($file, $part) = @_;
    18     my ($file, $part) = @_;
    17 
    19 
    18 	foreach my $p (keys %$part) {
    20     foreach my $p (keys %$part) {
    19 	`pvs -o +uuid --nameprefix --noheadings $p` =~ /\bLVM2_PV_UUID='(.*?)'/
    21         `pvs -o +uuid --nameprefix --noheadings $p` =~ /\bLVM2_PV_UUID='(.*?)'/
    20 		or next;
    22           or next;
    21 
    23 
    22 	$part->{$p}{type} = "pv";
    24         $part->{$p}{type} = "pv";
    23 	$part->{$p}{uuid} = $1;
    25         $part->{$p}{uuid} = $1;
    24 
    26 
    25 	}
    27     }
    26 
    28 
    27 }
    29 }
    28 
    30 
    29 1;
    31 1;
       
    32 # vim:sts=4 sw=4 aw ai si: