source: ogServer-Git/src/client.c @ ff71a2a

Last change on this file since ff71a2a 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: 17.9 KB
Line 
1/*
2 * Copyright (C) 2020 Soleta Networks <info@soleta.eu>
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Affero General Public License as published by the
6 * Free Software Foundation, version 3.
7 */
8
9#include "ogAdmServer.h"
10#include "dbi.h"
11#include "utils.h"
12#include "list.h"
13#include "rest.h"
14#include "json.h"
15#include "schedule.h"
16#include <syslog.h>
17#include <sys/ioctl.h>
18#include <ifaddrs.h>
19#include <sys/types.h>
20#include <sys/stat.h>
21#include <fcntl.h>
22#include <jansson.h>
23#include <time.h>
24
25struct og_computer {
26        unsigned int    id;
27        unsigned int    center;
28        unsigned int    room;
29        char            name[OG_DB_COMPUTER_NAME_MAXLEN + 1];
30        unsigned int    procedure_id;
31};
32
33static int og_dbi_get_computer_info(struct og_computer *computer,
34                                    struct in_addr addr)
35{
36        const char *msglog;
37        struct og_dbi *dbi;
38        dbi_result result;
39
40        dbi = og_dbi_open(&dbi_config);
41        if (!dbi) {
42                syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
43                       __func__, __LINE__);
44                return -1;
45        }
46        result = dbi_conn_queryf(dbi->conn,
47                                 "SELECT ordenadores.idordenador,"
48                                 "       ordenadores.nombreordenador,"
49                                 "       ordenadores.idaula,"
50                                 "       ordenadores.idproautoexec,"
51                                 "       centros.idcentro FROM ordenadores "
52                                 "INNER JOIN aulas ON aulas.idaula=ordenadores.idaula "
53                                 "INNER JOIN centros ON centros.idcentro=aulas.idcentro "
54                                 "WHERE ordenadores.ip='%s'", inet_ntoa(addr));
55        if (!result) {
56                dbi_conn_error(dbi->conn, &msglog);
57                syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
58                       __func__, __LINE__, msglog);
59                og_dbi_close(dbi);
60                return -1;
61        }
62        if (!dbi_result_next_row(result)) {
63                syslog(LOG_ERR, "client does not exist in database (%s:%d)\n",
64                       __func__, __LINE__);
65                dbi_result_free(result);
66                og_dbi_close(dbi);
67                return -1;
68        }
69
70        computer->id = dbi_result_get_uint(result, "idordenador");
71        computer->center = dbi_result_get_uint(result, "idcentro");
72        computer->room = dbi_result_get_uint(result, "idaula");
73        computer->procedure_id = dbi_result_get_uint(result, "idproautoexec");
74        strncpy(computer->name,
75                dbi_result_get_string(result, "nombreordenador"),
76                OG_DB_COMPUTER_NAME_MAXLEN);
77
78        dbi_result_free(result);
79        og_dbi_close(dbi);
80
81        return 0;
82}
83
84static int og_resp_probe(struct og_client *cli, json_t *data)
85{
86        const char *status = NULL;
87        const char *key;
88        json_t *value;
89        int err = 0;
90
91        if (json_typeof(data) != JSON_OBJECT)
92                return -1;
93
94        json_object_foreach(data, key, value) {
95                if (!strcmp(key, "status")) {
96                        err = og_json_parse_string(value, &status);
97                        if (err < 0)
98                                return err;
99                } else {
100                        return -1;
101                }
102        }
103
104        if (!strcmp(status, "BSY"))
105                cli->status = OG_CLIENT_STATUS_BUSY;
106        else if (!strcmp(status, "OPG"))
107                cli->status = OG_CLIENT_STATUS_OGLIVE;
108        else if (!strcmp(status, "VDI"))
109                cli->status = OG_CLIENT_STATUS_VIRTUAL;
110
111        return status ? 0 : -1;
112}
113
114static int og_resp_shell_run(struct og_client *cli, json_t *data)
115{
116        const char *output = NULL;
117        char filename[4096];
118        const char *key;
119        json_t *value;
120        int err = -1;
121        FILE *file;
122
123        if (json_typeof(data) != JSON_OBJECT)
124                return -1;
125
126        json_object_foreach(data, key, value) {
127                if (!strcmp(key, "out")) {
128                        err = og_json_parse_string(value, &output);
129                        if (err < 0)
130                                return err;
131                } else {
132                        return -1;
133                }
134        }
135
136        if (!output) {
137                syslog(LOG_ERR, "%s:%d: malformed json response\n",
138                       __FILE__, __LINE__);
139                return -1;
140        }
141
142        sprintf(filename, "/tmp/_Seconsola_%s", inet_ntoa(cli->addr.sin_addr));
143        file = fopen(filename, "wt");
144        if (!file) {
145                syslog(LOG_ERR, "cannot open file %s: %s\n",
146                       filename, strerror(errno));
147                return -1;
148        }
149
150        fprintf(file, "%s", output);
151        fclose(file);
152
153        return 0;
154}
155
156struct og_computer_legacy  {
157        char center[OG_DB_INT_MAXLEN + 1];
158        char id[OG_DB_INT_MAXLEN + 1];
159        char hardware[8192];
160};
161
162static int og_resp_hardware(json_t *data, struct og_client *cli)
163{
164        struct og_computer_legacy legacy = {};
165        const char *hardware = NULL;
166        struct og_computer computer;
167        struct og_dbi *dbi;
168        const char *key;
169        json_t *value;
170        int err = 0;
171        bool res;
172
173        if (json_typeof(data) != JSON_OBJECT)
174                return -1;
175
176        json_object_foreach(data, key, value) {
177                if (!strcmp(key, "hardware")) {
178                        err = og_json_parse_string(value, &hardware);
179                        if (err < 0)
180                                return -1;
181                } else {
182                        return -1;
183                }
184        }
185
186        if (!hardware) {
187                syslog(LOG_ERR, "malformed response json\n");
188                return -1;
189        }
190
191        err = og_dbi_get_computer_info(&computer, cli->addr.sin_addr);
192        if (err < 0)
193                return -1;
194
195        snprintf(legacy.center, sizeof(legacy.center), "%d", computer.center);
196        snprintf(legacy.id, sizeof(legacy.id), "%d", computer.id);
197        snprintf(legacy.hardware, sizeof(legacy.hardware), "%s", hardware);
198
199        dbi = og_dbi_open(&dbi_config);
200        if (!dbi) {
201                syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
202                       __func__, __LINE__);
203                return -1;
204        }
205
206        res = actualizaHardware(dbi, legacy.hardware, legacy.id, computer.name,
207                                legacy.center);
208        og_dbi_close(dbi);
209
210        if (!res) {
211                syslog(LOG_ERR, "Problem updating client configuration\n");
212                return -1;
213        }
214
215        return 0;
216}
217
218struct og_software_legacy {
219        char software[8192];
220        char center[OG_DB_INT_MAXLEN + 1];
221        char part[OG_DB_SMALLINT_MAXLEN + 1];
222        char id[OG_DB_INT_MAXLEN + 1];
223};
224
225static int og_resp_software(json_t *data, struct og_client *cli)
226{
227        struct og_software_legacy legacy = {};
228        const char *partition = NULL;
229        const char *software = NULL;
230        struct og_computer computer;
231        struct og_dbi *dbi;
232        const char *key;
233        json_t *value;
234        int err = 0;
235        bool res;
236
237        if (json_typeof(data) != JSON_OBJECT)
238                return -1;
239
240        json_object_foreach(data, key, value) {
241                if (!strcmp(key, "software"))
242                        err = og_json_parse_string(value, &software);
243                else if (!strcmp(key, "partition"))
244                        err = og_json_parse_string(value, &partition);
245                else
246                        return -1;
247
248                if (err < 0)
249                        return -1;
250        }
251
252        if (!software || !partition) {
253                syslog(LOG_ERR, "malformed response json\n");
254                return -1;
255        }
256
257        err = og_dbi_get_computer_info(&computer, cli->addr.sin_addr);
258        if (err < 0)
259                return -1;
260
261        snprintf(legacy.software, sizeof(legacy.software), "%s", software);
262        snprintf(legacy.part, sizeof(legacy.part), "%s", partition);
263        snprintf(legacy.id, sizeof(legacy.id), "%d", computer.id);
264        snprintf(legacy.center, sizeof(legacy.center), "%d", computer.center);
265
266        dbi = og_dbi_open(&dbi_config);
267        if (!dbi) {
268                syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
269                       __func__, __LINE__);
270                return -1;
271        }
272
273        res = actualizaSoftware(dbi, legacy.software, legacy.part, legacy.id,
274                                computer.name, legacy.center);
275        og_dbi_close(dbi);
276
277        if (!res) {
278                syslog(LOG_ERR, "Problem updating client configuration\n");
279                return -1;
280        }
281
282        return 0;
283}
284
285#define OG_PARAMS_RESP_REFRESH  (OG_PARAM_PART_DISK |           \
286                                 OG_PARAM_PART_NUMBER |         \
287                                 OG_PARAM_PART_CODE |           \
288                                 OG_PARAM_PART_FILESYSTEM |     \
289                                 OG_PARAM_PART_OS |             \
290                                 OG_PARAM_PART_SIZE |           \
291                                 OG_PARAM_PART_USED_SIZE)
292
293static int og_json_parse_partition_array(json_t *value,
294                                         struct og_partition *partitions)
295{
296        json_t *element;
297        int i, err;
298
299        if (json_typeof(value) != JSON_ARRAY)
300                return -1;
301
302        for (i = 0; i < json_array_size(value) && i < OG_PARTITION_MAX; i++) {
303                element = json_array_get(value, i);
304
305                err = og_json_parse_partition(element, &partitions[i],
306                                              OG_PARAMS_RESP_REFRESH);
307                if (err < 0)
308                        return err;
309        }
310
311        return 0;
312}
313
314static int og_dbi_queue_autorun(uint32_t computer_id, uint32_t proc_id)
315{
316        struct og_task dummy_task = {
317                .scope          = computer_id,
318                .type_scope     = AMBITO_ORDENADORES,
319                .procedure_id   = proc_id,
320        };
321        struct og_dbi *dbi;
322
323        dbi = og_dbi_open(&dbi_config);
324        if (!dbi) {
325                syslog(LOG_ERR, "cannot open connection database "
326                                "(%s:%d)\n", __func__, __LINE__);
327                return -1;
328        }
329        if (og_dbi_queue_procedure(dbi, &dummy_task)) {
330                og_dbi_close(dbi);
331                return -1;
332        }
333        og_dbi_close(dbi);
334
335        return 0;
336}
337
338static int og_resp_refresh(json_t *data, struct og_client *cli)
339{
340        struct og_partition partitions[OG_PARTITION_MAX] = {};
341        const char *serial_number = NULL;
342        struct og_computer computer = {};
343        struct og_partition disk_setup;
344        char cfg[1024] = {};
345        struct og_dbi *dbi;
346        const char *key;
347        unsigned int i;
348        json_t *value;
349        int err = 0;
350        bool res;
351
352        if (json_typeof(data) != JSON_OBJECT)
353                return -1;
354
355        json_object_foreach(data, key, value) {
356                if (!strcmp(key, "disk_setup")) {
357                        err = og_json_parse_partition(value,
358                                                      &disk_setup,
359                                                      OG_PARAMS_RESP_REFRESH);
360                } else if (!strcmp(key, "partition_setup")) {
361                        err = og_json_parse_partition_array(value, partitions);
362                } else if (!strcmp(key, "serial_number")) {
363                        err = og_json_parse_string(value, &serial_number);
364                } else {
365                        return -1;
366                }
367
368                if (err < 0)
369                        return err;
370        }
371
372        err = og_dbi_get_computer_info(&computer, cli->addr.sin_addr);
373        if (err < 0)
374                return -1;
375
376        if (strlen(serial_number) > 0)
377                snprintf(cfg, sizeof(cfg), "ser=%s\n", serial_number);
378
379        if (!disk_setup.disk || !disk_setup.number || !disk_setup.code ||
380            !disk_setup.filesystem || !disk_setup.os || !disk_setup.size ||
381            !disk_setup.used_size)
382                return -1;
383
384        snprintf(cfg + strlen(cfg), sizeof(cfg) - strlen(cfg),
385                 "disk=%s\tpar=%s\tcpt=%s\tfsi=%s\tsoi=%s\ttam=%s\tuso=%s\n",
386                 disk_setup.disk, disk_setup.number, disk_setup.code,
387                 disk_setup.filesystem, disk_setup.os, disk_setup.size,
388                 disk_setup.used_size);
389
390        for (i = 0; i < OG_PARTITION_MAX; i++) {
391                if (!partitions[i].disk || !partitions[i].number ||
392                    !partitions[i].code || !partitions[i].filesystem ||
393                    !partitions[i].os || !partitions[i].size ||
394                    !partitions[i].used_size)
395                        continue;
396
397                snprintf(cfg + strlen(cfg), sizeof(cfg) - strlen(cfg),
398                         "disk=%s\tpar=%s\tcpt=%s\tfsi=%s\tsoi=%s\ttam=%s\tuso=%s\n",
399                         partitions[i].disk, partitions[i].number,
400                         partitions[i].code, partitions[i].filesystem,
401                         partitions[i].os, partitions[i].size,
402                         partitions[i].used_size);
403        }
404
405        dbi = og_dbi_open(&dbi_config);
406        if (!dbi) {
407                syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
408                                  __func__, __LINE__);
409                return -1;
410        }
411        res = actualizaConfiguracion(dbi, cfg, computer.id);
412        og_dbi_close(dbi);
413
414        if (!res) {
415                syslog(LOG_ERR, "Problem updating client configuration\n");
416                return -1;
417        }
418
419        if (!cli->autorun && computer.procedure_id) {
420                cli->autorun = true;
421
422                if (og_dbi_queue_autorun(computer.id, computer.procedure_id))
423                        return -1;
424        }
425
426        return 0;
427}
428
429static int update_image_info(struct og_dbi *dbi, const char *image_id,
430                             const char *clonator, const char *compressor,
431                             const char *filesystem, const uint64_t datasize)
432{
433        const char *msglog;
434        dbi_result result;
435
436        result = dbi_conn_queryf(dbi->conn,
437                "UPDATE imagenes"
438                "   SET clonator='%s', compressor='%s',"
439                "       filesystem='%s', datasize=%d"
440                " WHERE idimagen=%s", clonator, compressor, filesystem,
441                datasize, image_id);
442
443        if (!result) {
444                dbi_conn_error(dbi->conn, &msglog);
445                syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
446                       __func__, __LINE__, msglog);
447                return -1;
448        }
449        dbi_result_free(result);
450
451        return 0;
452}
453
454static int og_resp_image_create(json_t *data, struct og_client *cli)
455{
456        struct og_software_legacy soft_legacy;
457        struct og_image_legacy img_legacy;
458        const char *compressor = NULL;
459        const char *filesystem = NULL;
460        const char *partition = NULL;
461        const char *software = NULL;
462        const char *image_id = NULL;
463        const char *clonator = NULL;
464        struct og_computer computer;
465        const char *disk = NULL;
466        const char *code = NULL;
467        const char *name = NULL;
468        const char *repo = NULL;
469        uint64_t datasize = 0;
470        struct og_dbi *dbi;
471        const char *key;
472        json_t *value;
473        int err = 0;
474        bool res;
475
476        if (json_typeof(data) != JSON_OBJECT)
477                return -1;
478
479        json_object_foreach(data, key, value) {
480                if (!strcmp(key, "software"))
481                        err = og_json_parse_string(value, &software);
482                else if (!strcmp(key, "partition"))
483                        err = og_json_parse_string(value, &partition);
484                else if (!strcmp(key, "disk"))
485                        err = og_json_parse_string(value, &disk);
486                else if (!strcmp(key, "code"))
487                        err = og_json_parse_string(value, &code);
488                else if (!strcmp(key, "id"))
489                        err = og_json_parse_string(value, &image_id);
490                else if (!strcmp(key, "name"))
491                        err = og_json_parse_string(value, &name);
492                else if (!strcmp(key, "repository"))
493                        err = og_json_parse_string(value, &repo);
494                else if (!strcmp(key, "clonator"))
495                        err = og_json_parse_string(value, &clonator);
496                else if (!strcmp(key, "compressor"))
497                        err = og_json_parse_string(value, &compressor);
498                else if (!strcmp(key, "filesystem"))
499                        err = og_json_parse_string(value, &filesystem);
500                else if (!strcmp(key, "datasize"))
501                        err = og_json_parse_uint64(value, &datasize);
502                else
503                        return -1;
504
505                if (err < 0)
506                        return err;
507        }
508
509        if (!software || !partition || !disk || !code || !image_id || !name ||
510            !repo || !clonator || !compressor || !filesystem || !datasize) {
511                syslog(LOG_ERR, "malformed response json\n");
512                return -1;
513        }
514
515        err = og_dbi_get_computer_info(&computer, cli->addr.sin_addr);
516        if (err < 0)
517                return -1;
518
519        snprintf(soft_legacy.center, sizeof(soft_legacy.center), "%d",
520                 computer.center);
521        snprintf(soft_legacy.software, sizeof(soft_legacy.software), "%s",
522                 software);
523        snprintf(img_legacy.image_id, sizeof(img_legacy.image_id), "%s",
524                 image_id);
525        snprintf(soft_legacy.id, sizeof(soft_legacy.id), "%d", computer.id);
526        snprintf(img_legacy.part, sizeof(img_legacy.part), "%s", partition);
527        snprintf(img_legacy.disk, sizeof(img_legacy.disk), "%s", disk);
528        snprintf(img_legacy.code, sizeof(img_legacy.code), "%s", code);
529        snprintf(img_legacy.name, sizeof(img_legacy.name), "%s", name);
530        snprintf(img_legacy.repo, sizeof(img_legacy.repo), "%s", repo);
531
532        dbi = og_dbi_open(&dbi_config);
533        if (!dbi) {
534                syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
535                       __func__, __LINE__);
536                return -1;
537        }
538
539        res = actualizaSoftware(dbi,
540                                soft_legacy.software,
541                                img_legacy.part,
542                                soft_legacy.id,
543                                computer.name,
544                                soft_legacy.center);
545        if (!res) {
546                og_dbi_close(dbi);
547                syslog(LOG_ERR, "Problem updating client configuration\n");
548                return -1;
549        }
550
551        res = actualizaCreacionImagen(dbi,
552                                      img_legacy.image_id,
553                                      img_legacy.disk,
554                                      img_legacy.part,
555                                      img_legacy.code,
556                                      img_legacy.repo,
557                                      soft_legacy.id);
558        if (!res) {
559                og_dbi_close(dbi);
560                syslog(LOG_ERR, "Problem updating client configuration\n");
561                return -1;
562        }
563
564        res = update_image_info(dbi, image_id, clonator, compressor,
565                                filesystem, datasize);
566        og_dbi_close(dbi);
567
568        if (res) {
569                syslog(LOG_ERR, "Problem updating image info\n");
570                return -1;
571        }
572
573        return 0;
574}
575
576static int og_resp_image_restore(json_t *data, struct og_client *cli)
577{
578        struct og_software_legacy soft_legacy;
579        struct og_image_legacy img_legacy;
580        const char *partition = NULL;
581        const char *image_id = NULL;
582        struct og_computer computer;
583        const char *disk = NULL;
584        dbi_result query_result;
585        struct og_dbi *dbi;
586        const char *key;
587        json_t *value;
588        int err = 0;
589        bool res;
590
591        if (json_typeof(data) != JSON_OBJECT)
592                return -1;
593
594        json_object_foreach(data, key, value) {
595                if (!strcmp(key, "partition"))
596                        err = og_json_parse_string(value, &partition);
597                else if (!strcmp(key, "disk"))
598                        err = og_json_parse_string(value, &disk);
599                else if (!strcmp(key, "image_id"))
600                        err = og_json_parse_string(value, &image_id);
601                else
602                        return -1;
603
604                if (err < 0)
605                        return err;
606        }
607
608        if (!partition || !disk || !image_id) {
609                syslog(LOG_ERR, "malformed response json\n");
610                return -1;
611        }
612
613        err = og_dbi_get_computer_info(&computer, cli->addr.sin_addr);
614        if (err < 0)
615                return -1;
616
617        snprintf(img_legacy.image_id, sizeof(img_legacy.image_id), "%s",
618                 image_id);
619        snprintf(img_legacy.part, sizeof(img_legacy.part), "%s", partition);
620        snprintf(img_legacy.disk, sizeof(img_legacy.disk), "%s", disk);
621        snprintf(soft_legacy.id, sizeof(soft_legacy.id), "%d", computer.id);
622
623        dbi = og_dbi_open(&dbi_config);
624        if (!dbi) {
625                syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
626                       __func__, __LINE__);
627                return -1;
628        }
629
630        query_result = dbi_conn_queryf(dbi->conn,
631                                       "SELECT idperfilsoft FROM imagenes "
632                                       " WHERE idimagen='%s'",
633                                       image_id);
634        if (!query_result) {
635                og_dbi_close(dbi);
636                syslog(LOG_ERR, "failed to query database\n");
637                return -1;
638        }
639        if (!dbi_result_next_row(query_result)) {
640                dbi_result_free(query_result);
641                og_dbi_close(dbi);
642                syslog(LOG_ERR, "software profile does not exist in database\n");
643                return -1;
644        }
645        snprintf(img_legacy.software_id, sizeof(img_legacy.software_id),
646                 "%d", dbi_result_get_uint(query_result, "idperfilsoft"));
647        dbi_result_free(query_result);
648
649        res = actualizaRestauracionImagen(dbi,
650                                          img_legacy.image_id,
651                                          img_legacy.disk,
652                                          img_legacy.part,
653                                          soft_legacy.id,
654                                          img_legacy.software_id);
655        og_dbi_close(dbi);
656
657        if (!res) {
658                syslog(LOG_ERR, "Problem updating client configuration\n");
659                return -1;
660        }
661
662        return 0;
663}
664
665int og_agent_state_process_response(struct og_client *cli)
666{
667        json_error_t json_err;
668        json_t *root;
669        int err = -1;
670        char *body;
671
672        if (!strncmp(cli->buf, "HTTP/1.0 202 Accepted",
673                     strlen("HTTP/1.0 202 Accepted"))) {
674                og_dbi_update_action(cli->last_cmd_id, true);
675                cli->last_cmd_id = 0;
676                return 1;
677        }
678
679        if (strncmp(cli->buf, "HTTP/1.0 200 OK", strlen("HTTP/1.0 200 OK"))) {
680                og_dbi_update_action(cli->last_cmd_id, false);
681                cli->last_cmd_id = 0;
682                return -1;
683        }
684        og_dbi_update_action(cli->last_cmd_id, true);
685        cli->last_cmd_id = 0;
686
687        if (!cli->content_length) {
688                cli->last_cmd = OG_CMD_UNSPEC;
689                return 0;
690        }
691
692        body = strstr(cli->buf, "\r\n\r\n") + 4;
693
694        root = json_loads(body, 0, &json_err);
695        if (!root) {
696                syslog(LOG_ERR, "%s:%d: malformed json line %d: %s\n",
697                       __FILE__, __LINE__, json_err.line, json_err.text);
698                return -1;
699        }
700
701        switch (cli->last_cmd) {
702        case OG_CMD_PROBE:
703                err = og_resp_probe(cli, root);
704                break;
705        case OG_CMD_SHELL_RUN:
706                err = og_resp_shell_run(cli, root);
707                break;
708        case OG_CMD_HARDWARE:
709                err = og_resp_hardware(root, cli);
710                break;
711        case OG_CMD_SOFTWARE:
712                err = og_resp_software(root, cli);
713                break;
714        case OG_CMD_REFRESH:
715                err = og_resp_refresh(root, cli);
716                break;
717        case OG_CMD_SETUP:
718                err = og_resp_refresh(root, cli);
719                break;
720        case OG_CMD_IMAGE_CREATE:
721                err = og_resp_image_create(root, cli);
722                break;
723        case OG_CMD_IMAGE_RESTORE:
724                err = og_resp_image_restore(root, cli);
725                break;
726        default:
727                err = -1;
728                break;
729        }
730
731        cli->last_cmd = OG_CMD_UNSPEC;
732
733        return err;
734}
Note: See TracBrowser for help on using the repository browser.