Misc. tidyups
authorBryn M. Reeves <bmr@redhat.com>
Tue, 30 Oct 2012 16:38:01 +0000 (16:38 +0000)
committerBryn M. Reeves <bmr@redhat.com>
Tue, 30 Oct 2012 16:38:01 +0000 (16:38 +0000)
- Load map for all commands
- Tidy up debug output
- Add traling newline to configure message

wwidmap

diff --git a/wwidmap b/wwidmap
index 3658c71..a70ed5a 100755 (executable)
--- a/wwidmap
+++ b/wwidmap
@@ -74,6 +74,8 @@ add_wwid_mapping() {
     local WWID
     WWID="$1"
     NNAME="$2"
+    TYPE="$3"
+    debug "add_wwid_mapping WWID=\"$WWID\" NNAME=\"$NNAME\""
     if [ "$WWID" == "" ]; then
         warn "no wwid given"
         return
@@ -87,7 +89,7 @@ add_wwid_mapping() {
     fi
     WWIDMAP[$WWID]="$NNAME"
     NAMEMAP[$NNAME]="$WWID"
-    TYPEMAP[$WWID]="sd"
+    TYPEMAP[$WWID]=${TYPE:-"sd"}
 }
 
 # del_wwid_mapping <wwid>
@@ -155,7 +157,7 @@ EOF
         error "could not create configuration file $WM_CONF"
         exit
     fi
-    echo "done"
+    echo -e "done\n"
 }
 
 # createdisk <nickname> <device>
@@ -167,6 +169,7 @@ wm_createdisk () {
         echo "Usage: $0 createdisk <nickname> <device>"
         exit 2
     fi
+    debug "wm_createdisk: WWID=\"$WWID\" DEV=\"$DEV\" NNAME=\"$NNAME\""
     WWID=$(wm_scsi_id $DEV)
     add_wwid_mapping $WWID $NNAME "sd"
     wm_store_wwid_map
@@ -219,20 +222,19 @@ wm_map () {
     echo "WM_GROUP=$WM_GROUP"
 }
 
+# no point optimizing this out for configure
+wm_load_wwid_map
 case "$1" in
     configure)
         wm_configure
         ;;
     createdisk)
-        wm_load_wwid_map
         wm_createdisk $2 $3
         ;;
     deletedisk)
-        wm_load_wwid_map
         wm_deletedisk $2
         ;;
     listdisks)
-        wm_load_wwid_map
         wm_list_disks
         ;;
     querydisk)
@@ -242,7 +244,6 @@ case "$1" in
         wm_scandisks
         ;;
     map)
-        wm_load_wwid_map
         wm_map $2
         ;;
     *)