source: ogServer-Git/src/json.h @ 141b079

Last change on this file since 141b079 was 141b079, checked in by OpenGnSys Support Team <soporte-og@…>, 3 years ago

#915 Add schedule/command

Enables ogserver to schedule commands (also referred as actions in
legacy web console jargon).

This feature enables ogserver to write in the "acciones" table in order
to have full capabilities for command scheduling purposes, thus not
depending in the legacy web console to insert into "acciones" table.

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