Vinod Subramaniam

Easy way to parsing HiCommand CLI

Discussion created by Vinod Subramaniam Employee on Sep 4, 2013
Latest reply on Mar 16, 2016 by Vinod Subramaniam

#!/bin/bash

 

process(){

 

    case "$1" in

        displayName)     echo -n $name" ,"$arrayType" ,"$serialNumber" ,"$displayName" ," ;;

        emulation)     echo -n $emulation" ," ;;

        arrayGroupName) echo -n $arrayGroupName" ," ;;

        raidType)     echo -n $raidType" ," ;;

        domainID)    [[ -z "$portString" ]]     && portString=$portName"-"$domainID" ,"\

                             || portString=$portString" "$portName"-"$domainID" " ;;

        WWN)        [[ -z "$WWNString" ]]     && WWNString=$WWN" "\

                             || WWNString=$WWNString" "$WWN" " ;;

        devType)     echo -n $devType" ," ;;

        capacityInKB)     echo -n $capacityInKB" ," ;;

        trueCopyVolumeType)     echo -n $trueCopyVolumeType" ," ;;

        shadowImageVolumeType)     echo -n $shadowImageVolumeType" ," ;;

        quickShadowVolumeType)     echo -n $quickShadowVolumeType" ," ;;

        universalReplicatorVolumeType) echo -n $universalReplicatorVolumeType" ," ;;

 

    esac

}

 

key=""

value=""

portString=""

WWNString=""

 

./HiCommandCLI GetStorageArray subtarget=LogicalUnit lusubinfo=Path pathsubinfo=WWN -u system -p manager\

| sed 's/An instance of LogicalUnit/;/' | tr "\n" "|" | tr ";" "\n" | tr -d " " | tr "|" " " | tr -d "," |\

while read line

do

    SPLINE=(${line// / });

    for i in "${SPLINE[@]}"

    do

        key=${i%\=*}

        value=${i#*\=}

        export $i 2> /dev/null

        process $key

    done

    echo "$portString, $WWNString"

    portString=""

    WWNString=""

done

Attachments

Outcomes