summaryrefslogtreecommitdiffstats
path: root/src/dbi.h
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2020-10-13 14:46:28 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2020-10-14 12:05:25 +0200
commitd2f20d0be06617f421eecca111449d94672695eb (patch)
tree6547ad52f265f89158553d26bc9e7eac9ed72518 /src/dbi.h
parent24c8b940e614fa795b679628be2e6c0d68bd41e5 (diff)
#942 Create DB image when calling POST /image/create
In case the DB entry for an image does not exist when POST /image/create is called, this patch takes care of calling it. This adds few optional json parameters to the POST /image/create API. If optional parameters are included then this patch creates the DB entry, otherwise it just creates the actual image and updates the existing entry. Request: POST /image/create { "clients":["192.168.56.11"], "disk":"1", "partition":"1", "name":"archlinux", "repository":"192.168.56.10", "id":"24", "code":"131", "description":"This is a test", "group_id":0, "center_id":1 } Response: 200 OK
Diffstat (limited to 'src/dbi.h')
-rw-r--r--src/dbi.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/dbi.h b/src/dbi.h
index 7bfe311..8cd6fe6 100644
--- a/src/dbi.h
+++ b/src/dbi.h
@@ -3,6 +3,7 @@
#include <dbi/dbi.h>
#include <stdbool.h>
+#include <sys/stat.h>
struct og_dbi_config {
const char *user;
@@ -24,6 +25,7 @@ void og_dbi_close(struct og_dbi *db);
#define OG_DB_CENTER_NAME_MAXLEN 100
#define OG_DB_ROOM_NAME_MAXLEN 100
#define OG_DB_SERIAL_NUMBER_MAXLEN 25
+#define OG_DB_IMAGE_DESCRIPTION_MAXLEN 250
#define OG_DB_IMAGE_NAME_MAXLEN 50
#define OG_DB_FILESYSTEM_MAXLEN 16
#define OG_DB_NETDRIVER_MAXLEN 30
@@ -46,6 +48,16 @@ struct og_image_legacy {
char code[OG_DB_INT8_MAXLEN + 1];
};
+struct og_image {
+ char name[OG_DB_IMAGE_NAME_MAXLEN + 1];
+ char description[OG_DB_IMAGE_DESCRIPTION_MAXLEN + 1];
+ const char *filename;
+ uint64_t center_id;
+ uint64_t datasize;
+ uint64_t group_id;
+ struct stat image_stats;
+};
+
struct og_legacy_partition {
char partition[OG_DB_SMALLINT_MAXLEN + 1];
char code[OG_DB_INT8_MAXLEN + 1];
@@ -77,5 +89,6 @@ struct og_computer {
struct in_addr;
int og_dbi_get_computer_info(struct og_dbi *dbi, struct og_computer *computer,
struct in_addr addr);
+int og_dbi_add_image(struct og_dbi *dbi, const struct og_image *image);
#endif