Skip to content
Snippets Groups Projects
Commit 7c043f9a authored by Jonathan Hanks's avatar Jonathan Hanks
Browse files

Merge branch 'epics-only-models' into 'master'

Epics only models

See merge request cds/advligorts!167
parents 6b091bee 05d3a85a
No related branches found
No related tags found
1 merge request!167Epics only models
......@@ -12,8 +12,13 @@ fi
# this should define all USER_VARS (see below)
ENV_FILE=${RTS_ENV:-/etc/advligorts/env}
HOST_ENV_FILE=/etc/advligorts/systemd_env_`hostname`
set -o allexport
source "$ENV_FILE" 2>/dev/null || true
if [[ -e $HOST_ENV_FILE ]] ; then
log "found host specific environment file '$HOST_ENV_FILE'"
source $HOST_ENV_FILE 2>/dev/null || true
fi
set +o allexport
SITE=${SITE^^*}
......@@ -21,6 +26,9 @@ site=${SITE,,*}
IFO=${IFO^^*}
ifo=${IFO,,*}
IS_DOLPHIN_NODE=${IS_DOLPHIN_NODE:-false}
DAQ_STREAMING=${DAQ_STREAMING:-false}
RCG_SRC=${RCG_SRC:-/usr/share/advligorts/src}
RCG_BUILD_ROOT=${RCG_BUILD_ROOT:-/var/cache/advligorts}
RCG_BUILDD=${RCG_BUILDD:-$RCG_BUILD_ROOT/rcg-$RTS_VERSION}
......@@ -48,6 +56,26 @@ umask 0002
##################################################
contains() {
local x=$1
shift
[[ $@ =~ (^|[[:space:]])$x($|[[:space:]]) ]] && return 0 || return 1
}
epics_only_model() {
contains $1 $EPICS_ONLY_MODELS && return 0 || return 1
}
# echo the systemd unit that should be used to control the model
get_model_unit() {
local sys=$1
if epics_only_model ${sys} ; then
echo "rts-epics@${sys}"
else
echo "rts@${sys}.target"
fi
}
check_env() {
for var in ${USER_VARS[*]} ; do
if [ ! "${!var}" ] ; then
......@@ -136,7 +164,8 @@ check_host_sys_enabled() {
check_host_sys_active() {
for sys ; do
check_unit_available ${sys}
if ! systemctl is-active rts@${sys}.target > /dev/null ; then
local unit_name=`get_model_unit ${sys}`
if ! systemctl is-active $unit_name > /dev/null ; then
log "System '${sys}' is not active on this system'."
exit 4
fi
......@@ -146,7 +175,8 @@ check_host_sys_active() {
check_host_sys_inactive() {
for sys ; do
check_unit_available ${sys}
if systemctl is-active rts@${sys}.target > /dev/null ; then
local unit_name=`get_model_unit ${sys}`
if systemctl is-active $unit_name > /dev/null ; then
log "System '$sys' is already active on this system'."
exit 4
fi
......@@ -186,7 +216,9 @@ install_world() {
start_sys() {
for sys ; do
log "### starting $sys..."
sudo systemctl start rts@${sys}.target
local unit_name=`get_model_unit ${sys}`
sudo systemctl start $unit_name
# pause needed to avoid timing glitch when user model started immediately after IOP
log "... waiting for start of ${sys} to complete"
sleep 15
......@@ -198,7 +230,8 @@ stop_sys() {
for sys ; do
log "### stopping $sys..."
#${SCRIPTD}/kill${sys}
sudo systemctl stop rts@${sys}.target
local unit_name=`get_model_unit ${sys}`
sudo systemctl stop $unit_name
done
}
......@@ -222,7 +255,11 @@ _lsmod() {
local dolphin=(dis_kosif dis_ix_ntb dis_ix_dma dis_irm dis_sisci dis_intel_dma)
# FIXME: how to test for needed modules?
modules=(${rts[*]} ${dolphin[*]})
if $IS_DOLPHIN_NODE ; then
local modules=(${rts[*]} ${dolphin[*]})
else
local modules=(${rts[*]})
fi
local allloaded=
for m in ${modules[*]}; do
......@@ -237,12 +274,16 @@ _lsmod() {
if [ "$systems" ] ; then
echo
for m in ${systems[*]}; do
md=$(lsmod | grep "^${m}\s") || true
if [ -z "$md" ] ; then
printf "%-18s ***NOT LOADED***\n" "$m"
allloaded=1
if epics_only_model $m ; then
test 0
else
echo "$md"
md=$(lsmod | grep "^${m}") || true
if [ -z "$md" ] ; then
printf "%-18s ***NOT LOADED***\n" "$m"
allloaded=1
else
echo "$md"
fi
fi
done
fi
......@@ -267,18 +308,22 @@ systems_status() {
echo "------------------------------------------------------"
for sys in ${systems[*]} ; do
printf '%-15s' $sys
printf '%-15s ' $sys
for subsys in ${subsystems[*]} ; do
local subsysstatus='OFF'
if systemctl is-failed "rts-${subsys}@${sys}" > /dev/null ; then
subsysstatus='FAILED'
systems_health=10
if ! epics_only_model $sys || [[ $subsys == 'epics' ]] ; then
if systemctl is-failed "rts-${subsys}@${sys}" > /dev/null ; then
subsysstatus='FAILED'
systems_health=10
else
if systemctl is-active "rts-${subsys}@${sys}" > /dev/null ; then
subsysstatus='ON'
else
systems_health=10
fi
fi
else
if systemctl is-active "rts-${subsys}@${sys}" > /dev/null ; then
subsysstatus='ON'
else
systems_health=10
fi
subsysstatus='N/A'
fi
printf '%-15s' $subsysstatus
done
......@@ -334,13 +379,16 @@ global_status() {
fi
echo
local streamer_health=0
echo
if streamer_status ; then
echo "Streamer Status = ALL ACTIVE"
else
echo "Streamer Status = DEGRADED"
streamer_health=12
if $DAQ_STREAMING ; then
echo
if streamer_status ; then
echo "Streamer Status = ALL ACTIVE"
else
echo "Streamer Status = DEGRADED"
streamer_health=12
fi
fi
echo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment