user: slurm ''' import sys import os import Thiao if __name__ == '__main__': try: # save the log sys.stdout = open(Thiao.ConfigLoader.suspendLog, "a") sys.stderr = sys.stdout pass except: pass if not "ONE_AUTH" in os.environ: print ("trying to set ONE_AUTH") os.environ["ONE_AUTH"] = Thiao.ConfigLoader.oneAuth #hosts = "fg10,fg[0-9],vm[2-12]" print ("Warning: This module is DEPRECATED, use the c++ version instead: /src/Suspend.cpp") hosts = sys.argv[1] hlist = Thiao.extend_host_list(hosts) print ("shutting down the following hosts: ", hlist) for h in hlist: Thiao.shutdown_vm_by_name(h)
slurm scontrol update nodename=fg10 state=[idle|down] ''' import sys import os import Thiao if __name__ == '__main__': try: # save the log sys.stdout = open(Thiao.ConfigLoader.resumeLog, "a") sys.stderr = sys.stdout pass except: pass if not "ONE_AUTH" in os.environ: print ("trying to set ONE_AUTH") os.environ["ONE_AUTH"] = Thiao.ConfigLoader.oneAuth #hosts = "fg10,fg[0-9],vm[2-12]" print ("WARNING: This module is DEPRECATED, use the c++ version instead: /src/Resume.cpp") hosts = sys.argv[1] hlist = Thiao.extend_host_list(hosts) print ("booting the following hosts: ", hlist) for h in hlist: Thiao.launch_vm_by_name(h)
def usage(): print ("tclean.py [jobid]\n") if __name__ == '__main__': #sys.stdout = open("/tmp/tclean.log", "a") try: # save the log sys.stdout = open(Thiao.ConfigLoader.tcleanLog, "a") sys.stderr = sys.stdout pass except: pass try:# read job id from the arguments job = int(sys.argv[1]) except: try: # read the job id from the environment job = int( os.getenv("SLURM_JOB_ID")) except: usage() exit() if not "ONE_AUTH" in os.environ: print ("trying to set ONE_AUTH") os.environ["ONE_AUTH"] = Thiao.ConfigLoader.oneAuth Thiao.clean_job(job)
print ("usage:\n" "tusb.py /path/to/script.sh\n" "tsub.py [jobid]\n") if __name__ == '__main__': if len(sys.argv) != 2: usage() quit() try: job = int(sys.argv[1]) except: print ("trying to submit the job") job = Thiao.job_submit(sys.argv[1]) print ("got this job id: ", job) print ("retrieving job requirements") nodes, memory = Thiao.get_job_requirements(job) print ("nodes: ", nodes) vms = Thiao.list_down_vms() if len(vms) >= nodes: print ("launching VMs for job") vms = vms[:nodes] Thiao.launch_vm(vms, job) else: print("not enough vms to launch the job")