Skip to content
Snippets Groups Projects
Commit 5bc99e85 authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Add lua script for Slurm job_submit/lua interface

Routes user job submissions to the nodes they are allowed to run on.
parent 74d3a863
No related branches found
No related tags found
1 merge request!1Add lua script for Slurm job_submit/lua interface
--[[
Example lua script demonstrating the Slurm job_submit/lua interface.
This is only an example, not meant for use in its current form.
For use, this script should be copied into a file name "job_submit.lua"
in the same directory as the Slurm configuration file, slurm.conf.
--]]
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
-- Load necessary library
local pwd = require("posix").pwd
local grp = require("posix").grp
function slurm_job_submit(job_desc, part_list, submit_uid)
local target_group = "gpfs5"
local username = pwd.getpwuid(submit_uid).pw_name
local group_member = grp.getgrnam(target_group).gr_mem
local found = false
slurm.log_info("username:" .. username)
slurm.log_info("job_desc:" .. dump(job_desc) .. type(job_desc))
slurm.log_info("job_desc.features:" .. dump(job_desc.features))
slurm.log_info("part_list:" .. dump(part_list) .. type(part_list))
slurm.log_info("submit_uid:" .. dump(submit_uid) .. type(submit_uid))
-- Checking if the user is in the target_group
-- By compare group member and the username
for i,member in ipairs(group_member) do
if member == username then
found = true
job_desc.features = "gpfs5"
break
end
end
if found != true then
job_desc.features = "gpfs4"
end
slurm.log_info("found:" .. dump(found))
slurm.log_info("job_desc.features:" .. dump(job_desc.features))
--slurm.log_user("job_desc.features: " .. dump(job_desc.features))
return slurm.SUCCESS
end
function slurm_job_modify(job_desc, job_rec, part_list, modify_uid)
if job_desc.comment == nil then
local comment = "***TEST_COMMENT***"
slurm.log_info("slurm_job_modify: for job %u from uid %u, setting default comment value: %s",
job_rec.job_id, modify_uid, comment)
job_desc.comment = comment
end
return slurm.SUCCESS
end
slurm.log_info("initialized")
return slurm.SUCCESS
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