[ofa-general] [PATCH 1/3] infiniband-diags/scripts/set_nodedesc.sh: enhance to be able to set names other than hostname and to provide feedback on the names assigned.
Ira Weiny
weiny2 at llnl.gov
Thu Mar 20 18:13:36 PDT 2008
>From e4da62e7fa20921af62f65f98d23c8154acdad1a Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Mon, 17 Mar 2008 14:46:45 -0700
Subject: [PATCH] infiniband-diags/scripts/set_nodedesc.sh: enhance to be able to set names other
than hostname and to provide feedback on the names assigned.
Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
infiniband-diags/scripts/set_nodedesc.sh | 47 ++++++++++++++++++++++++++++--
1 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/infiniband-diags/scripts/set_nodedesc.sh b/infiniband-diags/scripts/set_nodedesc.sh
index 7b817cc..55a2fd1 100755
--- a/infiniband-diags/scripts/set_nodedesc.sh
+++ b/infiniband-diags/scripts/set_nodedesc.sh
@@ -1,17 +1,58 @@
#!/bin/sh
-# set the node_desc field of any hca found to the defined hostname
-
+if [ -f /etc/sysconfig/network ]; then
. /etc/sysconfig/network
+fi
ib_sysfs="/sys/class/infiniband"
+newname="$HOSTNAME"
+
+
+function usage
+{
+ echo "Usage: `basename $0` [-hv] [<name>]"
+ echo " set the node_desc field of all hca's found in \"$ib_sysfs\""
+ echo " -h this help"
+ echo " -v view all node descriptors"
+ echo " [<name>] set name to name specified."
+ echo " Default is to use the hostname: \"$HOSTNAME\""
+ exit 2
+}
+
+function viewall
+{
+ for hca in `ls $ib_sysfs`; do
+ if [ -f $ib_sysfs/$hca/node_desc ]; then
+ echo -n "$hca: "
+ cat $ib_sysfs/$hca/node_desc
+ else
+ logger -s "Failed to set node_desc for : $hca"
+ fi
+ done
+ exit 0
+}
+
+while getopts "hv" flag
+do
+ case $flag in
+ "h") usage;;
+ "v") viewall;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+
+if [ "$1" != "" ]; then
+ newname="$1"
+fi
for hca in `ls $ib_sysfs`; do
if [ -f $ib_sysfs/$hca/node_desc ]; then
- echo -n "$HOSTNAME" >> $ib_sysfs/$hca/node_desc
+ echo -n "$newname" >> $ib_sysfs/$hca/node_desc
else
logger -s "Failed to set node_desc for : $hca"
fi
done
exit 0
+
--
1.5.1
More information about the general
mailing list