Moe Jette <[email protected]> writes: > This is exactly what I would recommend.
I have added this patch as an attachment to the newly created enhancement request http://bugs.schedmd.com/show_bug.cgi?id=190 / Kent > Quoting Kent Engström <[email protected]>: >> Moe Jette <[email protected]> writes: >>> That information does not seem to be available today to the lua >>> script, but the src/job_submit/lua/job_submit_lua.c could be modified >>> to make that information available in a new variable. It would need >>> to execute the assoc_mgr_fill_in_assoc() function to get the >>> information then pass it in a new variable. >> >> Could something like this be OK (it seems to work with my first initial >> tests)? If so, I will test some more and send you a real patch. >> >> >> diff --git a/src/plugins/job_submit/lua/job_submit_lua.c >> b/src/plugins/job_submit/lua/job_submit_lua.c >> index 46fa6fd..3575f15 100644 >> --- a/src/plugins/job_submit/lua/job_submit_lua.c >> +++ b/src/plugins/job_submit/lua/job_submit_lua.c >> @@ -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 [email protected] */ >> @@ -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")) { >> >> >> Regards, >> -- >> Kent Engström, National Supercomputer Centre, Sweden >> [email protected], +46 13 28 4444
