From e3a73a504f6a63bf1a716131cf9dea75dc7b0b41 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Fri, 6 Sep 2024 12:25:01 +0200 Subject: rest: add GET /efi Add GET /efi request to obtain information about the client's boot entries. Field inside the /refresh payload 'efi': { 'entries': [ { "order": 0, "name": "Boot0000", "active": false, "description": "grub" }, { "order": 1, "name": "Boot0001", "active": true, "description": "UEFI: PXE IP4 Realtek PCIe GBE Family Controller" } ] } If the client is not a EFI system it won't add the 'efi' field. If an entry is not in the boot order it won't have the 'order' field. GET /efi resquest payload structure: { 'clients': ['10.141.10.21', '10.141.10.22'] } GET /efi response's structure: { 'clients': [ { 'ip': '10.141.10.21', 'entries': [ { "order": 0, "name": "Boot0000", "active": false, "description": "grub" }, { "order": 1, "name": "Boot0001", "active": true, "description": "UEFI: PXE IP4 Realtek PCIe GBE Family Controller" } ] }, { 'ip': '10.141.10.22', 'entries': [] } ] } The client with ip 10.141.10.22 is a BIOS system. If an entry does not appear in the boot order it won't have the 'order' field. --- src/schema.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/schema.c') diff --git a/src/schema.c b/src/schema.c index 182f992..fd1d573 100644 --- a/src/schema.c +++ b/src/schema.c @@ -398,6 +398,42 @@ static int og_dbi_schema_v9(struct og_dbi *dbi) return 0; } +static int og_dbi_schema_v10(struct og_dbi *dbi) +{ + const char *msglog; + dbi_result result; + + syslog(LOG_DEBUG, "Creating table boot_entries\n"); + result = dbi_conn_query(dbi->conn, "CREATE TABLE `boot_entries` (" + "`id` BIGINT NOT NULL AUTO_INCREMENT," + "`client_id` INT NOT NULL," + "`name` VARCHAR(255)," + "`active` BOOLEAN," + "`description` TEXT," + "`entry_order` INT," + "PRIMARY KEY (`id`)," + "FOREIGN KEY (`client_id`) REFERENCES `ordenadores` (`idordenador`) ON DELETE CASCADE" + ")"); + if (!result) { + dbi_conn_error(dbi->conn, &msglog); + syslog(LOG_INFO, "Error when creating boot_entries (%s:%d) %s\n", + __func__, __LINE__, msglog); + return -1; + } + dbi_result_free(result); + + result = dbi_conn_query(dbi->conn, "UPDATE version SET version = 10"); + if (!result) { + dbi_conn_error(dbi->conn, &msglog); + syslog(LOG_INFO, "Could not update version row (%s:%d) %s\n", + __func__, __LINE__, msglog); + return -1; + } + dbi_result_free(result); + + return 0; +} + static struct og_schema_version { int version; int (*update)(struct og_dbi *dbi); @@ -411,6 +447,7 @@ static struct og_schema_version { { .version = 7, .update = og_dbi_schema_v7, }, { .version = 8, .update = og_dbi_schema_v8, }, { .version = 9, .update = og_dbi_schema_v9, }, + { .version = 10, .update = og_dbi_schema_v10,}, { 0, NULL }, }; -- cgit v1.2.3-18-g5258