Add wm_querydisk implementation
authorBryn M. Reeves <bmr@redhat.com>
Tue, 30 Oct 2012 16:39:09 +0000 (16:39 +0000)
committerBryn M. Reeves <bmr@redhat.com>
Tue, 30 Oct 2012 16:39:09 +0000 (16:39 +0000)
Implement "wwidmap querydisk" to print the same information as the
oracleasm equivalent.

wwidmap

diff --git a/wwidmap b/wwidmap
index a70ed5a..212354a 100755 (executable)
--- a/wwidmap
+++ b/wwidmap
@@ -201,7 +201,26 @@ wm_list_disks () {
 }
 
 wm_querydisk () {
-    warn "(unimplemented)"
+    local LISTDEV ONDEV WWID NNAME
+    if [ $1 == "-d" ]; then
+        LISTDEV=1
+        shift
+    fi
+    NNAME=$1
+    if [ "$NNAME" == "" ]; then
+        echo "Usage: $0 querydisk <nickname>"
+        exit 2
+    fi
+    WWID=${NAMEMAP[$NNAME]}
+    if [ "$LISTDEV" == "1" ]; then
+        DEV="/dev/$WM_DEV_PATH/$(readlink "/dev/$WM_DEV_PATH/$NNAME")"
+        ONDEV="on device $(stat --format "[%t, %T]" $DEV)"
+    fi
+    if [ "$WWID" != "" ]; then
+        echo "$NNAME is a valid wwidmap disk$ONDEV"
+        return
+    fi
+    exit 1
 }
 
 wm_scandisks () {
@@ -238,7 +257,7 @@ case "$1" in
         wm_list_disks
         ;;
     querydisk)
-        wm_querydisk
+        wm_querydisk $2 $3
         ;;
     scandisks)
         wm_scandisks