[Ovirt-devel] [PATCH node 6/6] Added new menu for Multipath configuration

Mike Burns mburns at redhat.com
Thu Oct 1 15:25:08 UTC 2009


On Wed, Sep 30, 2009 at 09:27:57PM -0400, Joey Boggs wrote:
> Michael Burns wrote:
>> Also added new kernel command line arg to setup multipath.
>> New menu takes user through mpath whitelisting and choosing an
>> mpath device for installation.
>>
>> Signed-off-by: Michael Burns <mburns at redhat.com>
>> ---
>>  scripts/ovirt-config-boot      |    2 +-
>>  scripts/ovirt-config-storage   |  188 +++++++++++++++++++++++++++++++++++++++-
>>  scripts/ovirt-config-uninstall |    8 ++
>>  scripts/ovirt-early            |   16 +++-
>>  4 files changed, 207 insertions(+), 7 deletions(-)
>>
>> diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot
>> index 87cf832..ed2bb9f 100755
>> --- a/scripts/ovirt-config-boot
>> +++ b/scripts/ovirt-config-boot
>> @@ -218,7 +218,7 @@ set -e\
>>          cp /sbin/dmsetup.static sbin/dmsetup
>>          cp /sbin/kpartx.static sbin/kpartx
>>          for M in /sbin/mpath_prio_*.static ; do
>> -            cp ${M} $/${M%%.static};
>> +            cp ${M} .${M%%.static};
>>          done
>>      fi
>>
>> diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage
>> index 91662c5..c448aee 100755
>> --- a/scripts/ovirt-config-storage
>> +++ b/scripts/ovirt-config-storage
>> @@ -130,6 +130,172 @@ check_partition_sizes()
>>      return $rc
>>  }
>>
>> +is_multipath_disabled()
>> +{
>> +    grep -q "^ *devnode \"\*\"" /etc/multipath.conf
>> +}
>> +
>> +multipath_warn()
>> +{
>> +    sp='                                                    '
>> +    w='!!WARNING'
>> +    wb="$w"'!!'
>> +    w8="$w$w$w$w$w$w$w$w"
>> +    printf '%s!!\n' \
>> +      "$w8" \
>> +      "$w8" \
>> +      "$wb$sp$w" \
>> +      "$wb$sp$w" \
>> +      "$wb    Multipath Configurations should only be made    $w" \
>> +      "$wb    on true multipath devices.  Configuring any     $w" \
>> +      "$wb    other devices may cause problems with your      $w" \
>> +      "$wb    system.                                         $w" \
>> +      "$wb$sp$w" \
>> +      "$wb    Proceeding from this menu will erase all        $w" \
>> +      "$wb    previous multipath configurations.              $w" \
>> +      "$wb$sp$w" \
>> +      "$wb$sp$w" \
>> +    "$w8" \
>> +    "$w8"
>> +
>> +}
>> +
>> +abort_multipath()
>> +{
>> +    printf "Cleaning up multipath configuration\n">&2
>> +    sed -i 's/^\s*wwid \*$/  devnode "*"/' /etc/multipath.conf
>> +    sed -i 's/^\s*wwid \w.*$//g' /etc/multipath.conf
>> +    service multipathd reload >&2
>> +}
>> +
>> +config_multipath_conf()
>> +{
>> +    ! is_multipath_disabled && abort_multipath
>> +    if [[ $OVIRT_MPATH = "ALL" ]]; then
>> +        sed -i 's/^\s*devnode ".*$/  #devnode "*"/' /etc/multipath.conf
>> +    else
>> +        sed -i 's/^\s*devnode ".*$/  wwid */' /etc/multipath.conf
>> +        test $(grep ^blacklist_exceptions /etc/multipath.conf | wc -l) = 0 \
>> +          && printf "blacklist_exceptions {\n}" >> /etc/multipath.conf
>> +        local wwid=""
>> +        for d in $whitelisted
>> +        do
>> +            d=$(basename $d)
>> +            local scsi_id=$(scsi_id --whitelisted --device=/dev/$d)
>> +            if [[ -z $scsi_id ]]; then
>> +                echo "scsi_id failed for device /dev/$d.  Not white listing." >&2
>> +            else
>> +                wwid="${wwid} $scsi_id"
>> +            fi
>> +        done
>> +        wwid=$(echo $wwid | sed 's/ /\n/g' | sort -u)
>> +        for scsi_id in $wwid
>> +        do
>> +            sed -i "s/^blacklist_exceptions {$/blacklist_exceptions {\n  wwid $scsi_id"/ /etc/multipath.conf
>> +        done
>> +        for d in $OVIRT_MPATH
>> +        do
>> +           sed -i "s/^blacklist_exceptions {$/blacklist_exceptions {\n  wwid $d"/ /etc/multipath.conf
>> +
>> +        done
>> +    fi
>> +    service multipathd reload >&2
>> +    start_log
>> +    echo "Generated multipath.conf"
>> +    cat /etc/multipath.conf
>> +    echo "Output of multiatph -v6 command"
>> +    multipath -v6
>> +    stop_log
>> +    return 0
>> +}
>> +
>> +
>> +generate_whitelist()
>> +{
>> +    whitelisted=""
>> +    local devs=$devices
>> +    local PS3="Please select devices to add or remove from multipath whitelist:  "
>> +    while true; do
>> +        local choices=""
>> +        for d in $devs
>> +        do
>> +            get_drive_size $d >&2
>> +            if [[ $whitelisted =~ $d ]]; then
>> +                choices="$choices $d-whitelisted"
>> +            else
>> +                choices="$choices $d"
>> +            fi
>> +        done
>> +
>> +        choices="$choices Done Abort"
>> +        select whitelist in $choices
>> +        do
>> +            test "$whitelist" = Abort && return 1
>> +            test "$whitelist" = Done && return 0
>> +            #first check if it is already whitelisted
>> +            #and remove from whitelist
>> +            if [[ $whitelist =~ "whitelisted"  ]]; then
>> +               local tmp_whitelist=""
>> +               whitelist=${whitelist%-whitelisted}
>> +               for d in $whitelisted
>> +               do
>> +                   test $d != $whitelist && tmp_whitelist="$tmp_whitelist $d"
>> +               done
>> +               whitelisted=$tmp_whitelist
>> +            #else add it to whitelist
>> +            else
>> +                whitelisted="$whitelisted $whitelist"
>> +            fi
>> +            break
>> +        done
>> +    done
>> +}
>> +
>> +# Choose a multipathed device for installation
>> +get_multipath_device()
>> +{
>> +    multipath_warn >&2
>> +    local DRIVE_VAR=$1
>> +    generate_whitelist
>> +    test $? = 1 && return 1
>> +    config_multipath_conf
>> +    local count=0
>> +    echo "Detecting Multipath Devices..." >&2
>> +    while [ $count -lt 60 ]
>> +    do
>> +        test ! `ls /dev/mapper/mpath* 2> /dev/null | wc -l` = 0 && break
>> +        let count=$count+1
>> +        sleep 1
>> +    done
>> +    if [ `ls /dev/mapper/mpath* 2> /dev/null | wc -l` = 0 ]; then
>> +        echo "No Multipath devices found.  Aborting...">&2
>> +        abort_multipath
>> +        return 1
>> +    fi
>> +    #need to provide a menu to choose a multipath device
>> +    while true
>> +    do
>> +        local choices=""
>> +        for dev in $(ls /dev/mapper/mpath* | egrep -v "p[0-9]+$")
>> +        do
>> +            choices="$choices $dev"
>> +            get_drive_size $dev >&2
>> +        done
>> +        choices="$choices Abort"
>> +        local PS3="Select Multipath Device: "
>> +        select mpath_device in $choices
>> +        do
>> +            if [[ $mpath_device = Abort ]]; then
>> +                abort_multipath
>> +                return 1
>> +            elif [[ -e $mpath_device ]]; then
>> +                eval $DRIVE_VAR=$mpath_device
>> +                return 0
>> +            fi
>> +        done
>> +    done
>> +}
>> +
>>  # Find a usable/selected storage device.
>>  # If there are none, give a diagnostic and return nonzero.
>>  # If there is just one, e.g., /dev/sda, treat it as selected (see below).
>> @@ -140,6 +306,7 @@ check_partition_sizes()
>>  get_dev_name()
>>  {
>>      local udi_list=$(hal-find-by-capability --capability storage)
>> +    local DRIVE_VAR=$1
>>      if test -z "$udi_list"; then
>>          warn "ERROR: no usable storage devices detected"
>>          return 1
>> @@ -152,6 +319,9 @@ get_dev_name()
>>          local block_dev=$(hal-get-property --udi "$d" --key block.device)
>>          # Must start with a '/'.
>>          case $block_dev in
>> +            '')
>> +                #if block.device not defined, suppress warning
>> +                continue;;
>>              *' '*)
>>                  # we use space as separator
>>                  warn "block device name '$block_dev' contains space; skipping";
>> @@ -189,12 +359,13 @@ get_dev_name()
>>      for d in $devices; do
>>          get_drive_size $d >&2
>>      done
>> -    local choices="$devices Abort"
>> +    local choices="$devices Multipath Abort"
>>      select device in $choices
>>      do
>>          test "$device" = Abort && return 1
>> +        test "$device" = "Multipath" && get_multipath_device device;
>>          test -z "$device" && continue
>> -        echo "$device"
>> +        eval $DRIVE_VAR=$device
>>          return 0
>>      done
>>  }
>>   
>
>> @@ -202,7 +373,9 @@ get_dev_name()
>>  do_configure()
>>  {
>>      local name_and_size
>> -    DRIVE=$(get_dev_name) || return 0
>> +    get_dev_name DRIVE
>> +    test ! -e $DRIVE && echo "Drive '$DRIVE' is not a valid drive" >&2 \
>> +        && return 0
>>      get_drive_size $DRIVE SPACE
>>
>>   
> In this section altering DRIVE=  kills me trying to use local disks.  
> Took me awhile to track this one down. Here's how to fix it:
>
>
>    local num_devices=$(echo "$devices" | wc -w)
>    # If there's only one device, use it.
>    case $num_devices in
>        0) warn "ERROR: found no usable block device"; return 1;;
>        1) echo "$devices"; return 0;;
>        *) ;; # found more than one
>    esac
>
>
> set
>        1) echo "$devices"; return 0;;
> to
>        1) eval $DRIVE_VAR=$devices; return0;;
>

Ok, I'll look at this, fix the patch, and re-submit




More information about the ovirt-devel mailing list