-# hide a little trick to unset this from the command line
-if [ "$lustre_root" == " " ]; then
- unset lustre_root
-fi
-
-if [ -z "$lustre_root" ]; then
- lctl=$(which lctl)
-else
- lctl=${lustre_root}/utils/lctl
-fi
-
-remote_shell () {
- host=$1
- shift
- cmds="$*"
- if [ "$host" = "localhost" -o "$host" = `uname -n` ]; then
- eval "$cmds"
- else
- custom_remote_shell $host "$cmds"
- fi
-}
-
-obdecho_loaded() {
- local host=$1
- remote_shell $host $lsmod | grep obdecho > /dev/null 2>&1
-}
-
-load_obdecho () {
- local host=$1
- if [ -z "$lustre_root" ]; then
- remote_shell $host $modprobe obdecho
- elif [ -f ${lustre_root}/obdecho/obdecho.ko ]; then
- remote_shell $host $insmod ${lustre_root}/obdecho/obdecho.ko
- else
- remote_shell $host $insmod ${lustre_root}/obdecho/obdecho.o
- fi
-}
-
-unload_obdecho () {
- local host=$1
- remote_shell $host $rmmod obdecho
-}
-
-get_devno () {
- local host=$1
- local type=$2
- local name=$3
- remote_shell $host $lctl device_list | \
- awk "{if (\$2 == \"UP\" && \$3 == \"$type\" && \$4 == \"$name\") {\
- print \$1; exit}}"
-}
-
-get_ec_devno () {
- local host=$1
- local client_name="$2"
- local ost_name="$3"
- if [ -z "$client_name" ]; then
- if [ -z "$ost_name" ]; then
- echo "client and ost name both null" 1>&2
- return
- fi
- client_name=${ost_name}_echo_client
- fi
- ec=`get_devno $host echo_client $client_name`
- if [ -n "$ec" ]; then
- echo $ec $client_name 0
- return
- fi
- if [ -z "$ost_name" ]; then
- echo "no echo client and ost_name not set" 1>&2
- return
- fi
- ost=`get_devno $host obdfilter $ost_name`
- if [ -z "$ost" ]; then
- echo "OST $ost_name not setup" 1>&2
- return
- fi
- remote_shell $host "$lctl <<EOF
- attach echo_client $client_name ${client_name}_UUID
- setup $ost_name
-EOF"
- ec=`get_devno $host echo_client $client_name`
- if [ -z "$ec" ]; then
- echo "Can't setup echo client" 1>&2
- return
- fi
- echo $ec $client_name 1
-}
-
-teardown_ec_devno () {
- local host=$1
- local client_name=$2
- remote_shell $host "$lctl <<EOF
- cfg $client_name
- cleanup
- detach
-EOF"
-}