[config_tool] Configurator creates duplicate VM name

1.add condition to recalculate maxVMID from saved VM name,  so that vm name could be update correctly
if there is VM names "service VM" "real-time VM" "VM11", the new VM will be named "VM12"

2. support calculate VM name when changing any VM name.
if there is VM names "service VM" "real-time VM" , the new VM will be named "VM2",count from 0.

Tracked-On: #8046
Signed-off-by: Chuang-Ke <chuangx.ke@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Chuang Ke 2022-08-24 15:22:15 +08:00 committed by acrnsi-robot
parent 8ac707d244
commit c411dbdfbf
1 changed files with 6 additions and 0 deletions

View File

@ -232,6 +232,12 @@ export default {
let haveService = false;
this.scenario.vm.map((vmConfig) => {
let vmID = vmConfig['@id'];
if (vmConfig['name'] && (/^VM(\d+)$/).test(vmConfig['name'])) {
let temp = vmConfig['name'].replace(/\D/g, ' ')
if (maxVMID < parseInt(temp)) {
maxVMID = parseInt(temp)
}
}
if (vmID > maxVMID) {
maxVMID = vmID
}