Skip to content
Snippets Groups Projects
Commit 00a8f15b authored by Rickard Armiento's avatar Rickard Armiento
Browse files

Support old reservationscripts

parent 1230fb3d
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python3
#
# rar@nsc 2023-12-20: Updated to python3 and included in ssetools
#
# Original:
# cap 20190314 git managed in ~cap/git/reservationhelpers
from json import load
from os import geteuid
from pwd import getpwuid
import subprocess
import sys, os
scriptdir = os.path.dirname(os.path.realpath(__file__))
username = getpwuid(geteuid()).pw_name
accountdataf = open("/etc/beowulf/active_projects.json")
jsondata = load(accountdataf)
acclist = []
for l in jsondata:
if username in [ x[u'login'] for x in l[u'accounts'] ]:
acclist.append( l[u'rm_name'])
if "-v" in sys.argv:
print("Username: %s" % username)
print("In projects: %s" % str(acclist))
scontrolf = subprocess.Popen(["scontrol", "-o", "show", "res"],
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE)
reslist = []
reasonlist = []
for l in scontrolf.stdout:
ulist = []
alist = []
for v in l.split():
(key, val) = str(v).split('=', 1)
if ( key == 'Users' ):
ulist = val.split(",")
if ( key == 'Accounts' ):
alist = val.split(",")
if ( key == 'ReservationName' ):
resname = val
if ( key == 'StartTime' ):
starttime = val
if ( key == 'EndTime' ):
endtime = val
try:
ulist.remove('(null)')
except:
pass
if username in ulist:
reslist.append([resname, starttime, endtime, "(user)"])
for a in acclist:
if a in [ x.lower() for x in alist]:
reslist.append([resname, starttime, endtime, "(project:%s)" % a])
print("Reservations available to user:%s / project(s):%s" % (username,
",".join(acclist)))
if ( len(reslist) > 0 ):
for r in reslist:
print(" %s from %s to %s %s" % (r[0], r[1], r[2], r[3]))
print(" devel from NOW to INF (everyone)")
print()
print("Note: set one of the above as default by running:")
print(" usereservation RESERVATIONNAME")
print("Or without the usereservation alias:")
print(" source "+scriptdir+"/hpc_usereservation RESERVATIONNAME")
scontrolf.wait()
#!/bin/bash
#
# rar@nsc 2023-12-20: adjusted an included in ssetools
#
# Original version:
# initial helper by cap for course use
# 20180326 adapt to new slurm version (*_EXCLUSIVE set to empty instead of "1")
# cap 20190314 git managed in ~cap/git/reservationhelpers
if [ "$0" == "${BASH_SOURCE}" ]; then
echo "You must source this script."
exit 1
fi
if [ "$1" == "" ]; then
echo "Usage: hpc_usereservation RESERVATIONNAME"
echo " Or without the usereservation alias:"
echo "Usage: source ${BASH_SOURCE[0]} RESERVATIONNAME"
else
echo "Setting $1 as active using {SALLOC,SBATCH,SLURM}_RESERVATION"
echo
export SALLOC_RESERVATION=$1
export SBATCH_RESERVATION=$1
export SLURM_RESERVATION=$1
fi
hpc_listreservations
\ No newline at end of file
...@@ -91,6 +91,9 @@ if isFile ("/software/admin/containers/images/centos7_compute_node.sif") then ...@@ -91,6 +91,9 @@ if isFile ("/software/admin/containers/images/centos7_compute_node.sif") then
setenv("HPC_CONTAINERS_TETRALITH_EL7",capture("readlink -f /software/admin/containers/images/centos7_compute_node.sif"):gsub("\\n\$","")) setenv("HPC_CONTAINERS_TETRALITH_EL7",capture("readlink -f /software/admin/containers/images/centos7_compute_node.sif"):gsub("\\n\$",""))
end end
set_alias("usereservation", "source /software/sse2/generic/manual/ssetools/${VER}/bin/hpc_usereservation")
set_alias("hpc_usereservation", "source /software/sse2/generic/manual/ssetools/${VER}/bin/hpc_usereservation")
add_property("lmod","sticky") add_property("lmod","sticky")
EOF EOF
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment