+do_nodes() {
+ local nodes=$1
+ shift
+
+ nodes=${nodes//,/ }
+ # split list to local and remote
+ local rnodes=$(echo " $nodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
+
+ if [ "$(get_node_count $nodes)" != "$(get_node_count $rnodes)" ]; then
+ do_node $HOSTNAME $@
+ fi
+
+ [ -z "$(echo $rnodes)" ] && return 0
+
+ # This is part from do_node
+ local myPDSH=$PDSH
+
+ rnodes=$(comma_list $rnodes)
+ [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ] && \
+ echo "cannot run remote command on $rnodes with $myPDSH" && return 128
+
+ if $VERBOSE; then
+ echo "CMD: $rnodes $@" >&2
+ $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
+ fi
+
+ if [ "$myPDSH" = "rsh" ]; then
+# we need this because rsh does not return exit code of an executed command
+ local command_status="$TMP/cs"
+ rsh $rnodes ":> $command_status"
+ rsh $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
+ cd $RPWD; sh -c \"$@\") ||
+ echo command failed >$command_status"
+ [ -n "$($myPDSH $rnodes cat $command_status)" ] && return 1 || true
+ return 0
+ fi
+ $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
+ return ${PIPESTATUS[0]}
+}
+
+