-
Notifications
You must be signed in to change notification settings - Fork 594
/
installation.ts
56 lines (42 loc) · 1.84 KB
/
installation.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import * as _ from 'lodash';
import { NodeKind } from 'public/module/k8s';
export const SIZE_MAP = {
'512Gi': 0.5,
'2Ti': 2,
'4Ti': 4,
};
export const getPodName = (pod) => pod.metadata.name;
export const getPodRestartCount = (pod) => pod.status.containerStatuses[0].restartCount;
export const getPresentPod = (pods, podName: string) =>
pods.items.find((pod) => getPodName(pod) === podName);
export const getIds = (nodes, type: string): number[] =>
nodes.filter((node) => node.type === type).map((node) => node.id);
export const getNewOSDIds = (nodes, osds: number[]): number[] =>
nodes
.filter((node) => node.type === 'osd' && osds.indexOf(node.id) === -1)
.map((node) => node.id);
export const createOSDTreeMap = (nodes) =>
nodes.reduce((acc, curr) => Object.assign(acc, { [curr.id]: curr }), {});
export const verifyZoneOSDMapping = (zones: number[], osds: number[], osdtree): boolean => {
let filteredOsds = [...osds];
zones.forEach((zone) => {
const hostId = osdtree[zone].children[0];
const len = osdtree[hostId].children.length;
filteredOsds = filteredOsds.filter((osd) => osd !== osdtree[hostId].children[len - 1]);
});
return filteredOsds.length === 0;
};
export const verifyNodeOSDMapping = (nodes: number[], osds: number[], osdtree): boolean => {
let filteredOsds = [...osds];
nodes.forEach((node) => {
const len = osdtree[node].children.length;
filteredOsds = filteredOsds.filter((osd) => osd !== osdtree[node].children[len - 1]);
});
return filteredOsds.length === 0;
};
export const isNodeReady = (node: NodeKind): boolean => {
const conditions = node.status?.conditions ?? [];
const readyState: any = _.find(conditions, { type: 'Ready' });
return readyState && readyState.status === 'True';
};
export const getDeviceCount = (storageCluster) => storageCluster?.spec?.storageDeviceSets[0].count;