From 35dc60192f688bd94ebf1c5d0e3d2b5a5a011768 Mon Sep 17 00:00:00 2001 From: Yifan Liu Date: Wed, 27 Apr 2022 11:53:03 +0800 Subject: [PATCH] misc: configurator: Re-assign VMID based on load order Previously if user creates a shared scenario and adds a pre-launched VM, the pre-launched VM will be assigned a VMID that's greater than service VM, which will be blocked by scenario validation. This patch re-assigns the VMID before saving as scenario XMLs based on their load order. The UI-only VM name will have no impact on VMID that's actually written to scenario XML. Tracked-On: #7419 Signed-off-by: Yifan Liu --- misc/config_tools/configurator/src/pages/Config.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/misc/config_tools/configurator/src/pages/Config.vue b/misc/config_tools/configurator/src/pages/Config.vue index 947dbf691..ad584fdc1 100644 --- a/misc/config_tools/configurator/src/pages/Config.vue +++ b/misc/config_tools/configurator/src/pages/Config.vue @@ -198,7 +198,20 @@ export default { } this.updateCurrentFormData() }, + assignVMID() { + let vm_priority = { + 'PRE_LAUNCHED_VM': 0, + 'SERVICE_VM': 1, + 'POST_LAUNCHED_VM': 2 + } + this.scenario.vm.sort((a, b) => { + return vm_priority[a['load_order']] - vm_priority[b['load_order']] + }).map((vmConfig, vmIndex) => { + vmConfig['@id'] = vmIndex + }) + }, saveScenario(event) { + this.assignVMID() let scenarioXMLData = configurator.convertScenarioToXML( { // simple deep copy