mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 13:11:43 +00:00
fix: unable to create VM when choosing L2VlanNetwork (#534)
* fix: unable to create VM via l2vlan network Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: based on discussion Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: add comment Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
parent
9fdbe9c58f
commit
5a0d7f283d
@ -892,7 +892,7 @@ export default {
|
||||
});
|
||||
|
||||
const specInterfaces = this.spec?.template?.spec?.domain?.devices?.interfaces;
|
||||
const mergedInterfaces = this.mergeDeviceList(specInterfaces, interfaces);
|
||||
const mergedInterfaces = this.mergeInterfaceList(specInterfaces, interfaces);
|
||||
|
||||
const spec = {
|
||||
...this.spec.template.spec,
|
||||
@ -1551,6 +1551,32 @@ export default {
|
||||
this.refreshYamlEditor();
|
||||
},
|
||||
|
||||
mergeInterfaceList(specInterfaceList, interfaceList) {
|
||||
if (!specInterfaceList || specInterfaceList.length === 0) {
|
||||
return interfaceList;
|
||||
}
|
||||
const specInterfaceMap = new Map(specInterfaceList.map((iface) => [iface.name, iface]));
|
||||
|
||||
return interfaceList.map((iface) => {
|
||||
const specInterface = specInterfaceMap.get(iface.name);
|
||||
|
||||
if (specInterface) {
|
||||
const merged = { ...specInterface, ...iface };
|
||||
|
||||
// currently we only have bridge and masquerade network type, they are mutually exclusive
|
||||
if (iface['bridge']) {
|
||||
delete merged['masquerade'];
|
||||
} else {
|
||||
delete merged['bridge'];
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
return iface;
|
||||
});
|
||||
},
|
||||
|
||||
mergeDeviceList(specDeviceList, deviceList) {
|
||||
if (!specDeviceList || specDeviceList.length === 0) {
|
||||
return deviceList;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user