source: ogServer-Git/src/json.h @ a67f27a

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

#1004 Handle new fields in /image/create response

ogClient now includes more information regarding the new image. This patch
modifies ogServer to support new elements sent in ogClient /image/create
response and store them in the database.

Example of new /image/create response:

{

"disk": "1",
"partition": "1",
"code": "131",
"id": "1",
"name": "ubuntu",
"repository": "192.168.56.10",
"software": "Ubuntu 18.04.5 LTS \naccountsservice 0.6.45\n...",
"clonator": "PARTCLONE",
"compressor": "LZOP",
"filesystem": "EXTFS",
"datasize": 2100000

}

New fields are "clonator", "compressor", "filesystem" and "datasize".

  • Property mode set to 100644
File size: 2.1 KB
Line 
1#ifndef _OG_JSON_H
2#define _OG_JSON_H
3
4#include <jansson.h>
5#include "schedule.h"
6
7int og_json_parse_string(json_t *element, const char **str);
8int og_json_parse_uint64(json_t *element, uint64_t *integer);
9int og_json_parse_uint(json_t *element, uint32_t *integer);
10int og_json_parse_bool(json_t *element, bool *value);
11
12#define OG_PARAM_PART_NUMBER                    (1UL << 0)
13#define OG_PARAM_PART_CODE                      (1UL << 1)
14#define OG_PARAM_PART_FILESYSTEM                (1UL << 2)
15#define OG_PARAM_PART_SIZE                      (1UL << 3)
16#define OG_PARAM_PART_FORMAT                    (1UL << 4)
17#define OG_PARAM_PART_DISK                      (1UL << 5)
18#define OG_PARAM_PART_OS                        (1UL << 6)
19#define OG_PARAM_PART_USED_SIZE                 (1UL << 7)
20
21struct og_partition {
22        const char      *disk;
23        const char      *number;
24        const char      *code;
25        const char      *size;
26        const char      *filesystem;
27        const char      *format;
28        const char      *os;
29        const char      *used_size;
30};
31
32#define OG_PARTITION_MAX        4
33
34int og_json_parse_partition(json_t *element, struct og_partition *part,
35                            uint64_t required_flags);
36
37#define OG_CLIENTS_MAX  4096
38
39struct og_sync_params {
40        const char      *sync;
41        const char      *diff;
42        const char      *remove;
43        const char      *compress;
44        const char      *cleanup;
45        const char      *cache;
46        const char      *cleanup_cache;
47        const char      *remove_dst;
48        const char      *diff_id;
49        const char      *diff_name;
50        const char      *path;
51        const char      *method;
52};
53
54#define OG_PARAM_SCOPE_ID       (1UL << 0)
55#define OG_PARAM_SCOPE_TYPE     (1UL << 1)
56
57struct og_scope {
58        uint32_t        id;
59        const char      *type;
60};
61
62int og_json_parse_scope(json_t *element, struct og_scope *scope,
63                        const uint64_t required_flags);
64
65struct og_msg_params {
66        const char      *ips_array[OG_CLIENTS_MAX];
67        const char      *mac_array[OG_CLIENTS_MAX];
68        const char      *netmask_array[OG_CLIENTS_MAX];
69        unsigned int    ips_array_len;
70        const char      *wol_type;
71        char            run_cmd[4096];
72        const char      *disk;
73        const char      *partition;
74        const char      *repository;
75        const char      *name;
76        const char      *id;
77        const char      *code;
78        const char      *type;
79        const char      *profile;
80        const char      *cache;
81        const char      *cache_size;
82        bool            echo;
83        struct og_partition     partition_setup[OG_PARTITION_MAX];
84        struct og_sync_params sync_setup;
85        struct og_schedule_time time;
86        const char      *task_id;
87        uint64_t        flags;
88};
89
90#endif
Note: See TracBrowser for help on using the repository browser.