From: Brian K. <br...@li...> - 2010-02-12 23:13:11
|
Adds ls-vscsi, ls-veth, and ls-vdev scripts the HMC can call to retrieve VIO related information from Linux. Signed-off-by: Brian King <br...@li...> --- powerpc-utils.spec.in | 3 + scripts/Makefile.am | 4 +- scripts/Makefile.in | 4 +- scripts/ls-vdev | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/ls-veth | 64 ++++++++++++++++++++++++++++++++++++++++++ scripts/ls-vscsi | 62 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 209 insertions(+), 4 deletions(-) diff -puN /dev/null scripts/ls-vdev --- /dev/null 2009-12-15 17:58:07.000000000 -0600 +++ powerpc-utils-bjking1/scripts/ls-vdev 2010-02-12 17:00:27.000000000 -0600 @@ -0,0 +1,76 @@ +#! /bin/bash + +# Copyright (c) 2010 International Business Machines +# Common Public License Version 1.0 (see COPYRIGHT) +# +# Author Brian King <br...@li...> +# +# ls-vdev - This utility provides the HMC or IVM with name information for +# virtual scsi adapters and devices +# + +LSVDEV="ls-vdev" +VERSION="0.1" +LS="/bin/ls" +GREP="/bin/grep" +SED="/bin/sed" + +usage() +{ + echo "Usage: $LSVDEV" + echo "Provide information on Virtual SCSI adapters and devices" + echo "" + echo "Optional arguments." + echo " -V, --version Display version information and exit" + echo " -h, --help Display this help information and exit" + echo "" +} + +show_version() +{ + echo "$LSVDEV: Version $VERSION" + echo "Written by: Brian King <br...@li...>" +} + + +while getopts "Vh" flag ; do + case "$flag" in + V) show_version + exit 0 ;; + + h) usage + exit 0 ;; + \?) usage + exit 1 ;; + :) echo "Option -$OPTARG requires an argument." + exit 1 ;; + esac +done + +# Look at every ibmvscsi (Virtual SCSI) device +for dev in $($LS -d /proc/device-tree/vdevice/v-scsi* 2> /dev/null) ; do + # find the slot so it can be used in sysfs + slot=$(echo $dev | $SED -e "s/\/proc\/device-tree\/vdevice\/v-scsi@//") + + # there is only one host per device, assign it to the path's name + for host in $($LS -d /sys/devices/vio/$slot/host*) ; do + parent=$(echo $host | $SED -e "s/.*\///") + host=$($LS -d /sys/devices/vio/$slot/host*/) + + # loop through the targets for this host. + for t in $($LS -d $host/target*); do + target=$(echo $($LS -d $t/$($LS $t | $GREP -v uevent | $GREP -v power | $GREP -v subsystem))) + if [[ ! -d $target/block ]]; then + name=$(echo $($LS -d $target/block*) | $SED -e "s/.*://") + else + name=$($LS $target/block) + fi + + echo "$parent $name" + done + done +done + +exit 0 + +# end diff -puN /dev/null scripts/ls-veth --- /dev/null 2009-12-15 17:58:07.000000000 -0600 +++ powerpc-utils-bjking1/scripts/ls-veth 2010-02-12 16:57:39.000000000 -0600 @@ -0,0 +1,64 @@ +#! /bin/bash + +# Copyright (c) 2010 International Business Machines +# Common Public License Version 1.0 (see COPYRIGHT) +# +# Author Brian King <br...@li...> +# +# ls-veth - This utility provides the HMC or IVM with name information for +# virtual ethernet devices +# + +LSVETH="ls-veth" +VERSION="0.1" +OFPATHNAME="/usr/sbin/ofpathname" +CAT="/bin/cat" +LS="/bin/ls" +SED="/bin/sed" + +usage() +{ + echo "Usage: $LSVETH [-h]" + echo "Provide information on Virtual Ethernet devices" + echo "" + echo "Optional arguments." + echo " -V, --version Display version information and exit" + echo " -h, --help Display this help information and exit" + echo "" +} + +show_version() +{ + echo "$LSVETH: Version $VERSION" + echo "Written by: Brian King <br...@li...>" +} + + +while getopts "Vh" flag ; do + case "$flag" in + V) show_version + exit 0 ;; + + h) usage + exit 0 ;; + \?) usage + exit 1 ;; + :) echo "Option -$OPTARG requires an argument." + exit 1 ;; + esac +done + +# Look at every ibmveth (Virtual Ethernet) device +for dev in $($LS -d /proc/device-tree/vdevice/l-lan* 2> /dev/null); do + # use ofpathname to get the device name (i.e. eth0) + name=$($OFPATHNAME -l $(echo $dev | $SED -e "s/\/proc\/device-tree//")) + + # get the physical location + physloc=$($CAT $dev/ibm,loc-code) + + echo "$name $physloc" +done + +exit 0 + +# end diff -puN /dev/null scripts/ls-vscsi --- /dev/null 2009-12-15 17:58:07.000000000 -0600 +++ powerpc-utils-bjking1/scripts/ls-vscsi 2010-02-12 16:59:31.000000000 -0600 @@ -0,0 +1,62 @@ +#! /bin/bash + +# Copyright (c) 2010 International Business Machines +# Common Public License Version 1.0 (see COPYRIGHT) +# +# Author Brian King <br...@li...> +# +# ls-vscsi - This utility provides the HMC or IVM with name information for +# virtual scsi devices +# + +LSVSCSI="ls-vscsi" +VERSION="0.1" +CAT="/bin/cat" +LS="/bin/ls" +SED="/bin/sed" + +usage() +{ + echo "Usage: $LSVSCSI" + echo "Provide information on Virtual devices" +} + +show_version() +{ + echo "$LSVSCSI: Version $VERSION" + echo "Written by: Brian King <br...@li...>" +} + + +while getopts "Vh" flag ; do + case "$flag" in + + V) show_version + exit 0 ;; + + h) usage + exit 0 ;; + \?) usage + exit 1 ;; + esac +done + + +# Look at every ibmvscsi (Virtual SCSI) device +for dev in $($LS -d /proc/device-tree/vdevice/v-scsi* 2> /dev/null) ; do + # pull the physical location + physloc=$($CAT $dev/ibm,loc-code) + + # find the slot so it can be used in sysfs + slot=$(echo $dev | $SED -e "s/\/proc\/device-tree\/vdevice\/v-scsi@//") + + # there is only one host per device, assign it to the path's name + for host in $($LS -d /sys/devices/vio/$slot/host*) ; do + name=$(echo $host | $SED -e "s/.*\///") + echo "$name $physloc" + done +done + +exit 0 + +# end diff -puN powerpc-utils.spec.in~powerpc_lsvio powerpc-utils.spec.in --- powerpc-utils/powerpc-utils.spec.in~powerpc_lsvio 2010-02-12 17:08:37.000000000 -0600 +++ powerpc-utils-bjking1/powerpc-utils.spec.in 2010-02-12 17:09:06.000000000 -0600 @@ -41,6 +41,9 @@ Utilities for maintaining and servicing /usr/sbin/ofpathname /usr/sbin/ppc64_cpu /usr/sbin/lsdevinfo +/usr/sbin/ls-veth +/usr/sbin/ls-vdev +/usr/sbin/ls-vscsi /etc/init.d/ibmvscsis.sh diff -puN scripts/Makefile.am~powerpc_lsvio scripts/Makefile.am --- powerpc-utils/scripts/Makefile.am~powerpc_lsvio 2010-02-12 17:10:39.000000000 -0600 +++ powerpc-utils-bjking1/scripts/Makefile.am 2010-02-12 17:11:11.000000000 -0600 @@ -2,10 +2,10 @@ bin_SCRIPTS = amsstat dist_bin_SCRIPTS = amsstat sbin_SCRIPTS = update_flash hvcsadmin vscsisadmin rtas_dump snap \ - bootlist ofpathname lsdevinfo + bootlist ofpathname lsdevinfo ls-veth ls-vscsi ls-vdev dist_sbin_SCRIPTS = update_flash hvcsadmin vscsisadmin rtas_dump snap \ - bootlist ofpathname lsdevinfo + bootlist ofpathname lsdevinfo ls-veth ls-vscsi ls-vdev initdir = /etc/init.d init_DATA = ibmvscsis.sh diff -puN scripts/Makefile.in~powerpc_lsvio scripts/Makefile.in --- powerpc-utils/scripts/Makefile.in~powerpc_lsvio 2010-02-12 17:10:44.000000000 -0600 +++ powerpc-utils-bjking1/scripts/Makefile.in 2010-02-12 17:11:24.000000000 -0600 @@ -150,10 +150,10 @@ top_srcdir = @top_srcdir@ bin_SCRIPTS = amsstat dist_bin_SCRIPTS = amsstat sbin_SCRIPTS = update_flash hvcsadmin vscsisadmin rtas_dump snap \ - bootlist ofpathname lsdevinfo + bootlist ofpathname lsdevinfo ls-veth ls-vscsi ls-vdev dist_sbin_SCRIPTS = update_flash hvcsadmin vscsisadmin rtas_dump snap \ - bootlist ofpathname lsdevinfo + bootlist ofpathname lsdevinfo ls-veth ls-vscsi ls-vdev initdir = /etc/init.d init_DATA = ibmvscsis.sh _ |