From bb7469a8ca73c885729f4584b431eb0e838a959f Mon Sep 17 00:00:00 2001 From: Zeke Morton Date: Mon, 9 Oct 2023 15:14:41 -0700 Subject: [PATCH] reapi: add overloaded info function to reapi_cli_t Problem: current info function only provides a subset of fields from job_info_t. Add in an overloaded info function that sets a shared pointed for job_info_t. --- resource/reapi/bindings/c++/reapi_cli.hpp | 2 ++ resource/reapi/bindings/c++/reapi_cli_impl.hpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/resource/reapi/bindings/c++/reapi_cli.hpp b/resource/reapi/bindings/c++/reapi_cli.hpp index 0ff9ed84b..10b67aeea 100644 --- a/resource/reapi/bindings/c++/reapi_cli.hpp +++ b/resource/reapi/bindings/c++/reapi_cli.hpp @@ -141,6 +141,8 @@ class reapi_cli_t : public reapi_t { static int find (void *h, std::string criteria, json_t *&o ); static int info (void *h, const uint64_t jobid, std::string &mode, bool &reserved, int64_t &at, double &ov); + static int info (void *h, const uint64_t jobid, + std::shared_ptr &job); static int stat (void *h, int64_t &V, int64_t &E,int64_t &J, double &load, double &min, double &max, double &avg); static const std::string &get_err_message (); diff --git a/resource/reapi/bindings/c++/reapi_cli_impl.hpp b/resource/reapi/bindings/c++/reapi_cli_impl.hpp index ebb24c580..feb3dbc5c 100644 --- a/resource/reapi/bindings/c++/reapi_cli_impl.hpp +++ b/resource/reapi/bindings/c++/reapi_cli_impl.hpp @@ -247,6 +247,22 @@ int reapi_cli_t::info (void *h, const uint64_t jobid, std::string &mode, return 0; } +int reapi_cli_t::info (void *h, const uint64_t jobid, + std::shared_ptr &job) +{ + resource_query_t *rq = static_cast (h); + + if ( !(rq->job_exists (jobid))) { + m_err_msg += __FUNCTION__; + m_err_msg += ": ERROR: nonexistent job " + + std::to_string (jobid) + "\n"; + return -1; + } + + job = rq->get_job (jobid); + return 0; +} + int reapi_cli_t::stat (void *h, int64_t &V, int64_t &E,int64_t &J, double &load, double &min, double &max, double &avg) {