Merge pull request #186 from a110605/filter_export_lhv1

Filter exported SC for non-longhorn V1 volume
This commit is contained in:
Andy Lee 2025-03-06 15:34:33 +08:00 committed by GitHub
commit 3e7b2338ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 7 deletions

View File

@ -34,9 +34,14 @@ export default {
await allHash(hash); await allHash(hash);
const defaultStorage = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS).find((s) => s.isDefault); const allStorages = this.allStorageClasses;
const defaultStorage = allStorages.find((s) => s.isDefault);
this['storageClassName'] = defaultStorage?.metadata?.name || 'longhorn'; if (this.isLonghornV1Volume) {
this['storageClassName'] = defaultStorage?.metadata?.name || 'longhorn';
} else {
this['storageClassName'] = this.nonLonghornV1StorageClasses[0]?.metadata?.name || '';
}
}, },
data() { data() {
@ -54,7 +59,7 @@ export default {
...mapGetters({ t: 'i18n/t' }), ...mapGetters({ t: 'i18n/t' }),
actionResource() { actionResource() {
return this.resources[0]; return this.resources[0] || {};
}, },
namespaces() { namespaces() {
@ -73,15 +78,33 @@ export default {
return out; return out;
}, },
isLonghornV1Volume() {
return this.actionResource?.isLonghornV1 === true;
},
disableSave() { disableSave() {
return !(this.name && this.namespace && this.storageClassName); return !(this.name && this.namespace && this.storageClassName);
}, },
storageClassOptions() { allStorageClasses() {
const inStore = this.$store.getters['currentProduct'].inStore; const inStore = this.$store.getters['currentProduct'].inStore;
const storages = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS);
const out = storages.filter((s) => !s.parameters?.backingImage).map((s) => { return this.$store.getters[`${ inStore }/all`](STORAGE_CLASS) || [];
},
nonLonghornV1StorageClasses() {
return this.allStorageClasses.filter((s) => s.isLonghornV1 === false) || [];
},
storageClassOptions() {
let storages = this.allStorageClasses;
// Volume with non-longhorn v1 sc can't be exported to longhorn v1 sc image
if (!this.isLonghornV1Volume) {
storages = this.allStorageClasses.filter((s) => s.isLonghornV1 === false);
}
const options = storages.filter((s) => !s.parameters?.backingImage).map((s) => {
const label = s.isDefault ? `${ s.name } (${ this.t('generic.default') })` : s.name; const label = s.isDefault ? `${ s.name } (${ this.t('generic.default') })` : s.name;
return { return {
@ -90,7 +113,7 @@ export default {
}; };
}) || []; }) || [];
return out; return options;
}, },
}, },

View File

@ -336,6 +336,10 @@ export default class HciPv extends HarvesterResource {
return this.volumeProvider === LONGHORN_DRIVER; return this.volumeProvider === LONGHORN_DRIVER;
} }
get isLonghornV1() {
return this.isLonghorn && !this.isLonghornV2;
}
get isLonghornV2() { get isLonghornV2() {
return this.dataEngine === DATA_ENGINE_V2; return this.dataEngine === DATA_ENGINE_V2;
} }