Skip to content
Snippets Groups Projects
Commit 1a64a229 authored by Kent Engström's avatar Kent Engström Committed by Morris Jette
Browse files

Add "default_account" as a LUA job submit plugin variable.

This is useful in a submit plugin script that needs to do
different things depending on the account, as the the setting
of account from default account does not happen until after
the script has run.
parent bf2ac92b
No related branches found
No related tags found
No related merge requests found
......@@ -243,6 +243,21 @@ static void _register_lua_slurm_output_functions (void)
lua_setglobal (L, "slurm");
}
/* Get the default account for a user (or NULL if not present) */
static char *_get_default_account(uint32_t user_id)
{
slurmdb_user_rec_t user;
memset(&user, 0, sizeof(slurmdb_user_rec_t));
user.uid = user_id;
if (assoc_mgr_fill_in_user(acct_db_conn,
&user, 0, NULL) != SLURM_ERROR) {
return user.default_acct;
} else {
return NULL;
}
}
/* Get fields in an existing slurmctld job record
* NOTE: This is an incomplete list of job record fields.
* Add more as needed and send patches to slurm-dev@llnl.gov */
......@@ -335,6 +350,8 @@ static int _get_job_req_field (lua_State *L)
lua_pushnumber (L, job_desc->contiguous);
} else if (!strcmp(name, "cores_per_socket")) {
lua_pushnumber (L, job_desc->cores_per_socket);
} else if (!strcmp(name, "default_account")) {
lua_pushstring (L, _get_default_account(job_desc->user_id));
} else if (!strcmp(name, "dependency")) {
lua_pushstring (L, job_desc->dependency);
} else if (!strcmp(name, "end_time")) {
......
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