Skip to content

Commit

Permalink
added server info to common lib server
Browse files Browse the repository at this point in the history
  • Loading branch information
mpyne1 committed Jan 23, 2025
1 parent 607875c commit 75eae8b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions houston-common-lib/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,33 @@ import { Group, LocalGroup, isLocalGroup } from "@/group";
import { Directory, File } from "@/path";
import { ParsingError, ProcessError, ValueError } from "@/errors";
import { Download } from "@/download";
import { safeJsonParse } from "./utils";

export type ServerInfo = {
Motherboard: {
Manufacturer: string,
["Product Name"]: string,
["Serial Number"]: string
},
HBA:
({
Model: string,
Adapter: string,
"Bus Address": string,
"Drive Connections": number,
"Kernel Driver": string,
"PCI Slot": number
})[],
Hybrid: boolean,
Serial: string,
Model: string,
"Alias Style": string,
"Chassis Size": string,
VM: boolean,
"Edit Mode": boolean,
"OS NAME": string,
"OS VERSION_ID": string
}

export class Server {
public readonly host?: string;
Expand All @@ -21,6 +48,14 @@ export class Server {
return this.execute(new Command(["true"]), true).map(() => true);
}

getServerInfo(): ResultAsync<ServerInfo> {
return new File(
this,
"/etc/45drives/server_info/server_info.json"
).read()
.andThen(safeJsonParse<ServerInfo>);
}

getHostname(cache: boolean = true): ResultAsync<string, ProcessError> {
if (this.hostname === undefined || cache === false) {
return this.execute(new Command(["hostname"]), true).map(
Expand Down

0 comments on commit 75eae8b

Please sign in to comment.