<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'>so if we're using blacklist exceptions (aka whitelist) then anytime a new lun is provisioned we'd have to edit the multipath configuration. Is that something that we're going to automate in ovirt?<br><br>Aic<br><br><br>----- "Joey Boggs" <jboggs@redhat.com> wrote:
<br>> Michael Burns wrote:<br>> > Also added new kernel command line arg to setup multipath.<br>> > New menu takes user through mpath whitelisting and choosing an<br>> > mpath device for installation.<br>> ><br>> > Signed-off-by: Michael Burns <mburns@redhat.com><br>> > ---<br>> >  scripts/ovirt-config-boot      |    2 +-<br>> >  scripts/ovirt-config-storage   |  188 +++++++++++++++++++++++++++++++++++++++-<br>> >  scripts/ovirt-config-uninstall |    8 ++<br>> >  scripts/ovirt-early            |   16 +++-<br>> >  4 files changed, 207 insertions(+), 7 deletions(-)<br>> ><br>> > diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot<br>> > index 87cf832..ed2bb9f 100755<br>> > --- a/scripts/ovirt-config-boot<br>> > +++ b/scripts/ovirt-config-boot<br>> > @@ -218,7 +218,7 @@ set -e\<br>> >          cp /sbin/dmsetup.static sbin/dmsetup<br>> >          cp /sbin/kpartx.static sbin/kpartx<br>> >          for M in /sbin/mpath_prio_*.static ; do<br>> > -            cp ${M} $/${M%%.static};<br>> > +            cp ${M} .${M%%.static};<br>> >          done<br>> >      fi<br>> ><br>> > diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage<br>> > index 91662c5..c448aee 100755<br>> > --- a/scripts/ovirt-config-storage<br>> > +++ b/scripts/ovirt-config-storage<br>> > @@ -130,6 +130,172 @@ check_partition_sizes()<br>> >      return $rc<br>> >  }<br>> ><br>> > +is_multipath_disabled()<br>> > +{<br>> > +    grep -q "^ *devnode \"\*\"" /etc/multipath.conf<br>> > +}<br>> > +<br>> > +multipath_warn()<br>> > +{<br>> > +    sp='                                                    '<br>> > +    w='!!WARNING'<br>> > +    wb="$w"'!!'<br>> > +    w8="$w$w$w$w$w$w$w$w"<br>> > +    printf '%s!!\n' \<br>> > +      "$w8" \<br>> > +      "$w8" \<br>> > +      "$wb$sp$w" \<br>> > +      "$wb$sp$w" \<br>> > +      "$wb    Multipath Configurations should only be made    $w" \<br>> > +      "$wb    on true multipath devices.  Configuring any     $w" \<br>> > +      "$wb    other devices may cause problems with your      $w" \<br>> > +      "$wb    system.                                         $w" \<br>> > +      "$wb$sp$w" \<br>> > +      "$wb    Proceeding from this menu will erase all        $w" \<br>> > +      "$wb    previous multipath configurations.              $w" \<br>> > +      "$wb$sp$w" \<br>> > +      "$wb$sp$w" \<br>> > +    "$w8" \<br>> > +    "$w8"<br>> > +<br>> > +}<br>> > +<br>> > +abort_multipath()<br>> > +{<br>> > +    printf "Cleaning up multipath configuration\n">&2<br>> > +    sed -i 's/^\s*wwid \*$/  devnode "*"/' /etc/multipath.conf<br>> > +    sed -i 's/^\s*wwid \w.*$//g' /etc/multipath.conf<br>> > +    service multipathd reload >&2<br>> > +}<br>> > +<br>> > +config_multipath_conf()<br>> > +{<br>> > +    ! is_multipath_disabled && abort_multipath<br>> > +    if [[ $OVIRT_MPATH = "ALL" ]]; then<br>> > +        sed -i 's/^\s*devnode ".*$/  #devnode "*"/' /etc/multipath.conf<br>> > +    else<br>> > +        sed -i 's/^\s*devnode ".*$/  wwid */' /etc/multipath.conf<br>> > +        test $(grep ^blacklist_exceptions /etc/multipath.conf | wc -l) = 0 \<br>> > +          && printf "blacklist_exceptions {\n}" >> /etc/multipath.conf<br>> > +        local wwid=""<br>> > +        for d in $whitelisted<br>> > +        do<br>> > +            d=$(basename $d)<br>> > +            local scsi_id=$(scsi_id --whitelisted --device=/dev/$d)<br>> > +            if [[ -z $scsi_id ]]; then<br>> > +                echo "scsi_id failed for device /dev/$d.  Not white listing." >&2<br>> > +            else<br>> > +                wwid="${wwid} $scsi_id"<br>> > +            fi<br>> > +        done<br>> > +        wwid=$(echo $wwid | sed 's/ /\n/g' | sort -u)<br>> > +        for scsi_id in $wwid<br>> > +        do<br>> > +            sed -i "s/^blacklist_exceptions {$/blacklist_exceptions {\n  wwid $scsi_id"/ /etc/multipath.conf<br>> > +        done<br>> > +        for d in $OVIRT_MPATH<br>> > +        do<br>> > +           sed -i "s/^blacklist_exceptions {$/blacklist_exceptions {\n  wwid $d"/ /etc/multipath.conf<br>> > +<br>> > +        done<br>> > +    fi<br>> > +    service multipathd reload >&2<br>> > +    start_log<br>> > +    echo "Generated multipath.conf"<br>> > +    cat /etc/multipath.conf<br>> > +    echo "Output of multiatph -v6 command"<br>> > +    multipath -v6<br>> > +    stop_log<br>> > +    return 0<br>> > +}<br>> > +<br>> > +<br>> > +generate_whitelist()<br>> > +{<br>> > +    whitelisted=""<br>> > +    local devs=$devices<br>> > +    local PS3="Please select devices to add or remove from multipath whitelist:  "<br>> > +    while true; do<br>> > +        local choices=""<br>> > +        for d in $devs<br>> > +        do<br>> > +            get_drive_size $d >&2<br>> > +            if [[ $whitelisted =~ $d ]]; then<br>> > +                choices="$choices $d-whitelisted"<br>> > +            else<br>> > +                choices="$choices $d"<br>> > +            fi<br>> > +        done<br>> > +<br>> > +        choices="$choices Done Abort"<br>> > +        select whitelist in $choices<br>> > +        do<br>> > +            test "$whitelist" = Abort && return 1<br>> > +            test "$whitelist" = Done && return 0<br>> > +            #first check if it is already whitelisted<br>> > +            #and remove from whitelist<br>> > +            if [[ $whitelist =~ "whitelisted"  ]]; then<br>> > +               local tmp_whitelist=""<br>> > +               whitelist=${whitelist%-whitelisted}<br>> > +               for d in $whitelisted<br>> > +               do<br>> > +                   test $d != $whitelist && tmp_whitelist="$tmp_whitelist $d"<br>> > +               done<br>> > +               whitelisted=$tmp_whitelist<br>> > +            #else add it to whitelist<br>> > +            else<br>> > +                whitelisted="$whitelisted $whitelist"<br>> > +            fi<br>> > +            break<br>> > +        done<br>> > +    done<br>> > +}<br>> > +<br>> > +# Choose a multipathed device for installation<br>> > +get_multipath_device()<br>> > +{<br>> > +    multipath_warn >&2<br>> > +    local DRIVE_VAR=$1<br>> > +    generate_whitelist<br>> > +    test $? = 1 && return 1<br>> > +    config_multipath_conf<br>> > +    local count=0<br>> > +    echo "Detecting Multipath Devices..." >&2<br>> > +    while [ $count -lt 60 ]<br>> > +    do<br>> > +        test ! `ls /dev/mapper/mpath* 2> /dev/null | wc -l` = 0 && break<br>> > +        let count=$count+1<br>> > +        sleep 1<br>> > +    done<br>> > +    if [ `ls /dev/mapper/mpath* 2> /dev/null | wc -l` = 0 ]; then<br>> > +        echo "No Multipath devices found.  Aborting...">&2<br>> > +        abort_multipath<br>> > +        return 1<br>> > +    fi<br>> > +    #need to provide a menu to choose a multipath device<br>> > +    while true<br>> > +    do<br>> > +        local choices=""<br>> > +        for dev in $(ls /dev/mapper/mpath* | egrep -v "p[0-9]+$")<br>> > +        do<br>> > +            choices="$choices $dev"<br>> > +            get_drive_size $dev >&2<br>> > +        done<br>> > +        choices="$choices Abort"<br>> > +        local PS3="Select Multipath Device: "<br>> > +        select mpath_device in $choices<br>> > +        do<br>> > +            if [[ $mpath_device = Abort ]]; then<br>> > +                abort_multipath<br>> > +                return 1<br>> > +            elif [[ -e $mpath_device ]]; then<br>> > +                eval $DRIVE_VAR=$mpath_device<br>> > +                return 0<br>> > +            fi<br>> > +        done<br>> > +    done<br>> > +}<br>> > +<br>> >  # Find a usable/selected storage device.<br>> >  # If there are none, give a diagnostic and return nonzero.<br>> >  # If there is just one, e.g., /dev/sda, treat it as selected (see below).<br>> > @@ -140,6 +306,7 @@ check_partition_sizes()<br>> >  get_dev_name()<br>> >  {<br>> >      local udi_list=$(hal-find-by-capability --capability storage)<br>> > +    local DRIVE_VAR=$1<br>> >      if test -z "$udi_list"; then<br>> >          warn "ERROR: no usable storage devices detected"<br>> >          return 1<br>> > @@ -152,6 +319,9 @@ get_dev_name()<br>> >          local block_dev=$(hal-get-property --udi "$d" --key block.device)<br>> >          # Must start with a '/'.<br>> >          case $block_dev in<br>> > +            '')<br>> > +                #if block.device not defined, suppress warning<br>> > +                continue;;<br>> >              *' '*)<br>> >                  # we use space as separator<br>> >                  warn "block device name '$block_dev' contains space; skipping";<br>> > @@ -189,12 +359,13 @@ get_dev_name()<br>> >      for d in $devices; do<br>> >          get_drive_size $d >&2<br>> >      done<br>> > -    local choices="$devices Abort"<br>> > +    local choices="$devices Multipath Abort"<br>> >      select device in $choices<br>> >      do<br>> >          test "$device" = Abort && return 1<br>> > +        test "$device" = "Multipath" && get_multipath_device device;<br>> >          test -z "$device" && continue<br>> > -        echo "$device"<br>> > +        eval $DRIVE_VAR=$device<br>> >          return 0<br>> >      done<br>> >  }<br>> >   <br>> <br>> > @@ -202,7 +373,9 @@ get_dev_name()<br>> >  do_configure()<br>> >  {<br>> >      local name_and_size<br>> > -    DRIVE=$(get_dev_name) || return 0<br>> > +    get_dev_name DRIVE<br>> > +    test ! -e $DRIVE && echo "Drive '$DRIVE' is not a valid drive" >&2 \<br>> > +        && return 0<br>> >      get_drive_size $DRIVE SPACE<br>> ><br>> >   <br>> In this section altering DRIVE=  kills me trying to use local disks. <br>> Took me awhile to track this one down. Here's how to fix it:<br>> <br>> <br>>     local num_devices=$(echo "$devices" | wc -w)<br>>     # If there's only one device, use it.<br>>     case $num_devices in<br>>         0) warn "ERROR: found no usable block device"; return 1;;<br>>         1) echo "$devices"; return 0;;<br>>         *) ;; # found more than one<br>>     esac<br>> <br>> <br>> set<br>>         1) echo "$devices"; return 0;;<br>> to<br>>         1) eval $DRIVE_VAR=$devices; return0;;<br>> <br>> <br>> <br>> <br>> <br>> >      printf "\n\nPlease configure storage partitions.\n\n"<br>> > @@ -537,6 +710,15 @@ CONFIG_SIZE=${OVIRT_VOL_CONFIG_SIZE:-$default_config_size}<br>> >  LOGGING_SIZE=${OVIRT_VOL_LOGGING_SIZE:-$default_logging_size}<br>> >  DATA_SIZE=${OVIRT_VOL_DATA_SIZE:-$default_data_size}<br>> ><br>> > +if [ -n "$OVIRT_MPATH" ]; then<br>> > +    #if present then setup multipath.conf with value<br>> > +    config_multipath_conf<br>> > +    while true<br>> > +    do<br>> > +        test ! `ls /dev/mapper/mpath* 2> /dev/null | wc -l` = 0 && break<br>> > +    done<br>> > +fi<br>> > +<br>> >  if [ -n "$OVIRT_INIT" ]; then<br>> >      # if present, use the drive selected with 'ovirt_init' boot parameter<br>> >      DRIVE=$OVIRT_INIT<br>> > diff --git a/scripts/ovirt-config-uninstall b/scripts/ovirt-config-uninstall<br>> > index fd65cbb..20f8c2c 100755<br>> > --- a/scripts/ovirt-config-uninstall<br>> > +++ b/scripts/ovirt-config-uninstall<br>> > @@ -47,6 +47,14 @@ if ask_yes_or_no "Do you wish to continue and uninstall this node ([Y]es/[N]o)?"<br>> >              log "Unmounting boot partition"<br>> >              umount $partition<br>> >              log "Removing partitions"<br>> > +            eval $(echo $partition | awk ' {<br>> > +                print "drive=" substr($0,1,length($1)-1);<br>> > +                print "drive2=" substr($0,1,length($1)-2);<br>> > +            }')<br>> > +            if [ ! -e "$drive" ]; then<br>> > +                # e.g. c0d0p1<br>> > +                drive="$drive2"<br>> > +            fi<br>> >              drive=$(echo $partition | awk '{ print substr($0, 1, length($0) - 1) }')<br>> >              parted -s $drive "rm 1"<br>> >              parted -s $drive "rm 2"<br>> > diff --git a/scripts/ovirt-early b/scripts/ovirt-early<br>> > index 8990727..5632fb0 100755<br>> > --- a/scripts/ovirt-early<br>> > +++ b/scripts/ovirt-early<br>> > @@ -148,6 +148,7 @@ start() {<br>> >      #   collectd=server[:port]<br>> >      #   hostname=fqdn<br>> >      #   TBD logrotate maxsize<br>> > +    #   mpath format: mpath=wwid:[wwid]<br>> ><br>> >      #   BOOTIF=link|eth*|<MAC> (appended by pxelinux)<br>> >      # network boot interface is assumed to be on management network where<br>> > @@ -236,6 +237,12 @@ start() {<br>> >      collectd_server=<br>> >      collectd_port=<br>> ><br>> > +    # mpath=wwid:[wwid...]<br>> > +    # set a list of comma or colon separated wwids to allow<br>> > +    # for multipath install<br>> > +    # Specify ALL to use all devices<br>> > +    mpath=<br>> > +<br>> >      # save boot parameters like console= for local disk boot menu<br>> >      bootparams=<br>> >      cat /etc/system-release >> $OVIRT_LOGFILE<br>> > @@ -286,8 +293,7 @@ start() {<br>> >                      =/dev/*)<br>> >                      bus=<br>> >                      serial=<br>> > -                    i=${i#=}<br>> > -                    init=$(ls -1 "$i" 2>/dev/null | head -n1)<br>> > +                    init=${i#=}<br>> >                      ;;<br>> >                      *)<br>> >                      bus=<br>> > @@ -374,6 +380,10 @@ start() {<br>> >              console=*)<br>> >              bootparams="$bootparams $i"<br>> >              ;;<br>> > +            mpath=*)<br>> > +            i=${i#mpath=}<br>> > +            mpath=$(echo $i|tr ",:;" " ")<br>> > +            ;;<br>> >          esac<br>> >      done<br>> ><br>> > @@ -384,7 +394,7 @@ start() {<br>> >          ip_gateway=$gateway<br>> >      fi<br>> >      # save boot parameters as defaults for ovirt-config-*<br>> > -    params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size vol_data_size local_boot standalone overcommit ip_address ip_netmask ip_gateway ipv6 dns ntp vlan ssh_pwauth syslog_server syslog_port collectd_server collectd_port bootparams hostname firstboot"<br>> > +    params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size vol_data_size local_boot standalone overcommit ip_address ip_netmask ip_gateway ipv6 dns ntp vlan ssh_pwauth syslog_server syslog_port collectd_server collectd_port bootparams hostname firstboot mpath"<br>> >      # mount /config unless firstboot is forced<br>> >      if [ "$firstboot" != "1" ]; then<br>> >          mount_config<br>> >   <br>> <br>> _______________________________________________<br>> Ovirt-devel mailing list<br>> Ovirt-devel@redhat.com<br>> https://www.redhat.com/mailman/listinfo/ovirt-devel<br>> </div></body></html>