summaryrefslogtreecommitdiffstats
path: root/src/rest.c
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2023-07-06 18:23:56 +0200
committerJose M. Guisado <jguisado@soleta.eu>2023-07-07 10:04:36 +0200
commit74b6e3ec7275164e2ecbf6f98b24357b2a9bb174 (patch)
tree3ba80fea6b671faec97172d345f9c9057f4b74bb /src/rest.c
parent3de8c25e4ee30d3d917d9b6c6956ccedeee29245 (diff)
rest: add optional param "backup" for create_imagev1.2.3
This parameter is used by ogServer to instruct target client if image backup should be performed before image creation. This parameter is optional to preserve backward compatibility with webconsole (legacy web client) and avoid the need of updating any legacy client. Default is true if the REST request is missing this parameter.
Diffstat (limited to 'src/rest.c')
-rw-r--r--src/rest.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/rest.c b/src/rest.c
index ff51332..da75f26 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -79,6 +79,7 @@ struct ev_loop *og_loop;
#define OG_REST_PARAM_SCOPE (1UL << 41)
#define OG_REST_PARAM_MODE (1UL << 42)
#define OG_REST_PARAM_CENTER (1UL << 43)
+#define OG_REST_PARAM_BACKUP (1UL << 44)
static LIST_HEAD(client_list);
static LIST_HEAD(client_wol_list);
@@ -2187,12 +2188,18 @@ int og_json_parse_create_image(json_t *element,
err = og_json_parse_uint64(value, &params->image.group_id);
} else if (!strcmp(key, "center_id")) {
err = og_json_parse_uint64(value, &params->image.center_id);
+ } else if (!strcmp(key, "backup")) {
+ err = og_json_parse_bool(value, &params->backup);
+ params->flags |= OG_REST_PARAM_BACKUP;
}
if (err < 0)
return err;
}
+ if (!og_msg_params_validate(params, OG_REST_PARAM_BACKUP))
+ params->backup = true;
+
return 0;
}
@@ -2252,6 +2259,7 @@ static int og_cmd_create_image(json_t *element, struct og_msg_params *params)
return err;
json_object_set_new(clients ,"repository", json_string(repository_ip));
+ json_object_set_new(clients ,"backup", json_boolean(params->backup));
return og_send_request(OG_METHOD_POST, OG_CMD_IMAGE_CREATE, params,
clients);