Changeset 2532


Ignore:
Timestamp:
Jan 8, 2010, 3:34:06 PM (10 years ago)
Author:
bruno
Message:

r3751@localhost: bruno | 2010-01-08 14:03:56 +0100
LVM excludion based on devices was flawed as the function targeted was not really useful. That script shold be fully rewritten to have a data structure contaiing what is needed. Anyway the current patch should allow to have some improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi/analyze-my-lvm

    r2531 r2532  
    131131    fi
    132132
     133    if [ "$EXCLUDE_DEVS" ] ; then
     134        for ed in $EXCLUDE_DEVS ; do
     135            if  [ "`echo " $list_of_devices" | grep " $ed"`" != "" ]; then
     136                return
     137            fi
     138        done
     139    fi
    133140    echo "# $LVMCMD vgcreate $current_VG$VG_params $list_of_devices"
    134141    echo "# $LVMCMD vgchange -a y $current_VG"
     
    143150        pvscan 2> /dev/null | grep '"' | cut -d'"' -f2  >  $MINDI_TMP/pv.tmp
    144151    fi
    145     if [ -f /etc/multipath.conf ]; then
    146         # If multipath check which type of devidec are given, mpath prefered
    147         for d in `cat  $MINDI_TMP/pv.tmp`; do
    148             GiveMapperOfdm $d
    149         done
    150     else
    151         cat $MINDI_TMP/pv.tmp
    152     fi
    153     rm -f $MINDI_TMP/pv.tmp
    154 }
    155 
    156 
    157 ListAllVolumeGroups() {
    158     $LVMCMD vgdisplay 2> /dev/null | awk '/^ *VG Name/ {print $3;}'
    159 }
    160 
    161 GiveMapperOfdm () {
    162 
    163 major=`stat -c "%t" $1`
    164 minor=`stat -c "%T" $1`
    165 
    166 for i in `ls /dev/mapper/*`; do
    167     mj=`stat -c "%t" $i`
    168     mn=`stat -c "%T" $i`
    169     if [ "$mj" = "$major" ] && [ "$mn" = "$minor" ]; then
    170         echo "$i"
    171         return
    172     fi
    173 done
    174 echo $1
    175 }
    176 
    177 
    178 ListLvmDrivesAndPartitions() {
    179     # We get partitions in this loop not devices
    180     for d in `$LVMCMD vgdisplay -v 2> /dev/null | grep "PV Name" | sed 's/(#)//' | awk '{print $3}'`; do
     152
     153    rm -f $MINDI_TMP/pv.tmp2
     154    for d in `cat $MINDI_TMP/pv.tmp`; do
    181155        # Skip devices excluded, coming from mondoarchive
    182156        skip=0
     
    184158            for ed in $EXCLUDE_DEVS ; do
    185159                if  [ "`echo " $d " | grep " $ed"`" != "" ]; then
    186                     echo "Excluding $d from i-want-my-lvm (due to excluded device $ed)"
    187160                    skip=1
    188161                    continue
     
    193166            continue
    194167        fi
    195         # If multipath check which type of devices are given, mpath prefered
    196         if [ -f /etc/multipath.conf ]; then
    197             i=`GiveMapperOfdm $d`
     168        echo $d >> $MINDI_TMP/pv.tmp2
     169    done
     170
     171    if [ -f /etc/multipath.conf ]; then
     172        # If multipath check which type of devidec are given, mpath prefered
     173        for d in `cat $MINDI_TMP/pv.tmp2`; do
    198174            skip=0
    199175            if [ "$EXCLUDE_DEVS" ] ; then
    200176                for ed in $EXCLUDE_DEVS ; do
    201                     if  [ "`echo " $i " | grep " $ed"`" != "" ]; then
    202                         echo "Excluding $i from i-want-my-lvm (due to excluded device $ed)"
     177                    if  [ "`echo " $d " | grep " $ed"`" != "" ]; then
    203178                        skip=1
    204179                        continue
     
    209184                continue
    210185            fi
     186            GiveMapperOfdm $d
     187        done
     188    else
     189        cat $MINDI_TMP/pv.tmp2
     190    fi
     191    rm -f $MINDI_TMP/pv.tmp $MINDI_TMP/pv.tmp2
     192}
     193
     194
     195ListAllVolumeGroups() {
     196    $LVMCMD vgdisplay 2> /dev/null | awk '/^ *VG Name/ {print $3;}'
     197}
     198
     199GiveMapperOfdm () {
     200
     201major=`stat -c "%t" $1`
     202minor=`stat -c "%T" $1`
     203
     204for i in `ls /dev/mapper/*`; do
     205    mj=`stat -c "%t" $i`
     206    mn=`stat -c "%T" $i`
     207    if [ "$mj" = "$major" ] && [ "$mn" = "$minor" ]; then
     208        echo "$i"
     209        return
     210    fi
     211done
     212echo $1
     213}
     214
     215
     216ListLvmDrivesAndPartitions() {
     217    # We get partitions in this loop not devices
     218    for d in `$LVMCMD vgdisplay -v 2> /dev/null | grep "PV Name" | sed 's/(#)//' | awk '{print $3}'`; do
     219        # If multipath check which type of devices are given, mpath prefered
     220        if [ -f /etc/multipath.conf ]; then
     221            i=`GiveMapperOfdm $d`
    211222            echo $i
    212223        else
Note: See TracChangeset for help on using the changeset viewer.