Changeset 2541 in MondoRescue for devel/mr/lib/MondoRescue/LVM.pm


Ignore:
Timestamp:
Jan 9, 2010, 4:40:56 PM (14 years ago)
Author:
Bruno Cornec
Message:

r3577@localhost: bruno | 2010-01-08 02:23:52 +0100
The 2 first commands check and analyze begin to work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/mr/lib/MondoRescue/LVM.pm

    r2540 r2541  
    1616use ProjectBuilder::Base;
    1717use ProjectBuilder::Conf;
     18use MondoRescue::Base;
    1819
    1920# Inherit from the "Exporter" module which handles exporting functions.
     
    5859my $lvmpath = $lvmpath_t->{$ENV{PBPROJ}};
    5960
     61# That file is not mandatory anymore
    6062if (! -x $lvmproc) {
    61     pb_log(1,"$lvmproc doesn't exist.");
    62     return(0,undef);
    63     }
    64 
    65 # Check LVM volumes presence
    66 open(LVM,$lvmproc) || mr_exit(-1,"Unable to open $lvmproc");
    67 while (<LVM>) {
    68     if (/0 VGs 0 PVs 0 LVs/) {
    69         pb_log(1,"No LVM volumes found in $lvmproc");
    70         return(0,undef);
    71     }
    72 }
    73 close(LVM);
     63    pb_log(1,"$lvmproc doesn't exist\n");
     64} else {
     65    # Check LVM volumes presence
     66    pb_log(2,"Checking with $lvmproc\n");
     67    open(LVM,$lvmproc) || mr_exit(-1,"Unable to open $lvmproc");
     68    while (<LVM>) {
     69        if (/0 VGs 0 PVs 0 LVs/) {
     70            pb_log(1,"No LVM volumes found in $lvmproc\n");
     71            return(0,undef);
     72        }
     73    }
     74    close(LVM);
     75}
    7476
    7577# Check LVM version
    76 my $lvmver=0;
    77 if (-x $lvmds ) {
     78my $lvmver = 0;
     79if (-x $lvmds) {
     80    pb_log(2,"Checking with $lvmds\n");
    7881    open(LVM,"$lvmds --help 2>&1 |") || mr_exit(-1,"Unable to execute $lvmds");
    7982    while (<LVM>) {
    8083        if (/Logical Volume Manager/ || /LVM version:/) {
    8184                $lvmver = $_;
     85                chomp($lvmver);
    8286                $lvmver =~ s/:([0-9])\..*/$1/;
    8387        }
    8488    }
    85 }
    86 close(LVM);
     89    close(LVM);
     90    pb_log(2,"Found a LVM version of $lvmver with $lvmds --help\n");
     91}
    8792
    8893if ($lvmver == 0) {
    89     # Still not found
     94    pb_log(2,"LVM version value is still not known\n");
    9095    if (-x $lvmcmd) {
     96        pb_log(2,"Checking with $lvmcmd\n");
    9197        open(LVM,"$lvmcmd version |") || mr_exit(-1,"Unable to execute $lvmcmd");
    9298        while (<LVM>) {
    9399            if (/LVM version/) {
    94100                $lvmver = $_;
    95                 $lvmver =~ s/LVM version ([0-9])\..*/$1/;
     101                chomp($lvmver);
     102                $lvmver =~ s/:([0-9])\..*/$1/;
     103                $lvmver =~ s/[\s]*LVM version[:]*[\s]+([0-9])\..*/$1/;
    96104            }
    97105        }
    98106        close(LVM);
     107        pb_log(2,"Found a LVM version of $lvmver with $lvmcmd version\n");
    99108    }
    100109}
     
    102111if ($lvmver == 0) {
    103112    # Still not found
    104     mr_exit(-1,"Unable to determine LVM version.\nPlease report to the dev team with the result of the commands\n$lvmds and $lvmcmd");
     113    mr_exit(-1,"Unable to determine LVM version.\nPlease report to the dev team with the result of the commands:\n$lvmds --help and $lvmcmd version\n");
    105114} elsif ($lvmver == 1) {
    106115    $lvmcmd = "$lvmpath";
     
    108117    $lvmcmd .= " ";
    109118} else {
    110     pb_log(0,"Unknown LVM version $lvmver");
     119    pb_log(0,"Unknown LVM version $lvmver\n");
    111120}
    112121# Here $lvmcmd contains a full path name
    113 pb_log(1,"Found LVM version $lvmver");
     122pb_log(1,"Found LVM version $lvmver\n");
    114123return ($lvmver,$lvmcmd);
    115124
     
    203212        print $OUTPUT "\n";
    204213    } elsif (/^LV:/) {
    205         if ($firsttime eq 0) {
     214        if ($firsttime == 0) {
    206215            print $OUTPUT "\n";
    207216            print $OUTPUT "# Activate All Volume Groups\n";
Note: See TracChangeset for help on using the changeset viewer.