-
Notifications
You must be signed in to change notification settings - Fork 7
/
zdb.ts
37 lines (36 loc) · 1.52 KB
/
zdb.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { events } from "../helpers/events";
import { Operations, TwinDeployment } from "../high_level/models";
import { DeploymentFactory } from "../primitives/deployment";
import { Nodes } from "../primitives/nodes";
import { ZdbPrimitive } from "../primitives/zdb";
import { Deployment } from "../zos/deployment";
import { WorkloadTypes } from "../zos/workload";
import { ZdbModes } from "../zos/zdb";
import { HighLevelBase } from "./base";
class ZdbHL extends HighLevelBase {
async create(
name: string,
node_id: number,
disk_size: number,
mode: ZdbModes,
password: string,
publicNamespace: boolean,
metadata = "",
description = "",
solutionProviderId?: number,
): Promise<TwinDeployment> {
if (!(await this.nodes.nodeHasResources(node_id, { hru: disk_size }))) {
throw Error(`Node ${node_id} doesn't have enough resources: hru=${disk_size}`);
}
events.emit("logs", `Creating a zdb on node: ${node_id}`);
const deploymentFactory = new DeploymentFactory(this.config);
const zdbFactory = new ZdbPrimitive();
const zdbWorkload = zdbFactory.create(name, disk_size, mode, password, publicNamespace, metadata, description);
const deployment = deploymentFactory.create([zdbWorkload], 1626394539, metadata, description, 0);
return new TwinDeployment(deployment, Operations.deploy, 0, node_id, null, solutionProviderId);
}
async delete(deployment: Deployment, names: string[]) {
return await this._delete(deployment, names, [WorkloadTypes.zdb]);
}
}
export { ZdbHL };