rest: update POST /shell/run for cmd execution

Remove legacy "echo" parameter.
Add boolean "inline" parameter to determine if the execution is
an inline command or a predefined script in /opt/opengnsys/shell/
master v1.2.5-27
Alejandro Sirgo Rica 2024-11-26 11:18:36 +01:00
parent 113472d5c0
commit 00d54325d3
2 changed files with 6 additions and 6 deletions

View File

@ -75,7 +75,6 @@ struct og_msg_params {
const char *cache;
const char *cache_size;
const char *comment;
bool echo;
struct og_partition partition_setup[OG_PARTITION_MAX];
struct og_image image;
uint64_t flags;

View File

@ -65,7 +65,7 @@ struct ev_loop *og_loop;
#define OG_REST_PARAM_SYNC_DIFF_NAME (1UL << 27)
#define OG_REST_PARAM_SYNC_PATH (1UL << 28)
#define OG_REST_PARAM_SYNC_METHOD (1UL << 29)
#define OG_REST_PARAM_ECHO (1UL << 30)
#define OG_REST_PARAM_INLINE (1UL << 30)
#define OG_REST_PARAM_TASK (1UL << 31)
#define OG_REST_PARAM_TIME_YEARS (1UL << 32)
#define OG_REST_PARAM_TIME_MONTHS (1UL << 33)
@ -667,6 +667,7 @@ static int og_cmd_run_post(json_t *element, struct og_msg_params *params)
{
json_t *value, *clients;
const char *key;
bool inline_cmd;
int err = 0;
if (json_typeof(element) != JSON_OBJECT)
@ -677,9 +678,9 @@ static int og_cmd_run_post(json_t *element, struct og_msg_params *params)
err = og_json_parse_clients(value, params);
else if (!strcmp(key, "run"))
err = og_json_parse_run(value, params);
else if (!strcmp(key, "echo")) {
err = og_json_parse_bool(value, &params->echo);
params->flags |= OG_REST_PARAM_ECHO;
else if (!strcmp(key, "inline")) {
err = og_json_parse_bool(value, &inline_cmd);
params->flags |= OG_REST_PARAM_INLINE;
}
if (err < 0)
@ -688,7 +689,7 @@ static int og_cmd_run_post(json_t *element, struct og_msg_params *params)
if (!og_msg_params_validate(params, OG_REST_PARAM_ADDR |
OG_REST_PARAM_RUN_CMD |
OG_REST_PARAM_ECHO))
OG_REST_PARAM_INLINE))
return -1;
clients = json_copy(element);