fix: VM's machine type options is not support (#307)

* feat: get options from API

Signed-off-by: Yi-Ya Chen <yiya.chen@suse.com>

* feat: add feature flag

Signed-off-by: Yi-Ya Chen <yiya.chen@suse.com>

* refactor: remove default value

Signed-off-by: Yi-Ya Chen <yiya.chen@suse.com>

* refactor: fallback to none

Signed-off-by: Yi-Ya Chen <yiya.chen@suse.com>

---------

Signed-off-by: Yi-Ya Chen <yiya.chen@suse.com>
This commit is contained in:
Yiya Chen 2025-06-02 12:38:04 +08:00 committed by GitHub
parent d6da4898b4
commit 7ecc9c320d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 9 deletions

View File

@ -37,7 +37,9 @@ const FEATURE_FLAGS = {
'liveMigrationProgress'
],
'v1.5.1': [],
'v1.6.0': []
'v1.6.0': [
'vmMachineTypes'
]
};
const generateFeatureFlags = () => {

View File

@ -114,13 +114,11 @@ export default {
},
machineTypeOptions() {
return [{
label: 'None',
value: ''
}, {
label: 'q35',
value: 'q35'
}];
return this.machineTypes.map((type) => {
if (!type) return { label: 'None', value: '' };
return { label: type, value: type };
});
},
templateOptions() {

View File

@ -157,6 +157,7 @@ export default {
diskRows: [],
networkRows: [],
machineType: '',
machineTypes: [],
secretName: '',
secretRef: null,
showAdvanced: false,
@ -295,6 +296,9 @@ export default {
async created() {
await this.$store.dispatch(`${ this.inStore }/findAll`, { type: SECRET });
const machineTypes = this.value.vmMachineTypesFeatureEnabled ? await this.$store.dispatch('harvester/request', { url: '/v1/harvester/clusters/local?link=machineTypes' }) : [''];
this.machineTypes = machineTypes;
this.getInitConfig({ value: this.value, init: this.isCreate });
},
@ -331,7 +335,8 @@ export default {
const maintenanceStrategy = vm.metadata.labels?.[HCI_ANNOTATIONS.VM_MAINTENANCE_MODE_STRATEGY] || 'Migrate';
const runStrategy = spec.runStrategy || 'RerunOnFailure';
const machineType = value.machineType;
const machineType = spec.template.spec.domain?.machine?.type || this.machineTypes[0];
const cpu = spec.template.spec.domain?.cpu?.cores;
const memory = spec.template.spec.domain.resources.limits.memory;
const reservedMemory = vm.metadata?.annotations?.[HCI_ANNOTATIONS.VM_RESERVED_MEMORY];

View File

@ -1205,6 +1205,10 @@ export default class VirtVm extends HarvesterResource {
return this.$rootGetters['harvester-common/getFeatureEnabled']('thirdPartyStorage');
}
get vmMachineTypesFeatureEnabled() {
return this.$rootGetters['harvester-common/getFeatureEnabled']('vmMachineTypes');
}
setInstanceLabels(val) {
if ( !this.spec?.template?.metadata?.labels ) {
set(this, 'spec.template.metadata.labels', {});