summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2023-12-20 13:33:23 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2023-12-21 12:18:40 +0100
commita7727e40eaf30393b3fde4e2bd0a7224b0ba8f83 (patch)
treecc891651fbebdb804e453024186f3a938b9173cd /src
parent3b3fc329993e110a2da89bec5a1cdbf064092fd1 (diff)
rest: allow to set boot mode in client/update
Allow to specify .boot field and call set_client_mode() to update the boot mode.
Diffstat (limited to 'src')
-rw-r--r--src/rest.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/rest.c b/src/rest.c
index 658a398..8bde175 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -1777,6 +1777,10 @@ static int og_cmd_post_client_update(json_t *element,
err = og_json_parse_string_copy(value,
computer.name,
sizeof(computer.name));
+ } else if (!strcmp(key, "boot")) {
+ err = og_json_parse_string_copy(value,
+ computer.boot,
+ sizeof(computer.boot));
} else if (!strcmp(key, "mac")) {
err = og_json_parse_string_copy(value,
computer.mac,
@@ -1824,14 +1828,16 @@ static int og_cmd_post_client_update(json_t *element,
" inremotepc=%u,"
" idaula=%u,"
" nombreordenador='%s',"
- " mac='%s'"
+ " mac='%s',"
+ " arranque='%s'"
" WHERE ip='%s';",
computer.serial_number,
computer.netdriver, computer.maintenance,
computer.netiface, computer.repo_id,
computer.netmask, computer.remote,
computer.room, computer.name,
- computer.mac, computer.ip);
+ computer.mac, computer.boot,
+ computer.ip);
if (!result) {
dbi_conn_error(dbi->conn, &msglog);
syslog(LOG_ERR, "failed to update client in database (%s:%d) %s\n",
@@ -1841,6 +1847,14 @@ static int og_cmd_post_client_update(json_t *element,
}
dbi_result_free(result);
+
+ if (og_set_client_mode(dbi, computer.mac, computer.boot)) {
+ syslog(LOG_ERR, "failed to set client boot mode (%s:%d)\n",
+ __func__, __LINE__);
+ og_dbi_close(dbi);
+ return -1;
+ }
+
og_dbi_close(dbi);
return 0;
}