diff --git a/src/common/gres.c b/src/common/gres.c index 7debdd3581d49952837d93a6a494d9eb5ea471e8..c1e2ecc7116530ce2ffa7d8618046b2211fbc737 100644 --- a/src/common/gres.c +++ b/src/common/gres.c @@ -3265,6 +3265,40 @@ static void _job_state_log(void *gres_data, uint32_t job_id, char *gres_name) } } +/* + * Extract from the job record's gres_list the count of allocated resources of + * the named gres gres typee. + * IN job_gres_list - job record's gres_list. + * IN gres_name_type - the name of the gres type to retrieve the associated + * value from. + * RET The value associated with the gres type or NO_VAL if not found. + */ +extern uint32_t gres_plugin_get_job_value_by_type(List job_gres_list, + char *gres_name_type) +{ + uint32_t gres_val, gres_name_type_id; + ListIterator job_gres_iter; + gres_state_t *job_gres_ptr; + + if (job_gres_list == NULL) + return NO_VAL; + + gres_name_type_id = _build_id(gres_name_type); + gres_val = NO_VAL; + + job_gres_iter = list_iterator_create(job_gres_list); + while ((job_gres_ptr = (gres_state_t *) list_next(job_gres_iter))) { + if (job_gres_ptr->plugin_id == gres_name_type_id) { + gres_val = ((gres_job_state_t*) + (job_gres_ptr->gres_data))->gres_cnt_alloc; + break; + } + } + list_iterator_destroy(job_gres_iter); + + return gres_val; +} + /* * Log a job's current gres state * IN gres_list - generated by gres_plugin_job_state_validate() diff --git a/src/common/gres.h b/src/common/gres.h index 130b6b00844510a89aff7356aeb500b2fd6122a6..fd53b264970b134d5c0f750a02a2221797b6ee50 100644 --- a/src/common/gres.h +++ b/src/common/gres.h @@ -421,6 +421,18 @@ extern void gres_plugin_job_merge(List from_job_gres_list, */ extern void gres_plugin_job_set_env(char ***job_env_ptr, List job_gres_list); + +/* + * Extract from the job record's gres_list the count of allocated resources of + * the named gres gres typee. + * IN job_gres_list - job record's gres_list. + * IN gres_name_type - the name of the gres type to retrieve the associated + * value from. + * RET The value associated with the gres type or NO_VAL if not found. + */ +extern uint32_t gres_plugin_get_job_value_by_type(List job_gres_list, + char *gres_name_type); + /* * Log a job's current gres state * IN gres_list - generated by gres_plugin_job_state_validate() @@ -540,5 +552,4 @@ extern int gres_plugin_step_alloc(List step_gres_list, List job_gres_list, */ extern int gres_plugin_step_dealloc(List step_gres_list, List job_gres_list, uint32_t job_id, uint32_t step_id); - #endif /* !_GRES_H */