Latest changes from Harvester master - d7d9d4af8a88d677695d7aff47a81d52041dfcca

Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
Francesco Torchia
2024-11-12 11:50:17 +01:00
parent d04cd35a08
commit dc74441d26
46 changed files with 1290 additions and 1624 deletions
@@ -8,10 +8,10 @@ import { LabeledInput } from '@components/Form/LabeledInput';
import LabeledSelect from '@shell/components/form/LabeledSelect';
import ModalWithCard from '@shell/components/ModalWithCard';
import { PVC, STORAGE_CLASS } from '@shell/config/types';
import { PVC } from '@shell/config/types';
import { clone } from '@shell/utils/object';
import { ucFirst, randomStr } from '@shell/utils/string';
import { removeObject } from '@shell/utils/array';
import { randomStr } from '@shell/utils/string';
import { _VIEW, _EDIT, _CREATE } from '@shell/config/query-params';
import { PLUGIN_DEVELOPER, DEV } from '@shell/store/prefs';
import { SOURCE_TYPE } from '../../../config/harvester-map';
@@ -82,11 +82,12 @@ export default {
data() {
return {
ucFirst,
SOURCE_TYPE,
rows: clone(this.value),
nameIdx: 1,
vol: null,
isOpen: false,
isOpen: false
};
},
@@ -175,10 +176,7 @@ export default {
};
if (type === SOURCE_TYPE.NEW) {
const inStore = this.$store.getters['currentProduct'].inStore;
const defaultStorage = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS).find( O => O.isDefault);
neu.storageClassName = defaultStorage?.metadata?.name || 'longhorn';
neu.storageClassName = this.defaultStorageClass?.metadata?.name || 'longhorn';
}
this.rows.push(neu);
@@ -258,6 +256,10 @@ export default {
getImageDisplayName(id) {
return this.$store.getters['harvester/all'](HCI.IMAGE).find(image => image.id === id)?.spec?.displayName;
},
isLonghornV2(volume) {
return volume?.pvc?.storageClass?.isLonghornV2;
}
},
};
@@ -371,12 +373,24 @@ export default {
</div>
</div>
<Banner
v-if="volume.volumeStatus && !isCreate"
class="mt-15 volume-status"
color="warning"
:label="volume.volumeStatus"
/>
<div class="mt-15">
<Banner
v-if="volume.volumeStatus && !isCreate"
class="volume-status"
color="warning"
:label="ucFirst(volume.volumeStatus)"
/>
<Banner
v-if="value.volumeBackups && value.volumeBackups.error && value.volumeBackups.error.message"
color="error"
:label="ucFirst(value.volumeBackups.error.message)"
/>
<Banner
v-if="isLonghornV2(volume) && !isView"
color="warning"
:label="t('harvester.volume.longhorn.disableResize')"
/>
</div>
</InfoBox>
</div>
</template>
@@ -497,4 +511,8 @@ export default {
justify-content: center;
align-items: center;
}
.banner {
margin: 10px 0;
}
</style>
@@ -114,6 +114,10 @@ export default {
return allPVCs.find((P) => {
return this.namespace ? P.id === `${ this.namespace }/${ this.value.volumeName }` : true;
});
},
isLonghornV2() {
return this.value.pvc?.storageClass?.isLonghornV2;
}
},
@@ -279,6 +283,7 @@ export default {
:label="t('harvester.fields.size')"
:mode="mode"
:required="validateRequired"
:disable="isLonghornV2"
suffix="GiB"
@update:value="update"
/>
@@ -4,13 +4,14 @@ import UnitInput from '@shell/components/form/UnitInput';
import InputOrDisplay from '@shell/components/InputOrDisplay';
import { LabeledInput } from '@components/Form/LabeledInput';
import LabeledSelect from '@shell/components/form/LabeledSelect';
import { Banner } from '@components/Banner';
import { PVC, STORAGE_CLASS } from '@shell/config/types';
import { formatSi, parseSi } from '@shell/utils/units';
import { VOLUME_TYPE, InterfaceOption } from '../../../../config/harvester-map';
import { _VIEW } from '@shell/config/query-params';
import LabelValue from '@shell/components/LabelValue';
import { ucFirst } from '@shell/utils/string';
import { LVM_DRIVER } from '../../../../models/harvester/storage.k8s.io.storageclass';
import { DATA_ENGINE_V2 } from '../../../../edit/harvesterhci.io.storage/index.vue';
export default {
name: 'HarvesterEditVolume',
@@ -18,7 +19,7 @@ export default {
emits: ['update'],
components: {
InputOrDisplay, Loading, LabeledInput, LabeledSelect, UnitInput, LabelValue, Banner
InputOrDisplay, Loading, LabeledInput, LabeledSelect, UnitInput, LabelValue
},
props: {
@@ -88,10 +89,12 @@ export default {
return !this.value.newCreateId && this.isEdit && this.isVirtualType;
},
storageClassOptions() {
const storages = this.$store.getters[`harvester/all`](STORAGE_CLASS) || [];
storageClasses() {
return this.$store.getters[`harvester/all`](STORAGE_CLASS) || [];
},
const out = storages.filter(s => !s.parameters?.backingImage).map((s) => {
storageClassOptions() {
return this.storageClasses.filter(s => !s.parameters?.backingImage).map((s) => {
const label = s.isDefault ? `${ s.name } (${ this.t('generic.default') })` : s.name;
return {
@@ -99,12 +102,25 @@ export default {
value: s.name,
};
}) || [];
return out;
},
isLonghornV2() {
return this.value.pvc?.storageClass?.isLonghornV2;
}
},
watch: {
'value.storageClassName': {
immediate: true,
handler(neu) {
const storageClass = this.storageClasses.find(sc => sc.name === neu);
const provisioner = storageClass?.provisioner;
const engine = storageClass?.parameters?.dataEngine;
this.value.accessMode = provisioner === LVM_DRIVER || engine === DATA_ENGINE_V2 ? 'ReadWriteOnce' : 'ReadWriteMany';
}
},
'value.type'(neu) {
if (neu === 'cd-rom') {
this.value['bus'] = 'sata';
@@ -222,6 +238,7 @@ export default {
:mode="mode"
:required="validateRequired"
:label="t('harvester.fields.size')"
:disabled="isLonghornV2"
@update:value="update"
/>
</InputOrDisplay>
@@ -261,11 +278,5 @@ export default {
/>
</div>
</div>
<Banner
v-if="value.volumeBackups && value.volumeBackups.error && value.volumeBackups.error.message"
color="error"
class="mb-20"
:label="value.volumeBackups.error.message"
/>
</div>
</template>