summaryrefslogtreecommitdiffstats
path: root/src/client.c
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-08-21 20:19:23 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-08-21 21:58:48 +0200
commit5eba9f4e1b44fb0d4b4962c2241fe9391e202d7b (patch)
tree1940f98fcf9d24b1046e425b77eddc5bab624ee4 /src/client.c
parent4e0f9aac9e2883a992469f5b2b231ecb14b30183 (diff)
rest: allow repository to have more than one IP address
Repository can have more than one single IP address. * Add alias field to database to represent the extra IPs that are attached to the repository, update schema and add version 9. * Use og_dbi_get_repository_ip() to infer the repository IP address. * Add helper functions (src/repo.c) to build a list of repositories and update rest API to use it.
Diffstat (limited to 'src/client.c')
-rw-r--r--src/client.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/client.c b/src/client.c
index d5e0391..675be74 100644
--- a/src/client.c
+++ b/src/client.c
@@ -621,15 +621,15 @@ static bool og_dbi_update_image(struct og_dbi *dbi,
const struct og_image_legacy *img_info,
const char *computer_id)
{
+ int repo_id, sw_id, repo_alias;
const char *msglog;
dbi_result result;
- int repo_id, sw_id;
uint32_t revision;
/* find repository identifier by repository ip and computer ID. */
result = dbi_conn_queryf(dbi->conn,
- "SELECT repositorios.idrepositorio"
- " FROM repositorios"
+ "SELECT repositorios.idrepositorio, repositorios.alias"
+ " FROM repositorios"
" LEFT JOIN ordenadores USING (idrepositorio)"
" WHERE repositorios.ip='%s' AND ordenadores.idordenador=%s",
img_info->repo, computer_id);
@@ -646,7 +646,12 @@ static bool og_dbi_update_image(struct og_dbi *dbi,
dbi_result_free(result);
return false;
}
- repo_id = dbi_result_get_uint(result, "idrepositorio");
+ repo_alias = dbi_result_get_uint(result, "alias");
+ if (repo_alias)
+ repo_id = repo_alias;
+ else
+ repo_id = dbi_result_get_uint(result, "idrepositorio");
+
dbi_result_free(result);
/* find software id by computer ID, disk number and partition. */