Revert "config_tools: add SyntacticValidationStage before save scenario"
This reverts commit 68636087a6
.
Tracked-On: #6691
Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
This commit is contained in:
parent
c24515cb7c
commit
753b2cf2c3
|
@ -39,8 +39,8 @@ class PythonObject {
|
|||
return this.api('validateScenarioStructure', 'plaintext', scenarioXMLText)
|
||||
}
|
||||
|
||||
validateScenario(boardXMLText, scenarioXMLText, completed_verify = false) {
|
||||
return this.api('validateScenario', 'json', boardXMLText, scenarioXMLText, completed_verify)
|
||||
validateScenario(boardXMLText, scenarioXMLText) {
|
||||
return this.api('validateScenario', 'json', boardXMLText, scenarioXMLText)
|
||||
}
|
||||
|
||||
generateLaunchScript(boardXMLText, scenarioXMLText) {
|
||||
|
|
|
@ -114,7 +114,6 @@ export default {
|
|||
window.getCurrentFormSchemaData = this.getCurrentFormSchemaData
|
||||
window.getCurrentScenarioData = this.getCurrentScenarioData
|
||||
window.getBoardData = this.getBoardData
|
||||
window.getErrors = this.getErrors
|
||||
this.showFlag = this.isNewConfig === 'true'
|
||||
},
|
||||
data() {
|
||||
|
@ -143,9 +142,6 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
getErrors() {
|
||||
return this.errors
|
||||
},
|
||||
back() {
|
||||
this.$router.back()
|
||||
},
|
||||
|
@ -220,11 +216,7 @@ export default {
|
|||
} else {
|
||||
if (this.schemas.ServiceVM.BasicConfigType.properties.hasOwnProperty('vm_type') === false) {
|
||||
this.schemas.ServiceVM.BasicConfigType.properties.vm_type =
|
||||
{
|
||||
$ref: '#/definitions/BasicVMType',
|
||||
title: 'VM type',
|
||||
description: '<p>Select the VM type. A standard VM (<span class=…ial features for time-sensitive applications.</p>'
|
||||
}
|
||||
{$ref: '#/definitions/BasicVMType', title: 'VM type', description: '<p>Select the VM type. A standard VM (<span class=…ial features for time-sensitive applications.</p>'}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -387,33 +379,11 @@ export default {
|
|||
let scenarioWithDefault = configurator.pythonObject.populateDefaultValues(scenarioXMLData)
|
||||
scenarioWithDefault = scenarioWithDefault.json['acrn-config']
|
||||
|
||||
if ((!scenarioWithDefault.hv.FEATURES.hasOwnProperty('RDT')) || scenarioWithDefault.hv.FEATURES.RDT.RDT_ENABLED === 'n') {
|
||||
if (scenarioWithDefault.hv.FEATURES.RDT.RDT_ENABLED === 'n') {
|
||||
delete scenarioWithDefault.hv.CACHE_REGION
|
||||
}
|
||||
return scenarioWithDefault
|
||||
},
|
||||
translateErrors() {
|
||||
let messageRegex = [
|
||||
{
|
||||
regex: /The content of element '(.+?)' is not complete. Tag '(.+?)' expected./,
|
||||
replace: '"$2" field in "$1" is required.'
|
||||
},
|
||||
{
|
||||
regex: /Unexpected child with tag 'VBDF' at position 1. Tag 'VM_NAME' expected./,
|
||||
replace: '"VM name" in "InterVM shared memory region" is required.'
|
||||
}
|
||||
]
|
||||
const translate = (error) => {
|
||||
for (const messageRegexKey in messageRegex) {
|
||||
if (messageRegex[messageRegexKey].regex.test(error.message)) {
|
||||
error.message = error.message.replace(messageRegex[messageRegexKey].regex, messageRegex[messageRegexKey].replace)
|
||||
}
|
||||
}
|
||||
}
|
||||
this.errors.map((error) => {
|
||||
translate(error)
|
||||
})
|
||||
},
|
||||
saveScenario() {
|
||||
if (_.isEmpty(this.scenario.vm)) {
|
||||
alert("Please add at least one VM")
|
||||
|
@ -454,21 +424,13 @@ export default {
|
|||
}
|
||||
// begin write down and verify
|
||||
|
||||
this.errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData, false)
|
||||
// noinspection ExceptionCaughtLocallyJS
|
||||
if (this.errors.length !== 0) {
|
||||
this.translateErrors()
|
||||
alert('Scenario have struct error, save failed!')
|
||||
return;
|
||||
}
|
||||
configurator.writeFile(this.WorkingFolder + 'scenario.xml', scenarioXMLData)
|
||||
.then(() => {
|
||||
stepDone = 1
|
||||
console.log("validate settings...")
|
||||
this.errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData, true)
|
||||
this.errors = configurator.pythonObject.validateScenario(this.board.content, scenarioXMLData)
|
||||
// noinspection ExceptionCaughtLocallyJS
|
||||
if (this.errors.length !== 0) {
|
||||
this.translateErrors()
|
||||
throw new Error("validation failed")
|
||||
}
|
||||
console.log("validation ok")
|
||||
|
@ -482,6 +444,8 @@ export default {
|
|||
writeDone.push(configurator.writeFile(this.WorkingFolder + filename, launchScripts[filename]))
|
||||
}
|
||||
return Promise.all(writeDone)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
})
|
||||
.then((result) => {
|
||||
|
|
|
@ -12,11 +12,13 @@ from scenario_config.xml_loader import XMLLoadStage
|
|||
|
||||
from .pyodide import (
|
||||
convert_result, write_temp_file,
|
||||
# Todo: add debug switch
|
||||
# is_debug,
|
||||
nuc11_board, nuc11_scenario, scenario_xml_schema_path, datachecks_xml_schema_path
|
||||
)
|
||||
|
||||
|
||||
def main(board, scenario, completed_verify=False):
|
||||
def main(board, scenario):
|
||||
pipeline = PipelineEngine(["board_path", "scenario_path", "schema_path", "datachecks_path"])
|
||||
stages = [
|
||||
ValidatorConstructionByFileStage(),
|
||||
|
@ -25,10 +27,11 @@ def main(board, scenario, completed_verify=False):
|
|||
XMLLoadStage("board"),
|
||||
XMLLoadStage("scenario"),
|
||||
DefaultValuePopulatingStage(),
|
||||
SyntacticValidationStage()
|
||||
SemanticValidationStage(),
|
||||
]
|
||||
if completed_verify:
|
||||
stages.append(SemanticValidationStage())
|
||||
#
|
||||
# if is_debug:
|
||||
# stages.append(SyntacticValidationStage())
|
||||
|
||||
pipeline.add_stages(stages)
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
|
@ -47,9 +50,7 @@ def main(board, scenario, completed_verify=False):
|
|||
)
|
||||
pipeline.run(obj)
|
||||
|
||||
validate_result: list = obj.get("syntactic_errors")
|
||||
if completed_verify:
|
||||
validate_result.extend(obj.get("semantic_errors"))
|
||||
validate_result = obj.get("semantic_errors")
|
||||
return convert_result(validate_result)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue