# Copyright 2008 Sun Microsystems, Inc. All rights reserved
# Use is subject to license terms.
#
-# Copyright (c) 2012, 2014, Intel Corporation.
+# Copyright (c) 2012, 2017, Intel Corporation.
#
# This file is part of Lustre, http://www.lustre.org/
-# Lustre is a trademark of Sun Microsystems, Inc.
#
# Author: Jitendra Pawar <jitendra@clusterfs.com>
local type=$2
local name=$3
- remote_shell $host $lctl device_list |
+ remote_shell $host $LCTL device_list |
awk "{if (\$2 == \"UP\" && \$3 == \"$type\" && \$4 == \"$name\") {\
print \$1; exit}}"
}
return 0
}
-# do cleanup for netdisk case.
-cleanup_netdisk () {
- for osc in $@; do
- $lctl <<-EOF
- cfg_device $osc
- cleanup
- detach
- EOF
- done
-}
-
# do cleanup for network case.
cleanup_network () {
local clean_srv_OSS=$1
- $lctl <<-EOF
- cfg_device echotmp
- cleanup
- detach
+ $LCTL <<-EOF
+ --device echotmp cleanup
+ --device echotmp detach
EOF
remote_shell "root@$server_nid" \
- "$lctl <<-EOF
- cfg_device echo_srv
- cleanup
- detach
+ "$LCTL <<-EOF
+ --device echo_srv cleanup
+ --device echo_srv detach
EOF"
if [ $clean_srv_OSS ]; then
remote_shell "root@$server_nid" \
- "$lctl <<-EOF
- cfg_device OSS
- cleanup
- detach
+ "$LCTL <<-EOF
+ --device OSS cleanup
+ --device OSS detach
EOF"
fi
}
# do cleanup and exit.
cleanup () {
+ trap 0
+
local exit_status=$1
local host
if [ $case == "network" ]; then
cleanup_network $1
fi
- if [ $case == "netdisk" ]; then
- shift
- cleanup_netdisk $@
- fi
if [ $exit_status ]; then
if [ $exit_status -ne 0 ]; then
echo "program exited with error "
fi
exit $exit_status
}
-trap 'cleanup 0 $clean_srv_OSS $cleanup_oscs' SIGHUP SIGINT SIGTERM
+trap 'cleanup 0 $clean_srv_OSS' EXIT SIGHUP SIGINT SIGTERM
# gets echoclient device number and attach it to the client UUID
# Results are returned by an echo followed by an exit
exit 1
fi
client_name=${ost_name}_ecc
- remote_shell $host \
- "$lctl <<-EOF
- attach echo_client $client_name ${client_name}_UUID
- setup $ost_name $stack_type
- EOF"
+ # Only 'attach' if '{client_name}_uuid' not already present
+ if ! [[ $($LCTL dl) =~ $client_name ]]; then
+ remote_shell $host \
+ "$LCTL <<-EOF
+ attach echo_client $client_name \
+ ${client_name}_UUID
+ setup $ost_name $stack_type
+ EOF"
+ fi
ec=$(get_devno $host echo_client $client_name)
if [ -z "$ec" ]; then
echo "Can't setup echo-client"
exit 0
}
-# Create echo-clients using osc_names and osc_uuid
-# It creates echoclients for all osc listed using #lctl device_list command
-ec_using_osc () {
- local osc_name=$1
-
- $lctl <<-EOF
- attach echo_client ${osc_name}_ecc ${osc_name}_ecc_UUID
- cfg_device ${osc_name}_ecc
- setup $osc_name
- EOF
-
-}
-
# create echo client using server nid.
ec_using_srv_nid () {
local server_nid=$1
- local ocsname=$2
+ local oscname=$2
local oscuuid=$3
- $lctl add_uuid echo_UUID $server_nid@$NETTYPE >/dev/null 2>&1
- $lctl <<-EOF
- attach osc $ocsname $oscuuid
- cfg_device $ocsname
- setup echo_srv_UUID echo_UUID
+ $LCTL add_uuid echo_UUID $server_nid@$NETTYPE >/dev/null 2>&1
+ $LCTL <<-EOF
+ attach osc $oscname $oscuuid
+ --device $oscname setup echo_srv_UUID echo_UUID
EOF
- $lctl <<-EOF
- attach echo_client ${ocsname}_ecc $oscuuid
- setup $ocsname
- EOF
-}
-
-setup_osc_for_remote_ost () {
- local ost_nid=$1
- local obdfilter_name=$2
- local host_name=host_$3
-
- $lctl add_uuid ${host_name}_UUID $ost_nid@$NETTYPE >/dev/null 2>&1
- $lctl <<-EOF
- attach osc ${obdfilter_name}_osc ${obdfilter_name}_osc_UUID
- cfg_device ${obdfilter_name}_osc
- setup ${obdfilter_name}_UUID ${host_name}_UUID
+ $LCTL <<-EOF
+ attach echo_client ${oscname}_ecc $oscuuid
+ --device ${oscname}_ecc setup $oscname
EOF
}
local test_ostfsnm=$2
remote_shell "root@$server_nid" \
- "$lctl <<-EOF
+ "$LCTL <<-EOF
attach obdecho $test_ostfsnm ${test_ostfsnm}_UUID
- cfg_device $test_ostfsnm
- setup
+ --device $test_ostfsnm setup
EOF"
}
local server_nid=$1
remote_shell "root@$server_nid" \
- "$lctl <<-EOF
+ "$LCTL <<-EOF
attach ost OSS OSS_UUID
- cfg_device OSS
- setup
+ --device OSS setup
EOF"
}
local client_name=$2
remote_shell $host \
- "$lctl <<-EOF
- cfg $client_name
- cleanup
- detach
+ "$LCTL <<-EOF
+ --device $client_name cleanup
+ --device $client_name detach
EOF"
}
check_cleanup () {
local type_obj="$1"
- local osc_names_str=$($lctl dl | grep $type_obj)
+ local osc_names_str=$($LCTL dl | grep $type_obj)
local count=0;
for name in $osc_names_str; do
check_setup () {
local type_obj="$1"
- local osc_names_str=$($lctl dl | grep $type_obj)
+ local osc_names_str=$($LCTL dl | grep $type_obj)
local count=0;
for name in $osc_names_str; do
# added from bugzill req.
get_targets () {
if [ -z "$ost_names" ]; then
- targets=$($lctl device_list | awk "{if (\$2 == \"UP\" && \
+ targets=$($LCTL device_list | awk "{if (\$2 == \"UP\" && \
\$3 == \"obdfilter\") {print \$4} }")
fi
if [ -z "$targets" ]; then