diff --git a/contribs/perlapi/libslurm/perl/Slurm.xs b/contribs/perlapi/libslurm/perl/Slurm.xs index 31ac7b7dafa30e220c9562eabf48033bd657f46a..f53a75621da22385fefb4e2585c2a7ad0a87d91f 100644 --- a/contribs/perlapi/libslurm/perl/Slurm.xs +++ b/contribs/perlapi/libslurm/perl/Slurm.xs @@ -427,6 +427,42 @@ slurm_load_reservations(slurm_t self = NULL) OUTPUT: RETVAL +char * +slurm_create_reservation(slurm_t self, HV* res_info = NULL) + PREINIT: + resv_desc_msg_t resv_msg; + CODE: + if(hv_to_update_reservation_msg(res_info, &resv_msg) < 0) { + XSRETURN_UNDEF; + } + RETVAL = slurm_create_reservation(&resv_msg); + OUTPUT: + RETVAL + +int +slurm_update_reservation(slurm_t self, HV* res_info = NULL) + PREINIT: + resv_desc_msg_t resv_msg; + CODE: + if(hv_to_update_reservation_msg(res_info, &resv_msg) < 0) { + XSRETURN_UNDEF; + } + RETVAL = slurm_update_reservation(&resv_msg); + OUTPUT: + RETVAL + +int +slurm_delete_reservation(slurm_t self, HV* res_info = NULL) + PREINIT: + reservation_name_msg_t resv_name; + CODE: + if(hv_to_delete_reservation_msg(res_info, &resv_name) < 0) { + XSRETURN_UNDEF; + } + RETVAL = slurm_delete_reservation(&resv_name); + OUTPUT: + RETVAL + # To be implemented in perl code # slurm_print_reservation_info_msg # slurm_print_reservation_info diff --git a/contribs/perlapi/libslurm/perl/reservation.c b/contribs/perlapi/libslurm/perl/reservation.c index 2efd406389596a8b34e1016fbf0a1c3ab8866e49..ab4ded3e5de97a34348ea3cf1c7916aa34e39f7e 100644 --- a/contribs/perlapi/libslurm/perl/reservation.c +++ b/contribs/perlapi/libslurm/perl/reservation.c @@ -82,3 +82,50 @@ reserve_info_msg_to_hv(reserve_info_msg_t* reserve_info_msg, HV* hv) return 0; } +/* + * convert perl HV to resv_desc_msg_t. + */ +int +hv_to_update_reservation_msg(HV* hv, resv_desc_msg_t* resv_msg) +{ + resv_msg->accounts = NULL; + resv_msg->duration = (uint32_t) NO_VAL; + resv_msg->end_time = (time_t) NO_VAL; + resv_msg->features = NULL; + resv_msg->flags = (uint16_t) NO_VAL; + resv_msg->licenses = NULL; + resv_msg->name = NULL; + resv_msg->node_cnt = (uint32_t) NO_VAL; + resv_msg->node_list = NULL; + resv_msg->partition = NULL; + resv_msg->start_time = (time_t) NO_VAL; + resv_msg->users = NULL; + + FETCH_FIELD(hv, resv_msg, accounts, charp, FALSE); + FETCH_FIELD(hv, resv_msg, duration, uint32_t, FALSE); + FETCH_FIELD(hv, resv_msg, end_time, time_t, FALSE); + FETCH_FIELD(hv, resv_msg, features, charp, FALSE); + FETCH_FIELD(hv, resv_msg, flags, uint16_t, FALSE); + FETCH_FIELD(hv, resv_msg, licenses, charp, FALSE); + FETCH_FIELD(hv, resv_msg, name, charp, FALSE); + FETCH_FIELD(hv, resv_msg, node_cnt, uint32_t, FALSE); + FETCH_FIELD(hv, resv_msg, node_list, charp, FALSE); + FETCH_FIELD(hv, resv_msg, partition, charp, FALSE); + FETCH_FIELD(hv, resv_msg, start_time, time_t, FALSE); + FETCH_FIELD(hv, resv_msg, users, charp, FALSE); + + return 0; +} + +/* + * convert perl HV to reservation_name_msg_t. + */ +int +hv_to_delete_reservation_msg(HV* hv, reservation_name_msg_t* resv_name) +{ + resv_name->name = NULL; + + FETCH_FIELD(hv, resv_name, name, charp, FALSE); + + return 0; +} diff --git a/contribs/perlapi/libslurm/perl/slurm-perl.h b/contribs/perlapi/libslurm/perl/slurm-perl.h index 5e6a6d625a7b079ef635d1b1c8f9bf91df71282d..7aca3ed9d501d48ea78d0cc2836a3d9f7ea61245 100644 --- a/contribs/perlapi/libslurm/perl/slurm-perl.h +++ b/contribs/perlapi/libslurm/perl/slurm-perl.h @@ -30,6 +30,8 @@ extern int hv_to_update_part_msg(HV* hv, update_part_msg_t* part_msg); extern int slurm_ctl_conf_to_hv(slurm_ctl_conf_t* conf, HV* hv); extern int reserve_info_msg_to_hv(reserve_info_msg_t* conf, HV* hv); +extern int hv_to_update_reservation_msg(HV* hv, resv_desc_msg_t* resv_msg); +extern int hv_to_delete_reservation_msg(HV* hv, reservation_name_msg_t* resv_name); extern int trigger_info_to_hv(trigger_info_t *info, HV* hv); extern int trigger_info_msg_to_hv(trigger_info_msg_t *msg, HV* hv);