1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
#ifndef _OG_JSON_H
#define _OG_JSON_H
#include <jansson.h>
#include <stdint.h>
#include <stdbool.h>
#include "list.h"
#include "dbi.h"
int og_json_parse_string(const json_t *element, const char **str);
int og_json_parse_string_copy(const json_t *element, char *str, size_t size);
int og_json_parse_uint64(const json_t *element, uint64_t *integer);
int og_json_parse_uint(const json_t *element, uint32_t *integer);
int og_json_parse_bool(const json_t *element, bool *value);
#define OG_PARAM_PART_NUMBER (1UL << 0)
#define OG_PARAM_PART_CODE (1UL << 1)
#define OG_PARAM_PART_FILESYSTEM (1UL << 2)
#define OG_PARAM_PART_SIZE (1UL << 3)
#define OG_PARAM_PART_FORMAT (1UL << 4)
#define OG_PARAM_PART_DISK (1UL << 5)
#define OG_PARAM_PART_OS (1UL << 6)
#define OG_PARAM_PART_USED_SIZE (1UL << 7)
#define OG_PARAM_PART_DISK_TYPE (1UL << 8)
#define OG_PARAM_PART_FREE_SIZE (1UL << 9)
struct og_partition {
const char *disk;
const char *disk_type;
const char *number;
const char *code;
const char *size;
const char *filesystem;
const char *format;
const char *os;
uint64_t used_size;
uint64_t free_size;
};
#define OG_DISK_MAX 4
#define OG_PARTITION_MAX (4 * OG_DISK_MAX)
int og_json_parse_partition(json_t *element, struct og_partition *part,
uint64_t required_flags);
#define OG_CLIENTS_MAX 4096
#define OG_PARAM_SCOPE_ID (1UL << 0)
#define OG_PARAM_SCOPE_TYPE (1UL << 1)
struct og_scope {
uint32_t id;
const char *type;
};
int og_json_parse_scope(json_t *element, struct og_scope *scope,
const uint64_t required_flags);
struct og_msg_params {
const char *ips_array[OG_CLIENTS_MAX];
const char *mac_array[OG_CLIENTS_MAX];
const char *netmask_array[OG_CLIENTS_MAX];
unsigned int ips_array_len;
const char *wol_type;
char run_cmd[4096];
const char *disk;
const char *partition;
const char *repository;
const char *name;
const char *id;
const char *code;
const char *type;
const char *profile;
const char *cache;
const char *cache_size;
const char *comment;
bool echo;
struct og_partition partition_setup[OG_PARTITION_MAX];
struct og_image image;
uint64_t flags;
bool backup;
};
int og_json_parse_partition_setup(json_t *element, struct og_msg_params *params);
int og_json_parse_create_image(json_t *element, struct og_msg_params *params);
int og_json_parse_restore_image(json_t *element, struct og_msg_params *params);
struct og_cmd_json {
const char *type;
json_t *json;
uint32_t flags;
};
enum og_procedure_step_type {
OG_STEP_COMMAND = 0,
OG_STEP_PROCEDURE,
OG_STEP_TASK,
};
#define OG_PROCEDURE_STEPS_MAX 256
struct og_procedure_step {
enum og_procedure_step_type type;
uint32_t position;
union {
struct og_cmd_json cmd;
struct {
uint64_t id;
} procedure;
};
};
struct og_procedure {
uint64_t id;
struct og_procedure_step steps[OG_PROCEDURE_STEPS_MAX];
uint32_t num_steps;
};
int og_json_parse_procedure(json_t *element, struct og_procedure *proc);
#define OG_PARAM_IMG_NAME (1UL << 0)
#define OG_PARAM_IMG_SIZE (1UL << 1)
#define OG_PARAM_IMG_CHECKSUM (1UL << 2)
struct og_cache_image {
struct list_head list;
const char *name;
uint64_t size;
const char *checksum;
};
#define OG_PARAM_CACHE_USED_SIZE (1UL << 0)
#define OG_PARAM_CACHE_FREE_SIZE (1UL << 1)
#define OG_PARAM_CACHE_IMAGES (1UL << 2)
struct og_cache_data {
uint64_t used_size;
uint64_t free_size;
struct list_head image_list;
};
void og_cache_data_init(struct og_cache_data *cache_data);
void og_cache_data_free(struct og_cache_data *cache_data);
int og_json_parse_cache(json_t *element, struct og_cache_data *cache_data);
#define OG_PARAM_EFI_ENTRIES (1UL << 0)
#define OG_PARAM_EFI_ORDER (1UL << 1)
#define OG_PARAM_EFI_NAME (1UL << 2)
#define OG_PARAM_EFI_DESCRIPTION (1UL << 3)
#define OG_PARAM_EFI_ACTIVE (1UL << 4)
struct og_boot_entry {
const char *description;
const char *name;
bool active;
uint64_t order;
struct list_head list;
};
void og_boot_entry_free(struct list_head *boot_entry_list);
int og_json_parse_efi(json_t *element, struct list_head *boot_entry_list);
#endif
|