From ebf5d3f00e8cc27d0572593d6a28ce1ca17fa399 Mon Sep 17 00:00:00 2001 From: Daniel Milroy Date: Thu, 31 Oct 2024 12:07:52 -0700 Subject: [PATCH] reapi: add grow function to C API --- resource/reapi/bindings/c/reapi_cli.cpp | 22 +++++++++++++++++----- resource/reapi/bindings/c/reapi_cli.h | 12 ++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/resource/reapi/bindings/c/reapi_cli.cpp b/resource/reapi/bindings/c/reapi_cli.cpp index 6bec44ca9..1f08c2ddb 100644 --- a/resource/reapi/bindings/c/reapi_cli.cpp +++ b/resource/reapi/bindings/c/reapi_cli.cpp @@ -186,6 +186,16 @@ extern "C" int reapi_cli_update_allocate (reapi_cli_ctx_t *ctx, return rc; } +extern "C" int reapi_cli_grow (reapi_cli_ctx_t *ctx, + const char *R_subgraph) +{ + if (!ctx || !ctx->rqt || !R_subgraph) { + errno = EINVAL; + return -1; + } + return reapi_cli_t::grow (ctx->rqt, R_subgraph) +} + extern "C" int reapi_cli_cancel (reapi_cli_ctx_t *ctx, const uint64_t jobid, bool noent_ok) { if (!ctx || !ctx->rqt) { @@ -259,11 +269,13 @@ extern "C" const char *reapi_cli_get_err_msg (reapi_cli_ctx_t *ctx) { std::string err_buf = ""; - if (ctx->rqt) - err_buf = ctx->rqt->get_resource_query_err_msg () + reapi_cli_t::get_err_message () - + ctx->err_msg; - else - err_buf = reapi_cli_t::get_err_message () + ctx->err_msg; + if (!ctx || !ctx->rqt) { + errno = EINVAL; + return "ERROR: REAPI context and/or rqt null \n"; + } + + err_buf = ctx->rqt->get_resource_query_err_msg () + reapi_cli_t::get_err_message () + + ctx->err_msg; return strdup (err_buf.c_str ()); } diff --git a/resource/reapi/bindings/c/reapi_cli.h b/resource/reapi/bindings/c/reapi_cli.h index eeca639dd..46063eb9f 100644 --- a/resource/reapi/bindings/c/reapi_cli.h +++ b/resource/reapi/bindings/c/reapi_cli.h @@ -140,6 +140,18 @@ int reapi_cli_update_allocate (reapi_cli_ctx_t *ctx, double *ov, const char **R_out); +/*! Update the resource state with R. + * + * \param h Opaque handle. How it is used is an implementation + * detail. However, when it is used within a Flux's + * service module, it is expected to be a pointer + * to a flux_t object. + * \param R_subgraph R string + * \return 0 on success; -1 on error. + */ +int reapi_cli_grow (reapi_cli_ctx_t *ctx, + const char *R_subgraph); + /*! Cancel the allocation or reservation corresponding to jobid. * * \param ctx reapi_cli_ctx_t context object