[config_tool] Duplicate VM name
Added check and error prompt for duplicate names of VM
before save scenario.
@@ -308,7 +308,26 @@ export default {
vmConfig['@id'] = vmIndex
})
},
+ confirmVmName() {
+ let vmNameArr = []
+ let errorFlag = false
+ for (let i = 0; i < this.scenario.vm.length; i++) {
+ vmNameArr.push(this.scenario.vm[i].name)
+ }
+ vmNameArr.sort()
+ console.log(vmNameArr)
+ for (let i = 0; i < vmNameArr.length - 1; i++) {
+ if (vmNameArr[i] === vmNameArr[i + 1]) {
+ alert("There are duplicate VM name with" + vmNameArr[i]
+ + ",\n please your VM name");
+ errorFlag = true
+ }
+ }
+ return errorFlag
+ },
saveScenario() {
+ let errorFlag = false
+ errorFlag = this.confirmVmName()
this.assignVMID()
let msg = ["Scenario xml saved\n",
".xml settings validated\n",
@@ -332,6 +351,7 @@ export default {
this.updateCurrentFormData()
// get scenario XML with defaults
scenarioXMLData = scenarioWithDefault.xml
+ if (!errorFlag) {
// begin write down and verify
configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData)
.then(() => {
@@ -360,6 +380,7 @@ export default {
}
}
}
+}
</script>
<style scoped>
