Allow abbreviated commands
authorBryn M. Reeves <bmr@redhat.com>
Thu, 1 Nov 2012 01:39:18 +0000 (01:39 +0000)
committerBryn M. Reeves <bmr@redhat.com>
Thu, 1 Nov 2012 01:39:18 +0000 (01:39 +0000)
Allow 'disk' and 'disks' to be dropped from command names.

blkdevalias

index 4486c63..975164c 100755 (executable)
@@ -171,8 +171,20 @@ ba_createdisk () {
         exit 2
     fi
     debug "ba_createdisk: WWID=\"$WWID\" DEV=\"$DEV\" ALIAS=\"$ALIAS\""
+
     WWID=$(ba_scsi_id $DEV)
-    ba_add_wwid_mapping $WWID $ALIAS "sd"
+    if [ "$WWID" == "" ]; then
+        error "could not get SCSI ID for $DEV"
+        exit 1
+    fi
+    if [[ $DEV == *mpath* ]]; then
+        TYPE=mpath
+        debug "wm_createdisk: WWID=\"$WWID\" DEV=\"$DEV\" ALIAS=\"$ALIAS\""
+    else
+        TYPE=sd
+    fi
+    ba_add_wwid_mapping $WWID $ALIAS $TYPE
     ba_store_wwid_map
 }
 
@@ -252,19 +264,19 @@ case "$1" in
     configure)
         ba_configure
         ;;
-    createdisk)
+    create*)
         ba_createdisk $2 $3
         ;;
-    deletedisk)
+    delete*)
         ba_deletedisk $2
         ;;
-    listdisks)
+    list*)
         ba_list_disks
         ;;
-    querydisk)
-        ba_querydisk $2 $3
+    query*)
+        ba_querydisks $2 $3
         ;;
-    scandisks)
+    scan*)
         ba_scandisks
         ;;
     map)