mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-11-22 00:27:38 +08:00
Add pkg/harvester components + shell portings - 1
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
265 files changed
+42316
-82
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import SteveModel from '@shell/plugins/steve/steve-class';
|
||||
|
||||
const HEALTHY = 'healthy';
|
||||
const WARNING = 'warning';
|
||||
|
||||
export default class LonghornNode extends SteveModel {
|
||||
get used() {
|
||||
let out = 0;
|
||||
|
||||
this.disks.filter(d => d.allowScheduling).map((disk) => {
|
||||
if (disk?.storageAvailable && disk?.storageMaximum) {
|
||||
out += disk.storageMaximum - disk.storageAvailable;
|
||||
}
|
||||
});
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
get disks() {
|
||||
const diskStatus = this?.status?.diskStatus || {};
|
||||
const diskSpec = this?.spec?.disks || {};
|
||||
|
||||
return Object.keys(diskSpec).map((key) => {
|
||||
const conditions = diskStatus[key]?.conditions || [];
|
||||
const readyCondition = conditions.find(c => c.type === 'Ready') || {};
|
||||
const schedulableCondition = conditions.find(c => c.type === 'Schedulable') || {};
|
||||
|
||||
let state;
|
||||
|
||||
if (readyCondition?.status !== 'True' || schedulableCondition?.status !== 'True') {
|
||||
state = WARNING;
|
||||
} else {
|
||||
state = HEALTHY;
|
||||
}
|
||||
|
||||
return {
|
||||
...diskStatus[key],
|
||||
...diskSpec[key],
|
||||
id: key,
|
||||
state,
|
||||
};
|
||||
}) || [];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user