source: ogServer-Git/src/dbi.h @ 8015f85

Last change on this file since 8015f85 was d8b78bb, checked in by OpenGnSys Support Team <soporte-og@…>, 4 years ago

#942 Extend GET /images function

This extension removes replaces the field 'filename' for 'name' and adds
new fields (software_id, type and id). These new fields are useful when
restoring an image.

Request:
GET /images

Response:
200 OK
{

"disk": {

"free": 37091418112,
"total": 52573995008

},
"images": [

{

"datasize": 5939200000,
"id": 25,
"modified": "Wed Oct 14 11:49:00 2020",
"name": "archlinux",
"permissions": "744",
"size": 1844222333,
"software_id": 19,
"type": 1

}

]

}

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[2629906]1#ifndef __OG_DBI
2#define __OG_DBI
3
4#include <dbi/dbi.h>
[cbd9421]5#include <stdbool.h>
[d2f20d0]6#include <sys/stat.h>
[2629906]7
8struct og_dbi_config {
9        const char      *user;
[fe1ce97]10        const char      *pass;
11        const char      *ip;
[0631b0e]12        const char      *port;
[fe1ce97]13        const char      *name;
[2629906]14};
15
16struct og_dbi {
17        dbi_conn        conn;
18        dbi_inst        inst;
19};
20
21struct og_dbi *og_dbi_open(struct og_dbi_config *config);
22void og_dbi_close(struct og_dbi *db);
23
[9c8e5c7]24#define OG_DB_COMPUTER_NAME_MAXLEN      100
[3d253e6]25#define OG_DB_CENTER_NAME_MAXLEN        100
26#define OG_DB_ROOM_NAME_MAXLEN          100
[f537daf]27#define OG_DB_SERIAL_NUMBER_MAXLEN      25
[d2f20d0]28#define OG_DB_IMAGE_DESCRIPTION_MAXLEN  250
[04ca20e]29#define OG_DB_IMAGE_NAME_MAXLEN 50
30#define OG_DB_FILESYSTEM_MAXLEN 16
[f537daf]31#define OG_DB_NETDRIVER_MAXLEN  30
32#define OG_DB_NETIFACE_MAXLEN   4
33#define OG_DB_LIVEDIR_MAXLEN    50
[04ca20e]34#define OG_DB_INT8_MAXLEN       8
[f537daf]35#define OG_DB_BOOT_MAXLEN       30
[04ca20e]36#define OG_DB_INT_MAXLEN        11
[f537daf]37#define OG_DB_MAC_MAXLEN        15
[04ca20e]38#define OG_DB_IP_MAXLEN         15
39#define OG_DB_SMALLINT_MAXLEN   6
40
41struct og_image_legacy {
42        char software_id[OG_DB_INT_MAXLEN + 1];
43        char image_id[OG_DB_INT_MAXLEN + 1];
44        char name[OG_DB_IMAGE_NAME_MAXLEN + 1];
45        char repo[OG_DB_IP_MAXLEN + 1];
46        char part[OG_DB_SMALLINT_MAXLEN + 1];
47        char disk[OG_DB_SMALLINT_MAXLEN + 1];
48        char code[OG_DB_INT8_MAXLEN + 1];
49};
50
[d2f20d0]51struct og_image {
52        char name[OG_DB_IMAGE_NAME_MAXLEN + 1];
53        char description[OG_DB_IMAGE_DESCRIPTION_MAXLEN + 1];
[d8b78bb]54        uint64_t software_id;
[d2f20d0]55        uint64_t center_id;
56        uint64_t datasize;
57        uint64_t group_id;
[d8b78bb]58        uint64_t type;
59        uint64_t id;
[d2f20d0]60        struct stat image_stats;
61};
62
[04ca20e]63struct og_legacy_partition {
64        char partition[OG_DB_SMALLINT_MAXLEN + 1];
65        char code[OG_DB_INT8_MAXLEN + 1];
66        char size[OG_DB_INT_MAXLEN + 1];
67        char filesystem[OG_DB_FILESYSTEM_MAXLEN + 1];
68        char format[2]; /* Format is a boolean 0 or 1 => length is 2 */
69};
70
[3cb98c7]71struct og_computer {
[cbd9421]72        unsigned int    procedure_id;
73        unsigned int    hardware_id;
74        unsigned int    repo_id;
[3cb98c7]75        unsigned int    center;
76        unsigned int    room;
[cbd9421]77        unsigned int    id;
78        bool            maintenance;
79        bool            remote;
[f537daf]80        char            serial_number[OG_DB_SERIAL_NUMBER_MAXLEN + 1];
81        char            netdriver[OG_DB_NETDRIVER_MAXLEN + 1];
82        char            name[OG_DB_COMPUTER_NAME_MAXLEN + 1];
83        char            netiface[OG_DB_NETIFACE_MAXLEN + 1];
84        char            livedir[OG_DB_LIVEDIR_MAXLEN + 1];
85        char            netmask[OG_DB_IP_MAXLEN + 1];
86        char            boot[OG_DB_BOOT_MAXLEN + 1];
87        char            mac[OG_DB_MAC_MAXLEN + 1];
88        char            ip[OG_DB_IP_MAXLEN + 1];
[3cb98c7]89};
90
91struct in_addr;
[d7e2022]92int og_dbi_get_computer_info(struct og_dbi *dbi, struct og_computer *computer,
93                             struct in_addr addr);
[d2f20d0]94int og_dbi_add_image(struct og_dbi *dbi, const struct og_image *image);
[3cb98c7]95
[2629906]96#endif
Note: See TracBrowser for help on using the repository browser.