From bf1340d8651e50a2596a583004bd8f5243f465ec Mon Sep 17 00:00:00 2001 From: Francesco Torchia Date: Mon, 9 Sep 2024 19:08:39 +0200 Subject: [PATCH] Update Storage and Disk tabs based on provisioner - TO CONTINUE Signed-off-by: Francesco Torchia --- .../harvesterhci.io.host/HarvesterDisk.vue | 47 +++++++++++++++---- .../edit/harvesterhci.io.storage/index.vue | 18 +++++-- .../provisioners/driver.longhorn.io.vue | 12 ++++- 3 files changed, 63 insertions(+), 14 deletions(-) diff --git a/pkg/harvester/edit/harvesterhci.io.host/HarvesterDisk.vue b/pkg/harvester/edit/harvesterhci.io.host/HarvesterDisk.vue index 78b536c1948..084b4dbf96c 100644 --- a/pkg/harvester/edit/harvesterhci.io.host/HarvesterDisk.vue +++ b/pkg/harvester/edit/harvesterhci.io.host/HarvesterDisk.vue @@ -56,17 +56,11 @@ export default { csiDrivers: this.$store.dispatch(`${ inStore }/findAll`, { type: CSI_DRIVER }), longhornV2DataEngine: this.$store.dispatch(`${ inStore }/find`, { type: LONGHORN.SETTINGS, id: LONGHORN_V2_DATA_ENGINE }), }); - - this.longhornVersion = hash.longhornV2DataEngine.value === 'true' ? 'v2' : 'v1'; }, data() { return { - longhornVersion: 'v1', - provisioner: { - label: this.t(`harvester.storage.storageClass.${ LONGHORN_DRIVER }.label`, { version: 1 }), - value: LONGHORN_DRIVER, - } + provisioner: this.value.provisioner || LONGHORN_DRIVER, // TODO fix provisioner souce field }; }, @@ -195,12 +189,43 @@ export default { return this.blockDevice.isFormatting; }, + longhornVersion() { + const inStore = this.$store.getters['currentProduct'].inStore; + const v2DataEngine = this.$store.getters[`${ inStore }/byId`](LONGHORN.SETTINGS, LONGHORN_V2_DATA_ENGINE) || {}; + + return v2DataEngine.value === 'true' ? 'v2' : 'v1'; + }, + + isLvm() { + return this.provisioner === LVM_DRIVER; + }, + + isLonghornV1() { + return this.provisioner === LONGHORN_DRIVER && this.longhornVersion === 'v1'; + }, + + isLonghornV2() { + return this.provisioner === LONGHORN_DRIVER && this.longhornVersion === 'v2'; + }, + provisionersLabelKeys() { return { [LONGHORN_DRIVER]: `harvester.storage.storageClass.longhorn.${ this.longhornVersion }.label`, [LVM_DRIVER]: 'harvester.storage.storageClass.lvm.label' }; }, + + showLonghornOptions() { + return this.isCorrupted || ( + this.value.isNew && + !this.isFormatted && + this.isLonghornV1 + ); + }, + + showLVMOptions() { + return this.isLvm; + } }, methods: { @@ -316,7 +341,7 @@ export default { /> -
+
+ +
+
+ ciao lvm +
+
diff --git a/pkg/harvester/edit/harvesterhci.io.storage/index.vue b/pkg/harvester/edit/harvesterhci.io.storage/index.vue index 3479aeab7da..3829b29664a 100644 --- a/pkg/harvester/edit/harvesterhci.io.storage/index.vue +++ b/pkg/harvester/edit/harvesterhci.io.storage/index.vue @@ -92,7 +92,6 @@ export default { key: '', values: [], }, - longhornVersion: 'v1' }; }, @@ -105,8 +104,6 @@ export default { csiDrivers: this.$store.dispatch(`${ inStore }/findAll`, { type: CSI_DRIVER }), longhornV2DataEngine: this.$store.dispatch(`${ inStore }/find`, { type: LONGHORN.SETTINGS, id: LONGHORN_V2_DATA_ENGINE }), }); - - this.longhornVersion = hash.longhornV2DataEngine.value === 'true' ? 'v2' : 'v1'; }, computed: { @@ -147,11 +144,24 @@ export default { [LVM_DRIVER]: 'harvester.storage.storageClass.lvm.label' }; }, + + longhornVersion() { + const inStore = this.$store.getters['currentProduct'].inStore; + const v2DataEngine = this.$store.getters[`${ inStore }/byId`](LONGHORN.SETTINGS, LONGHORN_V2_DATA_ENGINE) || {}; + + return v2DataEngine.value === 'true' ? 'v2' : 'v1'; + }, }, watch: { provisionerWatch() { - this.$set(this.value, 'parameters', {}); + const parameters = {}; + + if (this.isLonghornV2) { + parameters.migratable = false; + } + + this.$set(this.value, 'parameters', parameters); } }, diff --git a/pkg/harvester/edit/harvesterhci.io.storage/provisioners/driver.longhorn.io.vue b/pkg/harvester/edit/harvesterhci.io.storage/provisioners/driver.longhorn.io.vue index 329f61d2bfc..9df58d0a78d 100644 --- a/pkg/harvester/edit/harvesterhci.io.storage/provisioners/driver.longhorn.io.vue +++ b/pkg/harvester/edit/harvesterhci.io.storage/provisioners/driver.longhorn.io.vue @@ -9,6 +9,8 @@ import { LONGHORN } from '@shell/config/types'; import { clone } from '@shell/utils/object'; import { uniq } from '@shell/utils/array'; +const LONGHORN_V2_DATA_ENGINE = 'longhorn-system/v2-data-engine'; + const DEFAULT_PARAMETERS = [ 'numberOfReplicas', 'staleReplicaTimeout', @@ -41,17 +43,22 @@ export default { }, data() { + const inStore = this.$store.getters['currentProduct'].inStore; + const v2DataEngine = this.$store.getters[`${ inStore }/byId`](LONGHORN.SETTINGS, LONGHORN_V2_DATA_ENGINE) || {}; + + const longhornVersion = v2DataEngine.value === 'true' ? 'v2' : 'v1'; + if (this.realMode === _CREATE) { this.$set(this.value, 'parameters', { numberOfReplicas: '3', staleReplicaTimeout: '30', diskSelector: null, nodeSelector: null, - migratable: 'true', + migratable: longhornVersion === 'v2' ? 'false' : 'true', }); } - return {}; + return { longhornVersion }; }, computed: { @@ -229,6 +236,7 @@ export default { :label="t('harvester.storage.parameters.migratable.label')" :mode="mode" :options="migratableOptions" + :disabled="longhornVersion === 'v2'" />