Skip to content

Commit

Permalink
Fix storage provisioners labels
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
  • Loading branch information
torchiaf committed Sep 10, 2024
1 parent 4e03186 commit e8bf9c8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 28 deletions.
32 changes: 17 additions & 15 deletions pkg/harvester/edit/harvesterhci.io.host/HarvesterDisk.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Tags from '../../components/DiskTags';
import { HCI } from '../../types';
import { LONGHORN_SYSTEM } from './index';
import { LONGHORN_DRIVER } from '@shell/models/persistentvolume';
import { LVM_DRIVER } from '@shell/models/storage.k8s.io.storageclass';
const LONGHORN_V2_DATA_ENGINE = 'longhorn-system/v2-data-engine';
Expand Down Expand Up @@ -51,24 +52,21 @@ export default {
async fetch() {
const inStore = this.$store.getters['currentProduct'].inStore;
const hash = {
csiDrivers: this.$store.dispatch(`${ inStore }/findAll`, { type: CSI_DRIVER }),
longhornSettings: this.$store.dispatch(`${ inStore }/find`, { type: LONGHORN.SETTINGS, id: LONGHORN_V2_DATA_ENGINE }),
};
const hash = await allHash({
csiDrivers: this.$store.dispatch(`${ inStore }/findAll`, { type: CSI_DRIVER }),
longhornV2DataEngine: this.$store.dispatch(`${ inStore }/find`, { type: LONGHORN.SETTINGS, id: LONGHORN_V2_DATA_ENGINE }),
});
await allHash(hash);
this.longhornVersion = hash.longhornV2DataEngine.value === 'true' ? 'v2' : 'v1';
},
data() {
const provisionerFormat = { [LONGHORN_DRIVER]: 'harvester.storage.storageClass.longhornV1.label' };
return {
// TODO add provisioner to Disk
longhornVersion: 'v1',
provisioner: {
label: provisionerFormat[LONGHORN_DRIVER],
label: this.t(`harvester.storage.storageClass.${ LONGHORN_DRIVER }.label`, { version: 1 }),
value: LONGHORN_DRIVER,
},
provisionerFormat
}
};
},
Expand All @@ -77,12 +75,9 @@ export default {
const inStore = this.$store.getters['currentProduct'].inStore;
const csiDrivers = this.$store.getters[`${ inStore }/all`](CSI_DRIVER) || [];
// TODO to check if longhornV2 to be added in the list
// const longhornV2 = this.$store.getters[`${ inStore }/byId`](LONGHORN.SETTINGS, LONGHORN_V2_DATA_ENGINE);
return csiDrivers.map((provisioner) => {
return {
label: this.provisionerFormat[provisioner.name] || provisioner.name,
label: this.provisionersLabelKeys[provisioner.name],
value: provisioner.name,
};
});
Expand Down Expand Up @@ -199,6 +194,13 @@ export default {
isFormatting() {
return this.blockDevice.isFormatting;
},
provisionersLabelKeys() {
return {
[LONGHORN_DRIVER]: `harvester.storage.storageClass.longhorn.${ this.longhornVersion }.label`,
[LVM_DRIVER]: 'harvester.storage.storageClass.lvm.label'
};
},
},
methods: {
Expand Down
29 changes: 20 additions & 9 deletions pkg/harvester/edit/harvesterhci.io.storage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import { CSI_DRIVER } from '../../types';
import { allHash } from '@shell/utils/promise';
import { clone } from '@shell/utils/object';
import { LONGHORN_DRIVER } from '@shell/models/persistentvolume';
import { LVM_DRIVER } from '@shell/models/storage.k8s.io.storageclass';
const LONGHORN_V2_DATA_ENGINE = 'longhorn-system/v2-data-engine';
export default {
name: 'HarvesterStorage',
Expand Down Expand Up @@ -88,20 +91,22 @@ export default {
defaultAddValue: {
key: '',
values: [],
}
},
longhornVersion: 'v1'
};
},
async fetch() {
const inStore = this.$store.getters['currentProduct'].inStore;
const hash = {
storages: this.$store.dispatch(`${ inStore }/findAll`, { type: STORAGE_CLASS }),
longhornNodes: this.$store.dispatch(`${ inStore }/findAll`, { type: LONGHORN.NODES }),
csiDrivers: this.$store.dispatch(`${ inStore }/findAll`, { type: CSI_DRIVER }),
};
const hash = await allHash({
storages: this.$store.dispatch(`${ inStore }/findAll`, { type: STORAGE_CLASS }),
longhornNodes: this.$store.dispatch(`${ inStore }/findAll`, { type: LONGHORN.NODES }),
csiDrivers: this.$store.dispatch(`${ inStore }/findAll`, { type: CSI_DRIVER }),
longhornV2DataEngine: this.$store.dispatch(`${ inStore }/find`, { type: LONGHORN.SETTINGS, id: LONGHORN_V2_DATA_ENGINE }),
});
await allHash(hash);
this.longhornVersion = hash.longhornV2DataEngine.value === 'true' ? 'v2' : 'v1';
},
computed: {
Expand All @@ -121,11 +126,10 @@ export default {
provisioners() {
const csiDrivers = this.$store.getters[`${ this.inStore }/all`](CSI_DRIVER) || [];
const format = { [LONGHORN_DRIVER]: 'harvester.storage.storageClass.longhornV1.label' };
return csiDrivers.map((provisioner) => {
return {
label: format[provisioner.name] || provisioner.name,
label: this.provisionersLabelKeys[provisioner.name],
value: provisioner.name,
};
});
Expand All @@ -136,6 +140,13 @@ export default {
return this.$store.getters[`${ inStore }/schemaFor`](STORAGE_CLASS);
},
provisionersLabelKeys() {
return {
[LONGHORN_DRIVER]: `harvester.storage.storageClass.longhorn.${ this.longhornVersion }.label`,
[LVM_DRIVER]: 'harvester.storage.storageClass.lvm.label'
};
},
},
watch: {
Expand Down
9 changes: 5 additions & 4 deletions pkg/harvester/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1054,10 +1054,11 @@ harvester:
label: Disk Selector
storageClass:
label: Storage Class
longhornV1:
label: LonghornV1 (CSI)
longhornV2:
label: LonghornV2 (CSI)
longhorn:
v1:
label: Longhorn v1 (CSI)
v2:
label: Longhorn v2 (CSI)
lvm:
label: LVM
title: Storage Classes
Expand Down
2 changes: 2 additions & 0 deletions shell/models/storage.k8s.io.storageclass.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ export const PROVISIONER_OPTIONS = [
}
];

export const LVM_DRIVER = 'lvm.driver.harvesterhci.io';

export default class extends SteveModel {
get provisionerDisplay() {
const option = PROVISIONER_OPTIONS.find(o => o.value === this.provisioner);
Expand Down

0 comments on commit e8bf9c8

Please sign in to comment.