From d92b0f8c88038e49eafad8cdf27c1289f3533e0a Mon Sep 17 00:00:00 2001
From: Mathis Rosenhauer <rosenhauer@dkrz.de>
Date: Thu, 11 Jul 2019 11:08:39 +0200
Subject: [PATCH] start-vnc: allow constraint(s) to be specified

---
 start-vnc | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/start-vnc b/start-vnc
index 4e6e55e..21752a6 100755
--- a/start-vnc
+++ b/start-vnc
@@ -87,6 +87,9 @@ SVNC_NODES="half"
 # Quality of service
 SVNC_QOS="normal"
 
+# Constraint for feature selection (GPU and/or memory)
+SVNC_CONSTRAINT=""
+
 # Uncomment this if you use TurboVNC as vncviewer.
 #
 # TurboVNC will work without this option but then it will use its own
@@ -146,6 +149,7 @@ Usage: $(basename "$0") [OPTION]
 Available values for OPTION include:
 
   -A acctcode  acctcode of job
+  -C list      constraint for feature selection
   -g geometry  initial geometry of vnc window
   -n nodes     number of nodes
   -q qos       job qos
@@ -168,10 +172,12 @@ ssh_frontend () {
 
 parse_options () {
     local option
-    while getopts 'A:g:n:q:t:u:v:x:' option; do
+    while getopts 'A:C:g:n:q:t:u:v:x:' option; do
         case ${option} in
             A) SVNC_ACCTCODE="$OPTARG"
                ;;
+            C) SVNC_CONSTRAINT="$OPTARG"
+               ;;
             g) SVNC_GEOMETRY="$OPTARG"
                ;;
             n) SVNC_NODES="$OPTARG"
@@ -193,6 +199,7 @@ parse_options () {
     done
 
     readonly SVNC_ACCTCODE
+    readonly SVNC_CONSTRAINT
     readonly SVNC_GEOMETRY
     readonly SVNC_QOS
     readonly SVNC_RUNTIME
@@ -229,6 +236,7 @@ submit_vnc_job () {
     ssh_frontend "cd .startvnc && sbatch" <<EOF
 #!/bin/bash -l
 #SBATCH --partition=gpu
+#SBATCH --constraint=${SVNC_CONSTRAINT}
 ${sbatch_resources}
 #SBATCH --qos=${SVNC_QOS}
 #SBATCH --time=${SVNC_RUNTIME}
-- 
GitLab