Commit 5d920f11 authored by Powder4ik's avatar Powder4ik

first commit

parents
= MOAB TSI =
this is prototype of the TSI Adapter for MOAB Schedule
= Install =
```
mkdir /opt/unicore7
cd /opt/unicore7
git clone https://git.scc.kit.edu/lo4990/unicore-tsi-moab.git
# then create a link into /etc for config files
ln -s /opt/unicore7/tsi_moab/conf /etc/unicore/tsi
```
#!/bin/sh
######################### CONFIGURATION ######################################
PERL=perl
######################### CONFIGURATION ######################################
usage() {
echo ""
echo "Usage: $0 [conf_dir]"
echo ""
}
for arg in "$@"
do
case "$arg" in
-h | -help | --help | -\?)
usage
exit 0;;
*)
;;
esac
done
if [ $# -ne 0 ] && [ $# -ne 1 ]
then
usage
exit 1
fi
#
# detect TSI installation Directory
#
TSI_BIN=`dirname $0`
if [ "${TSI_BIN#/}" = "$TSI_BIN" ]
then
if [ "$TSI_BIN" != "." ]
then
TSI_DIR="$(pwd)/$TSI_BIN"
else
TSI_DIR="$(pwd)"
fi
else
TSI_DIR=$TSI_BIN
fi
TSI_DIR="${TSI_DIR%/bin}"
# Detect configuration directory:
if [ $# -eq 1 ]
then
TSI_CONF=$1
elif [ -n "$UNICORE_TSI" ]
then
TSI_CONF=$UNICORE_TSI
else
TSI_CONF="${TSI_DIR}/conf"
fi
# Sanity check. TSI_CONF must exist, be a directory and be x.
if [ ! -d $TSI_CONF ]
then
echo "TSI configuration directory $TSI_CONF is not a directory (or cannot be found)" 1>&2
exit 1
fi
if [ ! -x $TSI_CONF ]
then
echo "Cannot execute TSI configuration directory $TSI_CONF" 1>&2
exit 1
fi
#
# find tsi.properties file
#
if [ ! -r $TSI_CONF/tsi.properties ]
then
echo "The TSI configuration file $TSI_CONF/tsi.properties does not exist (or is not readable)." 1>&2
exit 1
fi
TSI_PROPS=$TSI_CONF/tsi.properties
#
# PID file
#
PID_FILE="`perl -ne 'if(/^\s*tsi.pidfile\s*=\s*(\S+)/) {print $1}' $TSI_PROPS`"
if [ -z "$PID_FILE" ]; then
PID_FILE=$TSI_CONF/LAST_TSI_PIDS
fi
#
# Look for TSI processes (shepherd and worker)
#
ppids=`cat $PID_FILE | sort -nr | xargs -n 10000`
if [ "$ppids" = "" ]; then
$PERL -e '{printf STDERR "ERROR: empty $PID_FILE file\n"}'
exit 1
fi
findpids="`echo $ppids | sed 's/ /|/g'`"
$PERL -e 'printf STDERR " PID PPID USER RUSER GROUP RGROUP COMMAND\n"'
ppids=`ps -eo pid,ppid,user,ruser,group,rgroup,args | sort -nr | $PERL -ne 'if(/^\s*('$findpids')\s+/) {printf STDERR "%s", $_; print $1." "}'`
allpids=""
while [ "$findpids" != "" ]; do
pids=`ps -eo pid,ppid,user,ruser,group,rgroup,args | sort -nr | $PERL -ne 'if(/^\s*(\d+)\s+('$findpids')\s+/) {printf STDERR "%s", $_; print $1." "}'`
allpids="$pids $allpids"
findpids="`echo $pids | sed 's/ /|/g'`"
done
$PERL -e 'printf STDERR "Found pids "'
echo $allpids $ppids
#!/bin/sh
#
# Detect TSI
#
TSI_BIN=`dirname $0`
if [ "${TSI_BIN#/}" = "$TSI_BIN" ]
then
if [ "$TSI_BIN" != "." ]
then
TSI_DIR="$(pwd)/$TSI_BIN"
else
TSI_DIR="$(pwd)"
fi
else
TSI_DIR=$TSI_BIN
fi
TSI_DIR="${TSI_DIR%/bin}"
usage() {
echo ""
echo "Usage: $0 [conf_dir]"
echo ""
}
for arg in "$@"
do
case "$arg" in
-h | -help | --help | -\?)
usage
exit 0;;
*)
;;
esac
done
if [ $# -ne 0 ] && [ $# -ne 1 ]
then
usage
exit 1
fi
# Detect configuration directory:
# - first look for command line argument
# - then in environment ($UNICORE_TSI)
# - lastly use value from this file (current directory)
if [ $# -eq 1 ]
then
TSI_CONF=$1
elif [ -n "$UNICORE_TSI" ]
then
TSI_CONF=$UNICORE_TSI
else
TSI_CONF="${TSI_DIR}/conf"
fi
# Sanity check. TSI_CONF must exist, be a directory and be x.
if [ ! -d $TSI_CONF ]
then
echo "TSI configuration directory $TSI_CONF is not a directory (or cannot be found)" 1>&2
exit 1
fi
if [ ! -x $TSI_CONF ]
then
echo "Cannot execute TSI configuration directory $TSI_CONF" 1>&2
exit 1
fi
#
# find tsi.properties file
#
if [ ! -r $TSI_CONF/tsi.properties ]
then
echo "The TSI configuration file $TSI_CONF/tsi.properties does not exist (or is not readable)." 1>&2
exit 1
fi
TSI_PROPS=$TSI_CONF/tsi.properties
#
# PID file
#
PID_FILE="`perl -ne 'if(/^\s*tsi.pidfile\s*=\s*(\S+)/) {print $1}' $TSI_PROPS`"
if [ -z "$PID_FILE" ]; then
PID_FILE=$TSI_CONF/LAST_TSI_PIDS
fi
pids=`$TSI_BIN/find_pids $TSI_CONF`
echo "$pids"
if [ "$pids" != "" ]; then
echo ""
echo kill -9 $pids
kill -9 $pids
else
echo "Nothing to kill"
fi
rm -f $PID_FILE
#!/bin/sh
usage() {
echo ""
echo "Usage: $0 type [conf_dir]"
echo ""
}
for arg in "$@"
do
case "$arg" in
-h | -help | --help | -\?)
usage
exit 0;;
*)
;;
esac
done
if [ $# -ne 1 ] && [ $# -ne 2 ]
then
usage
exit 1
fi
type=$1
shift
#
# detect TSI installation Directory
#
TSI_BIN=`dirname $0`
if [ "${TSI_BIN#/}" = "$TSI_BIN" ]
then
if [ "$TSI_BIN" != "." ]
then
TSI_DIR="$(pwd)/$TSI_BIN"
else
TSI_DIR="$(pwd)"
fi
else
TSI_DIR=$TSI_BIN
fi
TSI_DIR="${TSI_DIR%/bin}"
# >>>>>>>>>> Detect configuration directory:
# first look for command line argument
# then in environment ($UNICORE_TSI)
# then from the directory of this file
if [ $# -eq 1 ]
then
TSI_CONF=$1
elif [ -n "$UNICORE_TSI" ]
then
TSI_CONF=$UNICORE_TSI
else
TSI_CONF="${TSI_DIR}/conf"
fi
# >>>>>>>>>> Sanity check. TSI_CONF must exist, be a directory and be wx.
if [ ! -d $TSI_CONF ]
then
echo "TSI configuration directory $TSI_CONF is not a directory (or cannot be found)" 1>&2
exit 1
fi
if [ ! -w $TSI_CONF ]
then
echo "Cannot write to TSI configuration directory $TSI_CONF" 1>&2
exit 1
fi
if [ ! -x $TSI_CONF ]
then
echo "Cannot execute TSI configuration directory $TSI_CONF" 1>&2
exit 1
fi
# >>>>>>>>>> get the log dir from the tsi.properties file (and check that it is rx)
LOGDIR="`perl -ne 'if(/^\s*tsi.logdir\s*=\s*(\S+)/) {print $1}' $TSI_CONF/tsi.properties`"
if [ "$LOGDIR" == "syslog" ]
then
echo "TSI logs messages via Syslog" 1>&2
exit 1
fi
if [ ! -r $LOGDIR ] || [ ! -x $LOGDIR ]
then
echo "The TSI logging directory $TSI_CONF/logs does not exist (or is not readable and executable)." 1>&2
exit 1
fi
listing=`ls $LOGDIR/ wTSILog_*[0-9] 2> /dev/null`
# >>>>>>>>>> Write all log file names - in reverse time order
if [ "$type" = "a" ]
then
echo $listing | tr " " "\012"
exit 0
fi
echo "${LOGDIR}:"
# >>>>>>>>>> Write log file names since last start (most recent file with first line containing "starting up")
# Put into time order
rev_listing=`echo $listing | tr " " "\012" | sort -r`
if [ "$type" = "l" ]
then
collected=""
for logs in $rev_listing
do
if [ -e $LOGDIR/$logs ]
then
collected="$logs $collected"
head -n 5 $LOGDIR/$logs | fgrep -s -e "starting up"
if [ $? -eq 0 ]
then
# Found, quit
break
fi
fi
done
echo $collected | tr " " "\012"
exit 0
fi
if [ "$type" = "L" ]
then
collected=""
gathering=0
for logs in $rev_listing
do
if [ -e $LOGDIR/$logs ]
then
if [ $gathering -eq 1 ]
then
collected="$logs $collected"
else
head -n 5 $LOGDIR/$logs | fgrep -s -e "starting up"
if [ $? -eq 0 ]
then
# Found, start gathering after next
gathering=1
fi
fi
fi
done
echo $collected | tr " " "\012"
exit 0
fi
# Everything else must be a number, check
echo $type | egrep -s -e "[a-zA-Z]"
if [ $? -eq 0 ]
then
# The type does not seem to be valid (contains letters!)
echo "The type must be \"a\" (for all files), \"l\" (since latest start), \"L\" (all before latest start)" 1>&2
echo "A number (latest n), negative number (all except latest n)" 1>&2
exit 1
fi
# >>>>>>>>>> Write the latest n
my_type=$type
if [ $my_type -lt 0 ]
then
my_type=`expr $my_type \* -1`
fi
# Collect the latest n
collected=""
not_collected=""
count=0
for logs in $rev_listing
do
if [ "$count" -lt "$my_type" ]
then
# Collect in reverse time order
collected="$logs $collected"
else
not_collected="$logs $not_collected"
fi
count=`expr $count + 1`
done
if [ $type -ne $my_type ]
then
collected=$not_collected
fi
echo $collected | tr " " "\012"
exit 0
# 08-08-06 Updated, Bernd Schuller, JSC
# 06-02-02 Created, Sven van den Berghe, fecit
#
#
# Copyright (c) Fujitsu Ltd 2002
#
# Use and distribution is subject to the Community Source Licence.
#
# A copy of the Community Source Licence came with this distribution.
# Copies are also available at http://www.fecit.co.uk/arcon or by
# email from arcon@fecit.co.uk.
#!/bin/sh
######################### CONFIGURATION ######################################
PERLPATH=
PATH=$PERLPATH:$PATH
export PATH
######################### CONFIGURATION ######################################
# Uncomment this line for faster debugging, it would remain only last log
# rm -rf /opt/unicore7/tsi_selected/logs/*
#
# Detect TSI
#
TSI_BIN=`dirname $0`
if [ "${TSI_BIN#/}" = "$TSI_BIN" ]
then
if [ "$TSI_BIN" != "." ]
then
TSI_DIR="$(pwd)/$TSI_BIN"
else
TSI_DIR="$(pwd)"
fi
else
TSI_DIR=$TSI_BIN
fi
TSI_DIR="${TSI_DIR%/bin}"
usage() {
echo ""
echo "Usage: $0 [-d] [conf_dir]"
echo ""
}
debug=0
for arg in "$@"
do
case "$arg" in
-h | -help | --help | -\?)
usage
exit 0;;
-d | -debug | --debug)
debug=1
shift;;
*)
;;
esac
done
if [ $# -ne 0 ] && [ $# -ne 1 ]
then
usage
exit 1
fi
# Detect configuration directory:
if [ $# -eq 1 ]
then
TSI_CONF=$1
elif [ -n "$UNICORE_TSI" ]
then
TSI_CONF=$UNICORE_TSI
else
if [ -d /etc/unicore/tsi ]
then
TSI_CONF=/etc/unicore/tsi
fi
fi
# Sanity check: TSI_CONF must exist, be a directory and be executable
if [ ! -d $TSI_CONF ]
then
echo "TSI configuration directory $TSI_CONF is not a directory (or cannot be found)" 1>&2
exit 1
fi
if [ ! -x $TSI_CONF ]
then
echo "Cannot execute TSI configuration directory $TSI_CONF" 1>&2
exit 1
fi
# check config file $TSI_CONF/tsi.properties (needs to be r)
TSI_PROPS=$TSI_CONF/tsi.properties
echo $TSI_PROPS
if [ ! -r $TSI_PROPS ]
then
echo "The TSI configuration file $TSI_PROPS does not exist (or is not readable)." 1>&2
exit 1
fi
echo ""
echo "Evaluating $TSI_PROPS:"
echo "Found TSI $TSI_DIR"
echo ""
#
# PID file
#
PID_FILE="`perl -ne 'if(/^\s*tsi.pidfile\s*=\s*(\S+)/) {print $1}' $TSI_PROPS`"
if [ -z "$PID_FILE" ]; then
PID_FILE=$TSI_CONF/LAST_TSI_PIDS
fi
# Is there an instance of the TSI already running?
if [ -f $PID_FILE ]
then
last_pid=`cat $PID_FILE | xargs -n 10000 | sed 's/ /,/g'`
if [ $? != 0 ]
then
echo "Could not read pid file $PID_FILE" 1>&2
exit 1
fi
ps -p $last_pid > /dev/null 2>&1
if [ $? != 0 ]
then
# ps failed (no process or PID_FILE corrupt)
rm -f $PID_FILE
if [ $? != 0 ]
then
echo "Could not remove pid file $PID_FILE" 1>&2
exit 1
fi
else
# ps -p succeeded on pid in file, thus TSI is running
echo "There is already a TSI running (with pid(s) $last_pid)" 1>&2
exit 0
fi
fi
# check log dir
LOG_DIR="`perl -ne 'if(/^\s*tsi.logdir\s*=\s*(\S+)/) {print $1}' $TSI_PROPS`"
if [ "$LOG_DIR" != "syslog" ]; then
mkdir -p $LOG_DIR
if [ ! -r $LOG_DIR ] || [ ! -w $LOG_DIR ]
then
echo "The TSI logging directory $LOG_DIR does not exist (or is not readable and writable)." 1>&2
echo ""
exit 1;
fi
date=`date +_%Y_%m_%d`
time=`date +_%H_%M`
tsilog=$LOG_DIR/TSILog${date}${time}
echo "Logging to $tsilog"
else
echo "TSI logs messages via Syslog"
fi
# set default umask
umask 77
# the main tsi file
EXEC=$TSI_DIR/perl/tsi
if [ ! -r $EXEC ]
then
echo "The TSI file $EXEC does not exist (or is not readable)." 1>&2
echo ""
exit 1
fi
if [ $debug -eq 1 ]; then
echo "perl -d $EXEC $TSI_PROPS"
perl -d "$EXEC" "$TSI_PROPS"
else
if [ "$LOG_DIR" != "syslog" ]; then
echo "nohup perl $EXEC $TSI_PROPS > $tsilog 2>&1 &"
nohup perl "$EXEC" "$TSI_PROPS" > $tsilog 2>&1 &
else
echo "nohup perl $EXEC $TSI_PROPS 2>/dev/null &"
nohup perl "$EXEC" "$TSI_PROPS" 2>/dev/null &
fi
echo $! >> $PID_FILE
$TSI_BIN/find_pids $TSI_CONF
fi
#
# Example configuration file for the UNICORE TSI
#
# The path to the main "tsi" file
# (directories only, without "tsi" file)
tsi.path=/opt/unicore7/tsi_selected/perl
# The name/address of the system where the UNICORE 6 server is executing
# This can be a comma-separated list of names
# Only connection requests from these hosts will be accepted
tsi.njs_machine=unicore-bwunicluster.scc.kit.edu
# The port on which the server is listening for TSI worker connections
# (must match the CLASSICTSI.replyport value in the XNJS configuration file).
tsi.njs_port=7777
# The interface address on which the TSI shepherd process will listen
# for XNJS requests (must match the CLASSICTSI.machine value in the
# XNJS configuration file). Leaving this variable unset will default
# to binding to all interfaces, which can also be achieved by setting
# this to 0.0.0.0 to be more explicit.
tsi.my_addr=0.0.0.0
# The port on which the TSI shepherd process will listen for XNJS requests
# (must match the CLASSICTSI.port value in the XNJS configuration file).
tsi.my_port=4433
#
# Logging directory to be used, by default log to base TSI dir
# If value is "syslog", logging will go to syslog instead of a file
#
tsi.logdir=/opt/unicore7/tsi_selected/logs
#
# The Syslog facility to report to (relevant only if syslog is enabled)
#
tsi.logfacility=LOG_USER
#
# The Syslog host where log output should go (relevant only if syslog is
# enabled). By default logs are sent to the local Syslog daemon
#
#tsi.loghost=
#
# The convertion pattern used to format logging message strings
# It is composed of literal text and format control expressions
# (%u = username, %m = log message)
#
tsi.logformat=%m
# If set to true then groups of the grid user will be limited to those
# available for the chosen Xlogin as defined in the operating system
# (via /etc/groups or LDAP etc.). If set to false then XNJS will be free
# to assign any groups for the user regardless of the operating system
# settings what allows for more grid configuration flexibility but limits
# site autonomy.
#
tsi.enforce_gids_consistency=true
# This option is advanced and rarely changed.
# If it is set to true then TSI will deny requests from XNJS with non-existing groups or
# (if also tsi.enforce_gids_consistency is true) inconsistent groups with OS settings
# for the chosen Xlogin. If this setting is false then TSI won't deny such requests. It
# will simply ignore bogus groups (if primary group is wrong, then it will be replaced by
# the default OS group for the Xlogin).
#
tsi.fail_on_invalid_gids=false
#
# A name to be given to batch jobs if the user does not supply one
# or if the given one is invalid
#
tsi.default_job_name=UnicoreJob