Rename NNAME (nickname) -> ALIAS
authorBryn M. Reeves <bmr@redhat.com>
Wed, 31 Oct 2012 20:12:44 +0000 (20:12 +0000)
committerBryn M. Reeves <bmr@redhat.com>
Wed, 31 Oct 2012 20:12:44 +0000 (20:12 +0000)
The script was previously claled nickname. ALIAS is a better name
for the variable that makes the use more clear.

blkdevalias

index f1dd108..4486c63 100755 (executable)
@@ -37,7 +37,7 @@ print_wwid_mapping() {
     if [ "$WWID" == "" ]; then
         return
     fi
-    debug "NNAME for WWID '$WWID' is: '${WWIDMAP[$WWID]}' (${TYPEMAP[$WWID]})"
+    debug "ALIAS for WWID '$WWID' is: '${WWIDMAP[$WWID]}' (${TYPEMAP[$WWID]})"
 }
 
 # store the WWID map to disk
@@ -59,12 +59,12 @@ ba_load_wwid_map() {
         error "$BA_MAP_PATH does not exist or is not readable"
         exit 1
     fi
-    while read WWID NNAME TYPE; do
+    while read WWID ALIAS TYPE; do
         if [[ $WWID == \#* ]]; then
             continue
         fi
-        WWIDMAP[$WWID]="$NNAME"
-        NAMEMAP[$NNAME]="$WWID"
+        WWIDMAP[$WWID]="$ALIAS"
+        NAMEMAP[$ALIAS]="$WWID"
         TYPEMAP[$WWID]="$TYPE"
     done < $BA_MAP_PATH
 }
@@ -73,28 +73,28 @@ ba_load_wwid_map() {
 ba_add_wwid_mapping() {
     local WWID
     WWID="$1"
-    NNAME="$2"
+    ALIAS="$2"
     TYPE="$3"
-    debug "ba_add_wwid_mapping WWID=\"$WWID\" NNAME=\"$NNAME\""
+    debug "ba_add_wwid_mapping WWID=\"$WWID\" ALIAS=\"$ALIAS\""
     if [ "$WWID" == "" ]; then
         warn "no wwid given"
         return
     fi
-    if [ "$NNAME" == "" ]; then
+    if [ "$ALIAS" == "" ]; then
         warn "no nickname given"
         return
     fi
     if [ "${NAMEMAP[$WWID]}" != "" ]; then
         warn "$WWID already mapped to name ${NAMEMAP[$WWID]}; replacing it."
     fi
-    WWIDMAP[$WWID]="$NNAME"
-    NAMEMAP[$NNAME]="$WWID"
+    WWIDMAP[$WWID]="$ALIAS"
+    NAMEMAP[$ALIAS]="$WWID"
     TYPEMAP[$WWID]=${TYPE:-"sd"}
 }
 
 # ba_del_wwid_mapping <wwid>
 ba_del_wwid_mapping() {
-    local WWID NNAME
+    local WWID ALIAS
     WWID="$1"
     if [ "$WWID" == "" ]; then
         return 1
@@ -103,9 +103,9 @@ ba_del_wwid_mapping() {
         warn "WARNING: $WWID does not exist; doing nothing."
         return 1
     fi
-    NNAME=${WWIDMAP[$WWID]}
+    ALIAS=${WWIDMAP[$WWID]}
     unset WWIDMAP[$WWID]
-    unset NAMEMAP[$NNAME]
+    unset NAMEMAP[$ALIAS]
     unset TYPEMAP[$WWID]
 }
 
@@ -163,33 +163,33 @@ EOF
 
 # createdisk <nickname> <device>
 ba_createdisk () {
-    local WWID DEV NNAME
-    NNAME="$1"
+    local WWID DEV ALIAS
+    ALIAS="$1"
     DEV="$2"
-    if [ "$DEV" == "" ] || [ "$NNAME" == "" ]; then
+    if [ "$DEV" == "" ] || [ "$ALIAS" == "" ]; then
         echo "Usage: $0 createdisk <nickname> <device>"
         exit 2
     fi
-    debug "ba_createdisk: WWID=\"$WWID\" DEV=\"$DEV\" NNAME=\"$NNAME\""
+    debug "ba_createdisk: WWID=\"$WWID\" DEV=\"$DEV\" ALIAS=\"$ALIAS\""
     WWID=$(ba_scsi_id $DEV)
-    ba_add_wwid_mapping $WWID $NNAME "sd"
+    ba_add_wwid_mapping $WWID $ALIAS "sd"
     ba_store_wwid_map
 }
 
 ba_deletedisk () {
-    local WWID NNAME
-    NNAME=$1
-    if [ "$NNAME" == "" ]; then
+    local WWID ALIAS
+    ALIAS=$1
+    if [ "$ALIAS" == "" ]; then
         echo "Usage: $0 deletedisk <nickname>"
         exit 2
     fi
-    WWID=${NAMEMAP[$NNAME]}
+    WWID=${NAMEMAP[$ALIAS]}
     if [ "$WWID" == "" ]; then
-        error "\"$NNAME\" does not exist"
+        error "\"$ALIAS\" does not exist"
         echo "Usage: $0 deletedisk <nickname>"
         exit 2
     fi
-    echo -n "Removing wwid map disk \"$NNAME\":"
+    echo -n "Removing wwid map disk \"$ALIAS\":"
     ba_del_wwid_mapping $WWID \
     && echo "                                  [  OK  ]"
     ba_store_wwid_map
@@ -202,27 +202,27 @@ ba_list_disks () {
 }
 
 ba_querydisk () {
-    local LISTDEV ONDEV WWID NNAME
+    local LISTDEV ONDEV WWID ALIAS
     if [ "$1" == "-d" ]; then
         LISTDEV=1
         shift
     fi
-    NNAME=$1
-    if [ "$NNAME" == "" ]; then
+    ALIAS=$1
+    if [ "$ALIAS" == "" ]; then
         echo "Usage: $0 querydisk <nickname>"
         exit 2
     fi
-    WWID=${NAMEMAP[$NNAME]}
-    debug "ba_querydisk: NNAME=\"$NNAME\" WWID=\"$WWID\" LISTDEV=\"$LISTDEV\""
+    WWID=${NAMEMAP[$ALIAS]}
+    debug "ba_querydisk: ALIAS=\"$ALIAS\" WWID=\"$WWID\" LISTDEV=\"$LISTDEV\""
     if [ "$LISTDEV" == "1" ]; then
-        DEV="/dev/$BA_DEV_PATH/$(readlink "/dev/$BA_DEV_PATH/$NNAME")"
+        DEV="/dev/$BA_DEV_PATH/$(readlink "/dev/$BA_DEV_PATH/$ALIAS")"
         MAJ="$[0x$(stat --format "%t" $DEV)]"
         MIN="$[0x$(stat --format "%T" $DEV)]"
         ONDEV="on device [$MAJ,$MIN]"
         debug "ba_querydisk: DEV=\"$DEV\" MAJ=\"$MAJ\" MIN=\"$MIN\""
     fi
     if [ "$WWID" != "" ]; then
-        echo "$NNAME is a valid blkdevalias disk$ONDEV"
+        echo "$ALIAS is a valid blkdevalias disk$ONDEV"
         return
     fi
     exit 1