mirror of https://git.48k.eu/ogserver
#1065 client: add support for ogclient linux state
ogClient can be run in linux mode, intended for exposing some ogServer commands when running in a linux distribution. When connecting with a client in linux mode, do not expect a full partition setup response. Just expect a 'status', and then accept the connection without updating any partition information in the database.master
parent
ac3ce22c35
commit
5a3fd51261
|
@ -286,6 +286,7 @@ static int og_resp_refresh(json_t *data, struct og_client *cli)
|
||||||
struct og_partition disks[OG_DISK_MAX] = {};
|
struct og_partition disks[OG_DISK_MAX] = {};
|
||||||
const char *serial_number = NULL;
|
const char *serial_number = NULL;
|
||||||
struct og_computer computer = {};
|
struct og_computer computer = {};
|
||||||
|
const char *status = NULL;
|
||||||
char cfg[4096] = {};
|
char cfg[4096] = {};
|
||||||
struct og_dbi *dbi;
|
struct og_dbi *dbi;
|
||||||
const char *key;
|
const char *key;
|
||||||
|
@ -304,12 +305,19 @@ static int og_resp_refresh(json_t *data, struct og_client *cli)
|
||||||
err = og_json_parse_partition_array(value, partitions);
|
err = og_json_parse_partition_array(value, partitions);
|
||||||
} else if (!strcmp(key, "serial_number")) {
|
} else if (!strcmp(key, "serial_number")) {
|
||||||
err = og_json_parse_string(value, &serial_number);
|
err = og_json_parse_string(value, &serial_number);
|
||||||
|
} else if (!strcmp(key, "status")) {
|
||||||
|
err = og_json_parse_string(value, &status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status && !strncmp(status, "LINUX", strlen("LINUX"))) {
|
||||||
|
cli->status = OG_CLIENT_STATUS_LINUX;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen(serial_number) > 0)
|
if (strlen(serial_number) > 0)
|
||||||
snprintf(cfg, sizeof(cfg), "ser=%s\n", serial_number);
|
snprintf(cfg, sizeof(cfg), "ser=%s\n", serial_number);
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,8 @@ static const char *og_client_status(const struct og_client *cli)
|
||||||
return "OPG";
|
return "OPG";
|
||||||
case OG_CLIENT_STATUS_VIRTUAL:
|
case OG_CLIENT_STATUS_VIRTUAL:
|
||||||
return "VDI";
|
return "VDI";
|
||||||
|
case OG_CLIENT_STATUS_LINUX:
|
||||||
|
return "LINUX";
|
||||||
default:
|
default:
|
||||||
return "OFF";
|
return "OFF";
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ enum og_client_status {
|
||||||
OG_CLIENT_STATUS_OGLIVE,
|
OG_CLIENT_STATUS_OGLIVE,
|
||||||
OG_CLIENT_STATUS_BUSY,
|
OG_CLIENT_STATUS_BUSY,
|
||||||
OG_CLIENT_STATUS_VIRTUAL,
|
OG_CLIENT_STATUS_VIRTUAL,
|
||||||
|
OG_CLIENT_STATUS_LINUX,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum og_cmd_type {
|
enum og_cmd_type {
|
||||||
|
|
Loading…
Reference in New Issue