40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
|
import * as plugins from '../cloudly.plugins.js';
|
||
|
|
||
|
/*
|
||
|
* cluster defines a swarmkit cluster
|
||
|
*/
|
||
|
@plugins.smartdata.Manager()
|
||
|
export class Server extends plugins.smartdata.SmartDataDbDoc<Server, plugins.servezoneInterfaces.data.IServer> {
|
||
|
// STATIC
|
||
|
public static async createFromHetznerServer(
|
||
|
hetznerServerArg: plugins.hetznercloud.HetznerServer
|
||
|
) {
|
||
|
const newServer = new Server();
|
||
|
newServer.id = plugins.smartunique.shortId(8);
|
||
|
const data: plugins.servezoneInterfaces.data.IServer['data'] = {
|
||
|
assignedClusterId: hetznerServerArg.data.labels.clusterId,
|
||
|
requiredDebianPackages: [],
|
||
|
sshKeys: [],
|
||
|
type: 'hetzner',
|
||
|
}
|
||
|
Object.assign(newServer, { data });
|
||
|
await newServer.save();
|
||
|
return newServer;
|
||
|
}
|
||
|
|
||
|
// INSTANCE
|
||
|
@plugins.smartdata.unI()
|
||
|
public id: string;
|
||
|
|
||
|
@plugins.smartdata.svDb()
|
||
|
public data: plugins.servezoneInterfaces.data.IServer['data'];
|
||
|
|
||
|
constructor() {
|
||
|
super();
|
||
|
}
|
||
|
|
||
|
public async getServices(): Promise<plugins.servezoneInterfaces.data.IService[]> {
|
||
|
return [];
|
||
|
}
|
||
|
}
|