Add remote configuration of hosts

Implement remote editing of the host config in a similar fasion to how
the remote editing of the controller config works.
This commit is contained in:
Hornwitser committed 2024-01-15 20:28:44 +01:00
1 parent 705fb90740
commit 707c0bb453
10 files changed
+325 -9

No files matched your search

+57 -1
View File
@@ -1,6 +1,62 @@
import { Type, Static } from "@sinclair/typebox";
import { jsonArray, StringEnum } from "./composites";
import { jsonArray, plainJson, StringEnum } from "./composites";
import { CollectorResultSerialized } from "../prometheus";
import { HostConfig } from "../config/definitions";
export class HostConfigGetRequest {
declare ["constructor"]: typeof HostConfigGetRequest;
static type = "request" as const;
static src = ["control", "controller"] as const;
static dst = "host" as const;
static permission = "core.host.get_config" as const;
static Response = plainJson(HostConfig.jsonSchema);
}
export class HostConfigSetFieldRequest {
declare ["constructor"]: typeof HostConfigSetFieldRequest;
static type = "request" as const;
static src = ["control", "controller"] as const;
static dst = "host" as const;
static permission = "core.host.update_config" as const;
constructor(
public field: string,
public value: string,
) { }
static jsonSchema = Type.Object({
"field": Type.String(),
"value": Type.String(),
});
static fromJSON(json: Static<typeof this.jsonSchema>) {
return new this(json.field, json.value);
}
}
export class HostConfigSetPropRequest {
declare ["constructor"]: typeof HostConfigSetPropRequest;
static type = "request" as const;
static src = ["control", "controller"] as const;
static dst = "host" as const;
static permission = "core.host.update_config" as const;
constructor(
public field: string,
public prop: string,
public value?: unknown,
) { }
static jsonSchema = Type.Object({
"field": Type.String(),
"prop": Type.String(),
"value": Type.Optional(Type.Unknown()),
});
static fromJSON(json: Static<typeof this.jsonSchema>) {
return new this(json.field, json.prop, json.value);
}
}
export class HostDetails {
constructor(
+3
View File
@@ -32,6 +32,9 @@ export const dataClasses: (RequestClass<unknown, unknown> | EventClass<unknown>)
subscriptions.SubscriptionRequest,
host.HostConfigGetRequest,
host.HostConfigSetFieldRequest,
host.HostConfigSetPropRequest,
host.HostListRequest,
host.HostUpdatesEvent,
host.HostMetricsRequest,
+10
View File
@@ -136,6 +136,16 @@ definePermission({
"Subscribe to be notified when the system metrics detailing cpu, memory and disk usage for the " +
"controller and hosts are updated.",
});
definePermission({
name: "core.host.get_config",
title: "Get host configs",
description: "Get the config of hosts.",
});
definePermission({
name: "core.host.update_config",
title: "Modify host configs",
description: "Modify the host config or entries of the host config.",
});
definePermission({
name: "core.host.list",
title: "List hosts",