-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathnode-utils.ts
More file actions
24 lines (20 loc) · 1.01 KB
/
node-utils.ts
File metadata and controls
24 lines (20 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { Node, NodeState, Pool } from "app/models";
export class NodeUtils {
public static getSubStatesforCategory(category: string): NodeState[] {
if (category === "error") {
return [NodeState.startTaskFailed, NodeState.unusable, NodeState.unknown];
} else if (category === "transition") {
return [NodeState.creating, NodeState.starting, NodeState.rebooting,
NodeState.reimaging, NodeState.leavingPool, NodeState.upgradingos];
} else if (category === "running") {
return [NodeState.running25, NodeState.running50, NodeState.running75, NodeState.running99, NodeState.running100];
}
return [];
}
public static getTaskSlotsUsagePercent(node: Node, pool: Pool): number {
const taskSlotsPerNode = pool.taskSlotsPerNode;
const taskSlotsCount = node.runningTaskSlotsCount;
const taskSlotPercentUsed = Math.floor((taskSlotsCount / taskSlotsPerNode) * 100);
return taskSlotPercentUsed;
}
}