mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-21 13:08:42 +00:00
acrn-config: dynamic configuration for scenario setting and launch setting
config app implements interfaces to dynamically: create new scenario settings based on tempaltes; create new launch settings based on templates; add or delete VMs for scenario settings; add or delete VMs for launch settings; load default scenario or launch settings Tracked-On: #4641 Signed-off-by: Shuang Zheng <shuang.zheng@intel.com Reviewed-by: Victor Sun <victor.sun@intel.com> Acked-by: Terry Zou <terry.zou@intel.com>
This commit is contained in:
parent
a12b746a18
commit
0445c5f826
@ -221,6 +221,20 @@ class XmlConfig:
|
|||||||
dest_node = self._get_dest_node(*args)
|
dest_node = self._get_dest_node(*args)
|
||||||
dest_node.append(elem)
|
dest_node.append(elem)
|
||||||
|
|
||||||
|
def insert_curr_elem(self, index, elem, *args):
|
||||||
|
"""
|
||||||
|
insert elements for current path.
|
||||||
|
:param index: the location for the element to insert.
|
||||||
|
:param elem: the element to insert.
|
||||||
|
:param args: the path of the element.
|
||||||
|
:return: None.
|
||||||
|
"""
|
||||||
|
if self._curr_xml_tree is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
dest_node = self._get_dest_node(*args)
|
||||||
|
dest_node.insert(index, elem)
|
||||||
|
|
||||||
def delete_curr_key(self, *args):
|
def delete_curr_key(self, *args):
|
||||||
"""
|
"""
|
||||||
delete the element by its path.
|
delete the element by its path.
|
||||||
|
@ -10,7 +10,6 @@ $().ready(function(){
|
|||||||
formFile.append("name", file_name);
|
formFile.append("name", file_name);
|
||||||
formFile.append("file", fileObj);
|
formFile.append("file", fileObj);
|
||||||
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "../upload_board_info",
|
url: "../upload_board_info",
|
||||||
data: formFile,
|
data: formFile,
|
||||||
@ -77,7 +76,7 @@ $().ready(function(){
|
|||||||
alert('Scenario setting import successfully with name: '+file_name);
|
alert('Scenario setting import successfully with name: '+file_name);
|
||||||
}
|
}
|
||||||
window.location = 'http://'
|
window.location = 'http://'
|
||||||
+ window.location.host+"/scenario/user_defined_" + file_name;
|
+ window.location.host+"/scenario/" + file_name;
|
||||||
},
|
},
|
||||||
error: function(e){
|
error: function(e){
|
||||||
console.log(e.status);
|
console.log(e.status);
|
||||||
@ -123,7 +122,7 @@ $().ready(function(){
|
|||||||
alert('Launch setting import successfully with name: '+file_name);
|
alert('Launch setting import successfully with name: '+file_name);
|
||||||
}
|
}
|
||||||
window.location = 'http://'
|
window.location = 'http://'
|
||||||
+ window.location.host+"/launch/user_defined_" + file_name;
|
+ window.location.host+"/launch/" + file_name;
|
||||||
},
|
},
|
||||||
error: function(e){
|
error: function(e){
|
||||||
console.log(e.status);
|
console.log(e.status);
|
||||||
@ -177,10 +176,6 @@ $().ready(function(){
|
|||||||
|
|
||||||
$('#remove_scenario').on('click', function() {
|
$('#remove_scenario').on('click', function() {
|
||||||
old_scenario_name = $("#old_scenario_name").text();
|
old_scenario_name = $("#old_scenario_name").text();
|
||||||
if(old_scenario_name.indexOf('user_defined')<0) {
|
|
||||||
alert("Default scenario setting could not be deleted.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var board_info = $("select#board_info").val();
|
var board_info = $("select#board_info").val();
|
||||||
if (board_info==null || board_info=='') {
|
if (board_info==null || board_info=='') {
|
||||||
@ -230,10 +225,6 @@ $().ready(function(){
|
|||||||
|
|
||||||
$('#remove_launch').on('click', function() {
|
$('#remove_launch').on('click', function() {
|
||||||
old_launch_name = $("#old_launch_name").text();
|
old_launch_name = $("#old_launch_name").text();
|
||||||
if(old_launch_name.indexOf('user_defined')<0) {
|
|
||||||
alert("Default launch setting could not be deleted.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var board_info = $("select#board_info").val();
|
var board_info = $("select#board_info").val();
|
||||||
if (board_info==null || board_info=='') {
|
if (board_info==null || board_info=='') {
|
||||||
@ -271,18 +262,109 @@ $().ready(function(){
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#export_scenario_xml').on('click', function() {
|
||||||
|
var dataId = $(this).data('id');
|
||||||
|
$("#save_scenario").data('id', dataId);
|
||||||
|
$('#src_path_row').addClass('hidden');
|
||||||
|
});
|
||||||
|
|
||||||
$('#generate_config_src').on('click', function() {
|
$('#generate_config_src').on('click', function() {
|
||||||
var dataId = $(this).data('id');
|
var dataId = $(this).data('id');
|
||||||
$("#save_scenario").data('id', dataId);
|
$("#save_scenario").data('id', dataId);
|
||||||
|
$('#src_path_row').removeClass('hidden');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#export_launch_xml').on('click', function() {
|
||||||
|
var dataId = $(this).data('id');
|
||||||
|
$("#save_launch").data('id', dataId);
|
||||||
|
$('#src_path_row').addClass('hidden');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
$('#generate_launch_script').on('click', function() {
|
$('#generate_launch_script').on('click', function() {
|
||||||
var dataId = $(this).data('id');
|
var dataId = $(this).data('id');
|
||||||
$("#save_launch").data('id', dataId);
|
$("#save_launch").data('id', dataId);
|
||||||
|
$('#src_path_row').removeClass('hidden');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('a.create_menu').on('click', function() {
|
||||||
|
var type = $(this).data('id');
|
||||||
|
$("#createModalLabel").text("Create a new " + type + " setting");
|
||||||
|
var date = new Date();
|
||||||
|
$("#create_name").val(date.getTime());
|
||||||
|
$("#create_btn").data('id', type);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#create_btn').on('click', function() {
|
||||||
|
var type = $(this).data('id');
|
||||||
|
var create_name = $("#create_name").val();
|
||||||
|
create_setting(type, create_name, create_name, 'create');
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('change', "select#load_scenario_name", function() {
|
||||||
|
$('input#load_scenario_name2').val(this.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('change', "select#load_launch_name", function() {
|
||||||
|
$('input#load_launch_name2').val(this.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#load_scenario_btn').on('click', function() {
|
||||||
|
var type = $(this).data('id');
|
||||||
|
var default_load_name = $("#load_scenario_name").val();
|
||||||
|
var load_name = $("#load_scenario_name2").val();
|
||||||
|
create_setting(type, default_load_name, load_name, 'load')
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#load_launch_btn').on('click', function() {
|
||||||
|
var type = $(this).data('id');
|
||||||
|
var default_load_name = $("#load_launch_name").val();
|
||||||
|
var load_name = $("#load_launch_name2").val();
|
||||||
|
create_setting(type, default_load_name, load_name, 'load')
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', "#add_vm", function() {
|
||||||
|
var curr_vm_id = $(this).data('id');
|
||||||
|
$("#add_vm_submit").data('id', curr_vm_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', "#add_vm_submit", function() {
|
||||||
|
var curr_vm_id = $(this).data('id');
|
||||||
|
save_scenario('add_vm:'+curr_vm_id)
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', "#remove_vm", function() {
|
||||||
|
var remove_confirm_message = 'Do you want to delete this VM?'
|
||||||
|
if(confirm(remove_confirm_message)) {
|
||||||
|
var curr_vm_id = $(this).data('id');
|
||||||
|
save_scenario('remove_vm:'+curr_vm_id)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', "#add_launch_vm", function() {
|
||||||
|
var curr_vm_id = $(this).data('id');
|
||||||
|
$("#add_launch_submit").data('id', curr_vm_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', "#add_launch_submit", function() {
|
||||||
|
var curr_vm_id = $(this).data('id');
|
||||||
|
save_launch('add_vm:'+curr_vm_id)
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#add_launch_script').on('click', function() {
|
||||||
|
var curr_vm_id = $(this).data('id');
|
||||||
|
$("#add_launch_submit").data('id', curr_vm_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', "#remove_launch_vm", function() {
|
||||||
|
var remove_confirm_message = 'Do you want to delete this VM?'
|
||||||
|
if(confirm(remove_confirm_message)) {
|
||||||
|
var curr_vm_id = $(this).data('id');
|
||||||
|
save_launch('remove_vm:'+curr_vm_id)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("select[ID$='vuart:id=1,base']").change(function(){
|
$("select[ID$='vuart:id=1,base']").change(function(){
|
||||||
|
|
||||||
var id = $(this).attr('id');
|
var id = $(this).attr('id');
|
||||||
var value = $(this).val();
|
var value = $(this).val();
|
||||||
show_com_target(id, value);
|
show_com_target(id, value);
|
||||||
@ -292,21 +374,23 @@ $().ready(function(){
|
|||||||
var id = $(item).attr('id');
|
var id = $(item).attr('id');
|
||||||
var value = $(item).val();
|
var value = $(item).val();
|
||||||
show_com_target(id, value);
|
show_com_target(id, value);
|
||||||
})
|
});
|
||||||
|
|
||||||
$(document).on('click', "button:contains('+')", function() {
|
$(document).on('click', "button:contains('+')", function() {
|
||||||
if($(this).text() != '+')
|
if($(this).text() != '+')
|
||||||
return;
|
return;
|
||||||
var add_vcpu_id = $(this).attr('id');
|
var curr_item_id = $(this).attr('id');
|
||||||
var id = add_vcpu_id.replace('add_vcpu_', '');
|
var curr_id = curr_item_id.substr(curr_item_id.lastIndexOf('_')+1);
|
||||||
var config_item = $(this).parent().parent();
|
var config_item = $(this).parent().parent();
|
||||||
var config_item_added = config_item.clone();
|
var config_item_added = config_item.clone();
|
||||||
var id_added = (parseInt(id)+1).toString();
|
var id_added = (parseInt(curr_id)+1).toString();
|
||||||
config_item_added.find("button:contains('+')").attr('id', 'add_vcpu_'+id_added);
|
var id_pre_added = curr_item_id.substr(0, curr_item_id.lastIndexOf('_'));
|
||||||
config_item_added.find("button:contains('-')").attr('id', 'remove_vcpu_'+id_added);
|
config_item_added.find("button:contains('+')").attr('id', id_pre_added+'_'+id_added);
|
||||||
|
config_item_added.find("button:contains('-')").attr('id', id_pre_added.replace('add_', 'remove_')+'_'+id_added);
|
||||||
config_item_added.find("button:contains('-')").prop("disabled", false);
|
config_item_added.find("button:contains('-')").prop("disabled", false);
|
||||||
config_item_added.find("label:first").text("");
|
config_item_added.find("label:first").text("");
|
||||||
config_item_added.find('.bootstrap-select').replaceWith(function() { return $('select', this); });
|
config_item_added.find('.bootstrap-select').replaceWith(function() { return $('select', this); });
|
||||||
|
config_item_added.find('.selectpicker').val('default').selectpicker('deselectAll');;
|
||||||
config_item_added.find('.selectpicker').selectpicker('render');
|
config_item_added.find('.selectpicker').selectpicker('render');
|
||||||
config_item_added.insertAfter(config_item);
|
config_item_added.insertAfter(config_item);
|
||||||
});
|
});
|
||||||
@ -358,6 +442,80 @@ function show_com_target(id, value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_setting(type, default_name, name, mode){
|
||||||
|
var board_info = $("text#board_type").text();
|
||||||
|
if (board_info==null || board_info=='') {
|
||||||
|
alert("Please select one board info before this operation.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
create_config = {
|
||||||
|
board_info: board_info,
|
||||||
|
type: type,
|
||||||
|
default_name: default_name,
|
||||||
|
create_name: name,
|
||||||
|
mode: mode
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type : "POST",
|
||||||
|
contentType: "application/json;charset=UTF-8",
|
||||||
|
url : "../check_setting_exist",
|
||||||
|
data : JSON.stringify(create_config),
|
||||||
|
success : function(result) {
|
||||||
|
exist = result.exist
|
||||||
|
create_flag = true
|
||||||
|
if(exist == "yes") {
|
||||||
|
overwirte_confirm_message = 'Setting name: ' + create_config['create_name'] + ' existed in ' +
|
||||||
|
'acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/user_defined/.\n'+
|
||||||
|
'Do you want to overwrite it?\nClick OK to overwrite it; click Cancel to rename it.'
|
||||||
|
if(!confirm(overwirte_confirm_message)) {
|
||||||
|
create_flag = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(create_flag == true) {
|
||||||
|
$.ajax({
|
||||||
|
type : "POST",
|
||||||
|
contentType: "application/json;charset=UTF-8",
|
||||||
|
url : "../create_setting",
|
||||||
|
data : JSON.stringify(create_config),
|
||||||
|
success : function(result) {
|
||||||
|
console.log(result);
|
||||||
|
status = result.status
|
||||||
|
setting = result.setting
|
||||||
|
error_list = result.error_list
|
||||||
|
if (status == 'success' && (JSON.stringify(error_list)=='{}' || JSON.stringify(error_list)=='null')) {
|
||||||
|
alert('create a new setting successfully.');
|
||||||
|
} else {
|
||||||
|
alert('create a new setting failed. \nError list:\n'+JSON.stringify(error_list));
|
||||||
|
}
|
||||||
|
var href = window.location.href
|
||||||
|
if(href.endsWith("/scenario") || href.endsWith("/launch")) {
|
||||||
|
window.location = type + "/" + setting;
|
||||||
|
} else {
|
||||||
|
window.location = "../" + type + "/" + setting;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error : function(e){
|
||||||
|
$("#create_modal").modal("hide");
|
||||||
|
$("#load_scenario_modal").modal("hide");
|
||||||
|
$("#load_launch_modal").modal("hide");
|
||||||
|
console.log(e.status);
|
||||||
|
console.log(e.responseText);
|
||||||
|
alert(e.status+'\n'+e.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error : function(e){
|
||||||
|
console.log(e.status);
|
||||||
|
console.log(e.responseText);
|
||||||
|
alert(e.status+'\n'+e.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function save_scenario(generator=null){
|
function save_scenario(generator=null){
|
||||||
var board_info = $("text#board_type").text();
|
var board_info = $("text#board_type").text();
|
||||||
@ -367,39 +525,44 @@ function save_scenario(generator=null){
|
|||||||
}
|
}
|
||||||
|
|
||||||
scenario_config = {
|
scenario_config = {
|
||||||
old_scenario_name: $("#old_scenario_name").text(),
|
old_scenario_name: $("#old_scenario_name").text(),
|
||||||
new_scenario_name: $("#new_scenario_name").val(),
|
generator: generator
|
||||||
generator: generator
|
}
|
||||||
}
|
|
||||||
|
if(generator!=null && generator.indexOf('add_vm:')==0) {
|
||||||
|
scenario_config['new_scenario_name'] = $("#new_scenario_name2").val()
|
||||||
|
} else if(generator!=null && generator.indexOf('remove_vm:')==0) {
|
||||||
|
scenario_config['new_scenario_name'] = $("#old_scenario_name").text()
|
||||||
|
} else {
|
||||||
|
scenario_config['new_scenario_name'] = $("#new_scenario_name").val()
|
||||||
|
}
|
||||||
|
|
||||||
$("input").each(function(){
|
$("input").each(function(){
|
||||||
var id = $(this).attr('id');
|
var id = $(this).attr('id');
|
||||||
var value = $(this).val();
|
var value = $(this).val();
|
||||||
if(id!='new_scenario_name' && id!='board_info_file'
|
if(id!='new_scenario_name' && id!='new_scenario_name2' && id!='board_info_file' && id!='board_info_upload'
|
||||||
&& id!='board_info_upload' && id!="scenario_file") {
|
&& id!='scenario_file' && id!='create_name' && id!='load_scenario_name2' && id!='load_launch_name2'
|
||||||
|
&& id!='src_path') {
|
||||||
scenario_config[id] = value;
|
scenario_config[id] = value;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
$("textarea").each(function(){
|
$("textarea").each(function(){
|
||||||
var id = $(this).attr('id');
|
var id = $(this).attr('id');
|
||||||
var value = $(this).val();
|
var value = $(this).val();
|
||||||
if(id!='new_scenario_name' && id!='board_info_file'
|
scenario_config[id] = value;
|
||||||
&& id!='board_info_upload' && id!="scenario_file") {
|
|
||||||
scenario_config[id] = value;
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$("select").each(function(){
|
$("select").each(function(){
|
||||||
var id = $(this).attr('id');
|
var id = $(this).attr('id');
|
||||||
var value = $(this).val();
|
var value = $(this).val();
|
||||||
if(id.indexOf('pcpu_id')>=0) {
|
if(id.indexOf('pcpu_id')>=0 || id.indexOf('pci_dev')>=0) {
|
||||||
if(id in scenario_config) {
|
if(id in scenario_config) {
|
||||||
scenario_config[id].push(value);
|
scenario_config[id].push(value);
|
||||||
} else {
|
} else {
|
||||||
scenario_config[id] = [value];
|
scenario_config[id] = [value];
|
||||||
}
|
}
|
||||||
} else if(id!='board_info') {
|
} else if(id!='board_info' && id!='load_scenario_name' && id!='load_launch_name') {
|
||||||
scenario_config[id] = value;
|
scenario_config[id] = value;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -407,67 +570,111 @@ function save_scenario(generator=null){
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
type : "POST",
|
type : "POST",
|
||||||
contentType: "application/json;charset=UTF-8",
|
contentType: "application/json;charset=UTF-8",
|
||||||
url : "../save_scenario",
|
url : "../check_setting_exist",
|
||||||
data : JSON.stringify(scenario_config),
|
data : JSON.stringify(scenario_config),
|
||||||
success : function(result) {
|
success : function(result) {
|
||||||
error_list = result.error_list;
|
exist = result.exist
|
||||||
status = result.status;
|
create_flag = true
|
||||||
var no_err = true;
|
if(exist == "yes") {
|
||||||
$.each(error_list, function(index,item){
|
overwirte_confirm_message = 'Setting name: ' + scenario_config['create_name'] + ' existed in ' +
|
||||||
no_err = false;
|
'acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/user_defined/.\n'+
|
||||||
var jquerySpecialChars = ["~", "`", "@", "#", "%", "&", "=", "'", "\"",
|
'Do you want to overwrite it?\nClick OK to overwrite it; click Cancel to rename it.'
|
||||||
":", ";", "<", ">", ",", "/"];
|
if(!confirm(overwirte_confirm_message)) {
|
||||||
for (var i = 0; i < jquerySpecialChars.length; i++) {
|
create_flag = false
|
||||||
index = index.replace(new RegExp(jquerySpecialChars[i],
|
|
||||||
"g"), "\\" + jquerySpecialChars[i]);
|
|
||||||
}
|
|
||||||
$("#"+index).parents(".form-group").addClass("has-error");
|
|
||||||
$("#"+index+"_err").text(item);
|
|
||||||
})
|
|
||||||
if(no_err == true && status == 'success') {
|
|
||||||
file_name = result.file_name;
|
|
||||||
validate_message = 'Scenario setting saved successfully with name: '
|
|
||||||
+file_name+'\ninto acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/user_defined/.'
|
|
||||||
if(result.rename==true) {
|
|
||||||
validate_message = 'Scenario setting existed, saved successfully with a new name: '
|
|
||||||
+file_name+'\ninto acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/user_defined/.';
|
|
||||||
}
|
|
||||||
if(generator=="generate_config_src") {
|
|
||||||
generator_config = {
|
|
||||||
type: generator,
|
|
||||||
board_info: $("select#board_info").val(),
|
|
||||||
board_setting: "board_setting",
|
|
||||||
scenario_setting: file_name,
|
|
||||||
}
|
|
||||||
$.ajax({
|
|
||||||
type : "POST",
|
|
||||||
contentType: "application/json;charset=UTF-8",
|
|
||||||
url : "../generate_src",
|
|
||||||
data : JSON.stringify(generator_config),
|
|
||||||
success : function(result) {
|
|
||||||
console.log(result);
|
|
||||||
status = result.status
|
|
||||||
error_list = result.error_list
|
|
||||||
if (status == 'success' && (JSON.stringify(error_list)=='{}' || JSON.stringify(error_list)=='null')) {
|
|
||||||
alert(generator+' successfully.');
|
|
||||||
} else {
|
|
||||||
alert(generator+' failed. \nError list:\n'+JSON.stringify(error_list));
|
|
||||||
}
|
|
||||||
window.location = "./user_defined_" + file_name;
|
|
||||||
},
|
|
||||||
error : function(e){
|
|
||||||
console.log(e.status);
|
|
||||||
console.log(e.responseText);
|
|
||||||
alert(e.status+'\n'+e.responseText);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert(validate_message);
|
|
||||||
window.location = "./user_defined_" + file_name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(status != 'success') {
|
if(create_flag == true) {
|
||||||
alert(JSON.stringify(error_list));
|
$.ajax({
|
||||||
|
type : "POST",
|
||||||
|
contentType: "application/json;charset=UTF-8",
|
||||||
|
url : "../save_scenario",
|
||||||
|
data : JSON.stringify(scenario_config),
|
||||||
|
success : function(result) {
|
||||||
|
error_list = result.error_list;
|
||||||
|
status = result.status;
|
||||||
|
var no_err = true;
|
||||||
|
$.each(error_list, function(index,item){
|
||||||
|
no_err = false;
|
||||||
|
var jquerySpecialChars = ["~", "`", "@", "#", "%", "&", "=", "'", "\"",
|
||||||
|
":", ";", "<", ">", ",", "/"];
|
||||||
|
for (var i = 0; i < jquerySpecialChars.length; i++) {
|
||||||
|
index = index.replace(new RegExp(jquerySpecialChars[i],
|
||||||
|
"g"), "\\" + jquerySpecialChars[i]);
|
||||||
|
}
|
||||||
|
$("#"+index).parents(".form-group").addClass("has-error");
|
||||||
|
$("#"+index+"_err").text(item);
|
||||||
|
})
|
||||||
|
if(no_err == true && status == 'success') {
|
||||||
|
file_name = result.file_name;
|
||||||
|
validate_message = 'Scenario setting saved successfully with name: '
|
||||||
|
+file_name+'\ninto acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/user_defined/.'
|
||||||
|
if(result.rename==true) {
|
||||||
|
validate_message = 'Scenario setting existed, saved successfully with a new name: '
|
||||||
|
+file_name+'\ninto acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/user_defined/.';
|
||||||
|
}
|
||||||
|
if(generator=="generate_config_src") {
|
||||||
|
var src_path = $("input#src_path").val();
|
||||||
|
generate_flag = true;
|
||||||
|
if(src_path == null || src_path == '') {
|
||||||
|
overwirte_confirm_message = 'The Source Path for configuration files is not set.\n' +
|
||||||
|
'Do you want to generate them into the default path: hypervisor/arch/x86/configs/ and hypervisor/scenarios/,\n'+
|
||||||
|
'and overwrite the old ones?\nClick OK to overwrite them; click Cancel to edit the Source Path.'
|
||||||
|
if(!confirm(overwirte_confirm_message)) {
|
||||||
|
generate_flag = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(generate_flag) {
|
||||||
|
generator_config = {
|
||||||
|
type: generator,
|
||||||
|
board_info: $("select#board_info").val(),
|
||||||
|
board_setting: "board_setting",
|
||||||
|
scenario_setting: file_name,
|
||||||
|
src_path: src_path,
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
type : "POST",
|
||||||
|
contentType: "application/json;charset=UTF-8",
|
||||||
|
url : "../generate_src",
|
||||||
|
data : JSON.stringify(generator_config),
|
||||||
|
success : function(result) {
|
||||||
|
console.log(result);
|
||||||
|
status = result.status
|
||||||
|
error_list = result.error_list
|
||||||
|
if (status == 'success' && (JSON.stringify(error_list)=='{}' || JSON.stringify(error_list)=='null')) {
|
||||||
|
if(src_path==null || src_path=='') {
|
||||||
|
alert(generator+' successfully into hypervisor/arch/x86/configs/ and hypervisor/scenarios/ ');
|
||||||
|
} else {
|
||||||
|
alert(generator+' successfully into '+src_path);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert(generator+' failed. \nError list:\n'+JSON.stringify(error_list));
|
||||||
|
}
|
||||||
|
window.location = "./" + file_name;
|
||||||
|
},
|
||||||
|
error : function(e){
|
||||||
|
console.log(e.status);
|
||||||
|
console.log(e.responseText);
|
||||||
|
alert(e.status+'\n'+e.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert(validate_message);
|
||||||
|
window.location = "./" + file_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#save_modal").modal("hide");
|
||||||
|
alert(JSON.stringify(error_list));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error : function(e){
|
||||||
|
$("#save_modal").modal("hide");
|
||||||
|
console.log(e.status);
|
||||||
|
console.log(e.responseText);
|
||||||
|
alert(e.status+'\n'+e.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error : function(e){
|
error : function(e){
|
||||||
@ -487,14 +694,22 @@ function save_launch(generator=null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
launch_config = {
|
launch_config = {
|
||||||
old_launch_name: $("#old_launch_name").text(),
|
old_launch_name: $("#old_launch_name").text(),
|
||||||
new_launch_name: $("#new_launch_name").val(),
|
scenario_name: scenario_name,
|
||||||
scenario_name: scenario_name
|
generator: generator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(generator!=null && generator.indexOf('add_vm:')==0) {
|
||||||
|
launch_config['new_launch_name'] = $("#new_launch_name2").val()
|
||||||
|
} else if(generator!=null && generator.indexOf('remove_vm:')==0) {
|
||||||
|
launch_config['new_launch_name'] = $("#old_launch_name").text()
|
||||||
|
} else {
|
||||||
|
launch_config['new_launch_name'] = $("#new_launch_name").val()
|
||||||
|
}
|
||||||
|
|
||||||
$("input").each(function(){
|
$("input").each(function(){
|
||||||
var id = $(this).attr('id');
|
var id = $(this).attr('id');
|
||||||
var value = $(this).val();
|
var value = $(this).val();
|
||||||
|
|
||||||
if(id.indexOf('virtio_devices,network')>=0 || id.indexOf('virtio_devices,block')>=0
|
if(id.indexOf('virtio_devices,network')>=0 || id.indexOf('virtio_devices,block')>=0
|
||||||
|| id.indexOf('virtio_devices,input')>=0) {
|
|| id.indexOf('virtio_devices,input')>=0) {
|
||||||
@ -503,98 +718,145 @@ function save_launch(generator=null) {
|
|||||||
} else {
|
} else {
|
||||||
launch_config[id] = [value];
|
launch_config[id] = [value];
|
||||||
}
|
}
|
||||||
} else if(id!='new_launch_name' && id!='board_info_file'
|
} else if(id!='new_launch_name' && id!='new_launch_name2' && id!='board_info_file' && id!='board_info_upload'
|
||||||
&& id!='board_info_upload' && id!='scenario_name'
|
&& id!="launch_file" && id!='create_name' && id!='load_scenario_name2' && id!='load_launch_name2'
|
||||||
&& id!="launch_file") {
|
&& id!='src_path') {
|
||||||
launch_config[id] = value;
|
launch_config[id] = value;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
$("select").each(function(){
|
$("select").each(function(){
|
||||||
var id = $(this).attr('id');
|
var id = $(this).attr('id');
|
||||||
var value = $(this).val();
|
var value = $(this).val();
|
||||||
if(id!='board_info') {
|
if(id.indexOf('pcpu_id')>=0 || id.indexOf('pci_dev')>=0) {
|
||||||
|
if(id in launch_config) {
|
||||||
|
launch_config[id].push(value);
|
||||||
|
} else {
|
||||||
|
launch_config[id] = [value];
|
||||||
|
}
|
||||||
|
} else if(id!='board_info' && id!='load_scenario_name' && id!='load_launch_name') {
|
||||||
launch_config[id] = value;
|
launch_config[id] = value;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
$("textarea").each(function(){
|
$("textarea").each(function(){
|
||||||
var id = $(this).attr('id');
|
var id = $(this).attr('id');
|
||||||
var value = $(this).val();
|
var value = $(this).val();
|
||||||
if(id!='new_scenario_name' && id!='board_info_file'
|
launch_config[id] = value;
|
||||||
&& id!='board_info_upload' && id!="scenario_file") {
|
|
||||||
launch_config[id] = value;
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type : "POST",
|
type : "POST",
|
||||||
contentType: "application/json;charset=UTF-8",
|
contentType: "application/json;charset=UTF-8",
|
||||||
url : "../save_launch",
|
url : "../check_setting_exist",
|
||||||
data : JSON.stringify(launch_config),
|
data : JSON.stringify(launch_config),
|
||||||
success : function(result) {
|
success : function(result) {
|
||||||
console.log(result);
|
exist = result.exist
|
||||||
error_list = result.error_list;
|
create_flag = true
|
||||||
status = result.status;
|
if(exist == "yes") {
|
||||||
|
overwirte_confirm_message = 'Setting name: ' + launch_config['create_name'] + ' existed in ' +
|
||||||
var no_err = true;
|
'acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/user_defined/.\n'+
|
||||||
$.each(error_list, function(index,item){
|
'Do you want to overwrite it?\nClick OK to overwrite it; click Cancel to rename it.'
|
||||||
no_err = false;
|
if(!confirm(overwirte_confirm_message)) {
|
||||||
var jquerySpecialChars = ["~", "`", "@", "#", "%", "&", "=", "'", "\"",
|
create_flag = false
|
||||||
":", ";", "<", ">", ",", "/"];
|
|
||||||
for (var i = 0; i < jquerySpecialChars.length; i++) {
|
|
||||||
index = index.replace(new RegExp(jquerySpecialChars[i],
|
|
||||||
"g"), "\\" + jquerySpecialChars[i]);
|
|
||||||
}
|
|
||||||
$("#"+index).parents(".form-group").addClass("has-error");
|
|
||||||
$("#"+index+"_err").text(item);
|
|
||||||
})
|
|
||||||
if(no_err == true && status == 'success') {
|
|
||||||
file_name = result.file_name;
|
|
||||||
validate_message = 'Launch setting saved successfully with name: '
|
|
||||||
+file_name+'\nto acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/user_defined/.'
|
|
||||||
if(result.rename==true) {
|
|
||||||
validate_message = 'Launch setting existed, saved successfully with a new name: '
|
|
||||||
+file_name+'\nto acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/user_defined/.';
|
|
||||||
}
|
|
||||||
if(generator != null) {
|
|
||||||
generator_config = {
|
|
||||||
type: generator,
|
|
||||||
board_info: $("select#board_info").val(),
|
|
||||||
board_setting: "board_setting",
|
|
||||||
scenario_setting: $("select#scenario_name").val(),
|
|
||||||
launch_setting: file_name,
|
|
||||||
}
|
|
||||||
$.ajax({
|
|
||||||
type : "POST",
|
|
||||||
contentType: "application/json;charset=UTF-8",
|
|
||||||
url : "../generate_src",
|
|
||||||
data : JSON.stringify(generator_config),
|
|
||||||
success : function(result) {
|
|
||||||
console.log(result);
|
|
||||||
status = result.status
|
|
||||||
error_list = result.error_list
|
|
||||||
if (status == 'success' && (JSON.stringify(error_list)=='{}' || JSON.stringify(error_list)=='null')) {
|
|
||||||
alert(generator+' successfully into '+
|
|
||||||
'acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/output/.');
|
|
||||||
} else {
|
|
||||||
alert(generator+' failed. \nError list:\n'+JSON.stringify(error_list));
|
|
||||||
}
|
|
||||||
window.location = "./user_defined_" + file_name;
|
|
||||||
},
|
|
||||||
error : function(e){
|
|
||||||
console.log(e.status);
|
|
||||||
console.log(e.responseText);
|
|
||||||
alert(e.status+'\n'+e.responseText);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert(validate_message);
|
|
||||||
window.location = "./user_defined_" + file_name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(status != 'success') {
|
if(create_flag == true) {
|
||||||
alert(JSON.stringify(error_list));
|
$.ajax({
|
||||||
|
type : "POST",
|
||||||
|
contentType: "application/json;charset=UTF-8",
|
||||||
|
url : "../save_launch",
|
||||||
|
data : JSON.stringify(launch_config),
|
||||||
|
success : function(result) {
|
||||||
|
console.log(result);
|
||||||
|
error_list = result.error_list;
|
||||||
|
status = result.status;
|
||||||
|
|
||||||
|
var no_err = true;
|
||||||
|
$.each(error_list, function(index,item){
|
||||||
|
no_err = false;
|
||||||
|
var jquerySpecialChars = ["~", "`", "@", "#", "%", "&", "=", "'", "\"",
|
||||||
|
":", ";", "<", ">", ",", "/"];
|
||||||
|
for (var i = 0; i < jquerySpecialChars.length; i++) {
|
||||||
|
index = index.replace(new RegExp(jquerySpecialChars[i],
|
||||||
|
"g"), "\\" + jquerySpecialChars[i]);
|
||||||
|
}
|
||||||
|
$("#"+index).parents(".form-group").addClass("has-error");
|
||||||
|
$("#"+index+"_err").text(item);
|
||||||
|
})
|
||||||
|
if(no_err == true && status == 'success') {
|
||||||
|
file_name = result.file_name;
|
||||||
|
validate_message = 'Launch setting saved successfully with name: '
|
||||||
|
+file_name+'\nto acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/user_defined/.'
|
||||||
|
if(result.rename==true) {
|
||||||
|
validate_message = 'Launch setting existed, saved successfully with a new name: '
|
||||||
|
+file_name+'\nto acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/user_defined/.';
|
||||||
|
}
|
||||||
|
if(generator == 'generate_launch_script') {
|
||||||
|
var src_path = $("input#src_path").val();
|
||||||
|
generate_flag = true;
|
||||||
|
if(src_path == null || src_path == '') {
|
||||||
|
overwirte_confirm_message = 'The Source Path for launch scripts is not set.\n' +
|
||||||
|
'Do you want to generate them into the default path: misc/acrn-config/xmls/config-xmls/'+board_info+'/output/,\n'+
|
||||||
|
'and overwrite the old ones?\nClick OK to overwrite them; click Cancel to edit the Source Path.'
|
||||||
|
if(!confirm(overwirte_confirm_message)) {
|
||||||
|
generate_flag = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(generate_flag) {
|
||||||
|
generator_config = {
|
||||||
|
type: generator,
|
||||||
|
board_info: $("select#board_info").val(),
|
||||||
|
board_setting: "board_setting",
|
||||||
|
scenario_setting: $("select#scenario_name").val(),
|
||||||
|
launch_setting: file_name,
|
||||||
|
src_path: src_path,
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
type : "POST",
|
||||||
|
contentType: "application/json;charset=UTF-8",
|
||||||
|
url : "../generate_src",
|
||||||
|
data : JSON.stringify(generator_config),
|
||||||
|
success : function(result) {
|
||||||
|
console.log(result);
|
||||||
|
status = result.status
|
||||||
|
error_list = result.error_list
|
||||||
|
if (status == 'success' && (JSON.stringify(error_list)=='{}' || JSON.stringify(error_list)=='null')) {
|
||||||
|
if(src_path==null || src_path==='') {
|
||||||
|
alert(generator+' successfully into '+
|
||||||
|
'acrn-hypervisor/misc/acrn-config/xmls/config-xmls/'+board_info+'/output/.');
|
||||||
|
} else {
|
||||||
|
alert(generator+' successfully into '+src_path);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert(generator+' failed. \nError list:\n'+JSON.stringify(error_list));
|
||||||
|
}
|
||||||
|
window.location = "./" + file_name;
|
||||||
|
},
|
||||||
|
error : function(e){
|
||||||
|
console.log(e.status);
|
||||||
|
console.log(e.responseText);
|
||||||
|
alert(e.status+'\n'+e.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert(validate_message);
|
||||||
|
window.location = "./" + file_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#save_modal").modal("hide");
|
||||||
|
alert(JSON.stringify(error_list));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error : function(e){
|
||||||
|
$("#save_modal").modal("hide");
|
||||||
|
console.log(e.status);
|
||||||
|
console.log(e.responseText);
|
||||||
|
alert(e.status+'\n'+e.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error : function(e){
|
error : function(e){
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
* {
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.428;
|
||||||
|
}
|
||||||
|
|
||||||
ul.nav li.dropdown:hover ul.dropdown-menu {
|
ul.nav li.dropdown:hover ul.dropdown-menu {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,104 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<div class="modal fade" id="create_modal" tabindex="-1" role="dialog" aria-labelledby="createModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h4 class="modal-title" id="createModalLabel"></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="create_name" class="col-sm-3 control-label">Name: </label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="text" class="form-control" id="create_name"
|
||||||
|
value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
|
<button type="button" id="create_btn" data-id="" class="btn btn-primary">OK
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal fade" id="load_scenario_modal" tabindex="-1" role="dialog" aria-labelledby="loadScenarioModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title" id="loadScenarioModalLabel">Load Scenario Setting</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="load_scenario_name" class="col-sm-3 control-label">Default Scenario Setting: </label>
|
||||||
|
<div class="dropdown col-sm-6">
|
||||||
|
<select class="selectpicker" data-width="auto" id="load_scenario_name">
|
||||||
|
{% if scenarios[0] %}
|
||||||
|
{% for sc in scenarios[0] %}
|
||||||
|
<option value="{{sc}}">{{sc}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="load_scenario_name2" class="col-sm-3 control-label">Scenario Setting Name: </label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="text" class="form-control" id="load_scenario_name2"
|
||||||
|
value="{{scenarios[0][0] if scenarios[0] else ''}}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
|
<button type="button" id="load_scenario_btn" data-id="scenario" class="btn btn-primary">OK
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal fade" id="load_launch_modal" tabindex="-1" role="dialog" aria-labelledby="loadLaunchModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title" id="loadLaunchModalLabel">Load Launch setting</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="load_launch_name" class="col-sm-3 control-label">Default Launch Setting: </label>
|
||||||
|
<div class="dropdown col-sm-6">
|
||||||
|
<select class="selectpicker" data-width="auto" id="load_launch_name">
|
||||||
|
{% if launches[0] %}
|
||||||
|
{% for lc in launches[0] %}
|
||||||
|
<option value="{{lc}}">{{lc}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="load_launch_name2" class="col-sm-3 control-label">Launch Setting Name: </label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="text" class="form-control" id="load_launch_name2"
|
||||||
|
value="{{launches[0][0] if launches[0] else ''}}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
|
<button type="button" id="load_launch_btn" data-id="launch" class="btn btn-primary">OK
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<nav class="navbar navbar-inverse">
|
<nav class="navbar navbar-inverse">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
@ -26,13 +124,13 @@
|
|||||||
Scenario Setting <span class="caret"></span></a>
|
Scenario Setting <span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
{% if scenarios[0] %}
|
{% if scenarios[0] %}
|
||||||
<small class="text-muted">default</small>
|
<li><a href="" data-toggle="modal" data-target="#create_modal" class="create_menu"
|
||||||
{% for sc in scenarios[0] %}
|
data-id="scenario">Create a new scenario</a></li>
|
||||||
<li><a href="{{ url_for('CONFIG_APP.scenario', scenario_name=sc) }}">{{sc}}</a></li>
|
<li><a href="" data-toggle="modal" data-target="#load_scenario_modal" class="load_menu"
|
||||||
{% endfor %}
|
data-id="scenario">Load a default scenario</a></li>
|
||||||
<small class="text-muted">user-defined</small>
|
<small class="text-muted">scenario setting list</small>
|
||||||
{% for sc in scenarios[1] %}
|
{% for sc in scenarios[1] %}
|
||||||
<li><a href="{{ url_for('CONFIG_APP.scenario', scenario_name='user_defined_'+sc) }}">{{sc}}</a></li>
|
<li><a href="{{ url_for('CONFIG_APP.scenario', scenario_name=sc) }}">{{sc}}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<text class="form-control" id="err_msg" data-toggle="tooltip"
|
<text class="form-control" id="err_msg" data-toggle="tooltip"
|
||||||
@ -46,13 +144,13 @@
|
|||||||
class="caret"></span></a>
|
class="caret"></span></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
{% if launches[0] %}
|
{% if launches[0] %}
|
||||||
<small class="text-muted">default</small>
|
<li><a href="" data-toggle="modal" data-target="#create_modal" class="create_menu"
|
||||||
{% for lc in launches[0] %}
|
data-id="launch">Create a new Launch script</a></li>
|
||||||
<li><a href="{{ url_for('CONFIG_APP.launch', launch_name=lc) }}">{{lc}}</a></li>
|
<li><a href="" data-toggle="modal" data-target="#load_launch_modal" class="load_menu"
|
||||||
{% endfor %}
|
data-id="launch">Load a default launch script</a></li>
|
||||||
<small class="text-muted">user-defined</small>
|
<small class="text-muted">launch setting list</small>
|
||||||
{% for lc in launches[1] %}
|
{% for lc in launches[1] %}
|
||||||
<li><a href="{{ url_for('CONFIG_APP.launch', launch_name='user_defined_'+lc) }}">{{lc}}</a></li>
|
<li><a href="{{ url_for('CONFIG_APP.launch', launch_name=lc) }}">{{lc}}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<text class="form-control" id="err_msg" data-toggle="tooltip"
|
<text class="form-control" id="err_msg" data-toggle="tooltip"
|
||||||
@ -64,13 +162,13 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<form action="" enctype="multipart/form-data" method='POST'>
|
<form class="form-horizontal" action="" enctype="multipart/form-data" method='POST'>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="board_info" class="col-sm-1 control-label" style="text-align: left;">Board info:</label>
|
<label class="col-sm-1 control-label" style="text-align: left;"> Board info:</label>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-2">
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<select class="selectpicker" id="board_info">
|
<select class="selectpicker" id="board_info">
|
||||||
<option style="display:none">
|
<option disabled selected value> -- Select an option -- </option>
|
||||||
{% for bi in board_info_list %}
|
{% for bi in board_info_list %}
|
||||||
{% if bi==board_info %}
|
{% if bi==board_info %}
|
||||||
<option value="{{bi}}" selected="selected">{{bi}}</option>
|
<option value="{{bi}}" selected="selected">{{bi}}</option>
|
||||||
@ -81,7 +179,8 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<text class="col-sm-2" id="board_type">{{board_type if board_type != None else ''}}</text>
|
<label class="col-sm-1 control-label"> Board type:</label>
|
||||||
|
<text class="col-sm-2 control-label" id="board_type" style="text-align: left;">{{board_type if board_type != None else ''}}</text>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<form action="" enctype="multipart/form-data" method='POST'>
|
<form action="" enctype="multipart/form-data" method='POST'>
|
||||||
<label for="board_info_file" class="custom-file-upload btn btn-primary" id="board_info_file2"
|
<label for="board_info_file" class="custom-file-upload btn btn-primary" id="board_info_file2"
|
||||||
@ -93,6 +192,12 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-1"></label>
|
||||||
|
<text class="col-sm-2 control-label" id="bios_info" style="white-space: pre-line">{{bios_info if bios_info != None else ''}}</text>
|
||||||
|
<label class="col-sm-1"></label>
|
||||||
|
<text class="col-sm-2" id="base_board_info" style="white-space: pre-line">{{base_board_info if base_board_info != None else ''}}</text>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<hr class="col-sm-12">
|
<hr class="col-sm-12">
|
||||||
|
|
||||||
|
@ -10,18 +10,62 @@
|
|||||||
<h4 class="modal-title" id="myModalLabel">Save as</h4>
|
<h4 class="modal-title" id="myModalLabel">Save as</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="form-group">
|
<div class="form-group row">
|
||||||
<label for="new_launch_name" class="col-sm-3 control-label">Launch: </label>
|
<label for="new_launch_name" class="col-sm-3 control-label">Launch Name: </label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input type="text" class="form-control" id="new_launch_name"
|
<input type="text" class="form-control" id="new_launch_name"
|
||||||
value={{launch[13:] if launch.startswith('user_defined_') else launch}}>
|
value={{launch}}>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row hidden" id="src_path_row">
|
||||||
|
<label for="src_path" class="col-sm-3 control-label"
|
||||||
|
title="the relative path of acrn-hypervisor; if no path is specified,
|
||||||
|
the launch scripts will be generated into misc/acrn-config/xmls/config-xmls/[board]/output and overwirte the previous files.">
|
||||||
|
Source Path: </label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="text" class="form-control" id="src_path" value=""
|
||||||
|
placeholder="input the path to generate launch scripts">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
<button type="button" id="remove_launch" class="btn btn-default" data-dismiss="modal">Remove</button>
|
<button type="button" id="remove_launch" class="btn btn-default" data-dismiss="modal">Remove</button>
|
||||||
<button type="button" id="save_launch" data-id="" class="btn btn-primary" data-dismiss="modal">Submit
|
<button type="button" id="save_launch" data-id="" class="btn btn-primary">Submit
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal fade" id="add_launch_modal" tabindex="-1" role="dialog" aria-labelledby="addlaunchModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h4 class="modal-title" id="addlaunchModalLabel">Add a new VM</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="add_launch_type" class="col-sm-3 control-label">VM type: </label>
|
||||||
|
<div class="dropdown col-sm-6">
|
||||||
|
<select class="selectpicker" data-width="auto" id="add_launch_type">
|
||||||
|
<option value="LAUNCH_STANDARD_VM">LAUNCH_STANDARD_VM</option>
|
||||||
|
<option value="LAUNCH_RTVM">LAUNCH_RTVM</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="new_launch_name2" class="col-sm-3 control-label">Launch Name: </label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="text" class="form-control" id="new_launch_name2"
|
||||||
|
value={{ launch }}>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
|
<button type="button" id="add_launch_submit" data-id="" class="btn btn-primary" data-dismiss="modal">Submit
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -40,20 +84,20 @@
|
|||||||
<label for="launch_file" class="btn btn-primary" id="scenario_file2"
|
<label for="launch_file" class="btn btn-primary" id="scenario_file2"
|
||||||
style="border: 1px solid #ccc; display: inline-block; padding: 6px 12px;
|
style="border: 1px solid #ccc; display: inline-block; padding: 6px 12px;
|
||||||
cursor: pointer; border-radius:5px; ">
|
cursor: pointer; border-radius:5px; ">
|
||||||
Import</label>
|
Import XML</label>
|
||||||
<input type="file" name="file" id="launch_file" class="col-sm-1 btn btn-primary" style="display: none;">
|
<input type="file" name="file" id="launch_file" class="col-sm-1 btn btn-primary" style="display: none;">
|
||||||
{% else %}
|
{% else %}
|
||||||
<label class="btn"
|
<label class="btn"
|
||||||
style="border: 1px solid #ccc; display: inline-block; padding: 6px 12px;
|
style="border: 1px solid #ccc; display: inline-block; padding: 6px 12px;
|
||||||
cursor: pointer; border-radius:5px; ">
|
cursor: pointer; border-radius:5px; ">
|
||||||
Import</label>
|
Import XML</label>
|
||||||
<input type="file" name="file" class="col-sm-1" style="display: none;" disabled>
|
<input type="file" name="file" class="col-sm-1" style="display: none;" disabled>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% if board_info != None and root != None %}
|
{% if board_info != None and root != None %}
|
||||||
<div class="col-sm-1">
|
<div class="col-sm-1">
|
||||||
<button type="button" class="btn btn-primary" data-id="save" data-toggle="modal" data-target="#save_modal">
|
<button type="button" class="btn btn-primary" data-id="save" data-toggle="modal" data-target="#save_modal"
|
||||||
Export
|
id="export_launch_xml">Export XML
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-1">
|
<div class="col-sm-1">
|
||||||
@ -63,7 +107,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="col-sm-1">
|
<div class="col-sm-1">
|
||||||
<button type="button" disabled class="btn btn-primary">Export</button>
|
<button type="button" disabled class="btn btn-primary">Export XML</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-1">
|
<div class="col-sm-1">
|
||||||
<button type="button" disabled class="btn btn-primary">Generate Launch Script</button>
|
<button type="button" disabled class="btn btn-primary">Generate Launch Script</button>
|
||||||
@ -76,20 +120,14 @@
|
|||||||
<div class="dropdown col-sm-9">
|
<div class="dropdown col-sm-9">
|
||||||
<select class="selectpicker" data-width="auto" id="scenario_name">
|
<select class="selectpicker" data-width="auto" id="scenario_name">
|
||||||
<option style="display:none">
|
<option style="display:none">
|
||||||
{% for sc in scenarios[0] %}
|
<option disabled selected value> -- Select an option -- </option>
|
||||||
{% if root != None and root.attrib['scenario'] == sc %}
|
{% for sc in scenarios[1] %}
|
||||||
|
{% if root !=None and root.attrib['scenario'] == sc%}
|
||||||
<option value="{{sc}}" selected>{{sc}}</option>
|
<option value="{{sc}}" selected>{{sc}}</option>
|
||||||
{% else %}
|
{% else %}
|
||||||
<option value="{{sc}}">{{sc}}</option>
|
<option value="{{sc}}">{{sc}}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for sc in scenarios[1] %}
|
|
||||||
{% if root !=None and root.attrib['scenario'] == 'user_defined_'+sc%}
|
|
||||||
<option value="{{'user_defined_'+sc}}" selected>{{'user_defined_'+sc}}</option>
|
|
||||||
{% else %}
|
|
||||||
<option value="{{'user_defined_'+sc}}">{{'user_defined_'+sc}}</option>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -103,6 +141,14 @@
|
|||||||
<label class="col-sm-2 control-label">UOS: </label>
|
<label class="col-sm-2 control-label">UOS: </label>
|
||||||
<label class="col-sm-1 control-label" id="vm">{{vm.attrib['id']}}</label>
|
<label class="col-sm-1 control-label" id="vm">{{vm.attrib['id']}}</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<button type="button" class="btn" id="add_launch_vm" data-id="{{vm.attrib['id']}}" data-toggle="modal"
|
||||||
|
data-target="#add_launch_modal">Add a VM below</button>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<button type="button" class="btn" id="remove_launch_vm" data-id="{{vm.attrib['id']}}">
|
||||||
|
Remove this VM</button>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% for elem in vm.getchildren() %}
|
{% for elem in vm.getchildren() %}
|
||||||
@ -142,6 +188,7 @@
|
|||||||
<select class="selectpicker" data-width="auto" title=""
|
<select class="selectpicker" data-width="auto" title=""
|
||||||
id="{{'uos:id='+vm.attrib['id']+','+elem.tag}}">
|
id="{{'uos:id='+vm.attrib['id']+','+elem.tag}}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<option disabled selected value> -- Select an option -- </option>
|
||||||
{% for item_value in launch_item_values[','.join(['uos', elem.tag])] %}
|
{% for item_value in launch_item_values[','.join(['uos', elem.tag])] %}
|
||||||
{% if item_value == elem_text %}
|
{% if item_value == elem_text %}
|
||||||
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
|
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
|
||||||
@ -164,7 +211,6 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{% if 'id' not in elem.attrib %}
|
{% if 'id' not in elem.attrib %}
|
||||||
{% if not first_child %}
|
{% if not first_child %}
|
||||||
{% do first_child.append(1) %}
|
|
||||||
<label class="col-sm-1 control-label" data-toggle="tooltip"
|
<label class="col-sm-1 control-label" data-toggle="tooltip"
|
||||||
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
|
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
|
||||||
{{elem.tag}}</label>
|
{{elem.tag}}</label>
|
||||||
@ -178,7 +224,8 @@
|
|||||||
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
|
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
|
||||||
{{sub_elem.tag}}</label>
|
{{sub_elem.tag}}</label>
|
||||||
|
|
||||||
{% if ','.join(['uos', elem.tag, sub_elem.tag]) not in launch_item_values %}
|
{% if ','.join(['uos', elem.tag, sub_elem.tag]) not in launch_item_values
|
||||||
|
and elem.tag != 'vcpu_affinity'%}
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-5">
|
||||||
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
|
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
|
||||||
<input type="text" class="form-control" readonly
|
<input type="text" class="form-control" readonly
|
||||||
@ -204,6 +251,8 @@
|
|||||||
{% endif%}
|
{% endif%}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
{% set item_key = ','.join(['uos', elem.tag, sub_elem.tag]) if elem.tag != 'vcpu_affinity'
|
||||||
|
else ','.join(['uos', elem.tag]) %}
|
||||||
<div class="dropdown col-sm-6">
|
<div class="dropdown col-sm-6">
|
||||||
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
|
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
|
||||||
<select class="selectpicker" data-width="auto" disabled
|
<select class="selectpicker" data-width="auto" disabled
|
||||||
@ -212,7 +261,8 @@
|
|||||||
<select class="selectpicker" data-width="auto"
|
<select class="selectpicker" data-width="auto"
|
||||||
id="{{'uos:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}">
|
id="{{'uos:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for item_value in launch_item_values[','.join(['uos', elem.tag, sub_elem.tag])] %}
|
<option disabled selected value> -- Select an option -- </option>
|
||||||
|
{% for item_value in launch_item_values[item_key] %}
|
||||||
{% if item_value == sub_elem_text %}
|
{% if item_value == sub_elem_text %}
|
||||||
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
|
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -220,8 +270,17 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
{% if elem.tag == 'vcpu_affinity' %}
|
||||||
|
<button type="button" class="btn" id="add_vcpu_{{first_child|length}}">+</button>
|
||||||
|
{% if not first_child %}
|
||||||
|
<button type="button" disabled class="btn" id="remove_vcpu_{{first_child|length}}">-</button>
|
||||||
|
{% else %}
|
||||||
|
<button type="button" class="btn" id="remove_vcpu_{{first_child|length}}">-</button>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% do first_child.append(1) %}
|
||||||
<p id="{{'uos:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}_err" class="col-sm-3"></p>
|
<p id="{{'uos:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}_err" class="col-sm-3"></p>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if not first_child %}
|
{% if not first_child %}
|
||||||
@ -260,6 +319,7 @@
|
|||||||
<select class="selectpicker" data-width="auto"
|
<select class="selectpicker" data-width="auto"
|
||||||
id="{{'uos:id='+vm.attrib['id']+','+elem.tag+':id='+elem.attrib['id']+','+sub_elem.tag}}">
|
id="{{'uos:id='+vm.attrib['id']+','+elem.tag+':id='+elem.attrib['id']+','+sub_elem.tag}}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<option disabled selected value> -- Select an option -- </option>
|
||||||
{% for item_value in launch_item_values[','.join(['uos', elem.tag, sub_elem.tag])] %}
|
{% for item_value in launch_item_values[','.join(['uos', elem.tag, sub_elem.tag])] %}
|
||||||
{% if item_value == sub_elem_text %}
|
{% if item_value == sub_elem_text %}
|
||||||
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
|
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
|
||||||
@ -318,6 +378,10 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<tr><td>
|
||||||
|
<button type="button" class="btn" id="add_launch_script" data-toggle="modal" data-id="-1"
|
||||||
|
data-target="#add_launch_modal">Add a New VM</button>
|
||||||
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% else %}
|
||||||
<text class="form-control" id="err_msg">No setting available. Select one board info and make sure the launch xml
|
<text class="form-control" id="err_msg">No setting available. Select one board info and make sure the launch xml
|
||||||
|
@ -10,18 +10,66 @@
|
|||||||
<h4 class="modal-title" id="myModalLabel">Save as</h4>
|
<h4 class="modal-title" id="myModalLabel">Save as</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="form-group">
|
<div class="form-group row">
|
||||||
<label for="new_scenario_name" class="col-sm-3 control-label">Scenario: </label>
|
<label for="new_scenario_name" class="col-sm-3 control-label">Scenario Name: </label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input type="text" class="form-control" id="new_scenario_name"
|
<input type="text" class="form-control" id="new_scenario_name"
|
||||||
value={{ scenario[13:] if scenario.startswith('user_defined_') else scenario }}>
|
value={{ scenario }}>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row hidden" id="src_path_row">
|
||||||
|
<label for="src_path" class="col-sm-3 control-label"
|
||||||
|
title="the relative path of acrn-hypervisor; if no path is specified,
|
||||||
|
the source files will be generated into default path and overwirte the previous files.">
|
||||||
|
Source Path: </label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="text" class="form-control" id="src_path" value=""
|
||||||
|
placeholder="input the path to generate source files">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
<button type="button" id="remove_scenario" class="btn btn-default" data-dismiss="modal">Remove</button>
|
<button type="button" id="remove_scenario" class="btn btn-default" data-dismiss="modal">Remove</button>
|
||||||
<button type="button" id="save_scenario" data-id="" class="btn btn-primary" data-dismiss="modal">Submit
|
<button type="button" id="save_scenario" data-id="" class="btn btn-primary">Submit
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal fade" id="add_vm_modal" tabindex="-1" role="dialog" aria-labelledby="addVMModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h4 class="modal-title" id="addVMModalLabel">Add a new VM</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="add_vm_type" class="col-sm-3 control-label">VM type: </label>
|
||||||
|
<div class="dropdown col-sm-6">
|
||||||
|
<select class="selectpicker" data-width="auto" id="add_vm_type">
|
||||||
|
<option value="PRE_STD_VM">PRE_STD_VM</option>
|
||||||
|
<option value="SAFETY_VM">SAFETY_VM</option>
|
||||||
|
<option value="SOS_VM">SOS_VM</option>
|
||||||
|
<option value="POST_STD_VM">POST_STD_VM</option>
|
||||||
|
<option value="POST_RT_VM">POST_RT_VM</option>
|
||||||
|
<option value="KATA_VM">KATA_VM</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="new_scenario_name2" class="col-sm-3 control-label">Scenario Name: </label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<input type="text" class="form-control" id="new_scenario_name2"
|
||||||
|
value={{ scenario }}>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
|
<button type="button" id="add_vm_submit" data-id="" class="btn btn-primary" data-dismiss="modal">Submit
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -40,20 +88,20 @@
|
|||||||
<label for="scenario_file" class="btn btn-primary" id="scenario_file2"
|
<label for="scenario_file" class="btn btn-primary" id="scenario_file2"
|
||||||
style="border: 1px solid #ccc; display: inline-block; padding: 6px 12px;
|
style="border: 1px solid #ccc; display: inline-block; padding: 6px 12px;
|
||||||
cursor: pointer; border-radius:5px; ">
|
cursor: pointer; border-radius:5px; ">
|
||||||
Import</label>
|
Import XML</label>
|
||||||
<input type="file" name="file" id="scenario_file" class="col-sm-1 btn btn-primary" style="display: none;">
|
<input type="file" name="file" id="scenario_file" class="col-sm-1 btn btn-primary" style="display: none;">
|
||||||
{% else %}
|
{% else %}
|
||||||
<label for="scenario_file" class="btn"
|
<label for="scenario_file" class="btn"
|
||||||
style="border: 1px solid #ccc; display: inline-block; padding: 6px 12px;
|
style="border: 1px solid #ccc; display: inline-block; padding: 6px 12px;
|
||||||
cursor: pointer; border-radius:5px; ">
|
cursor: pointer; border-radius:5px; ">
|
||||||
Import</label>
|
Import XML</label>
|
||||||
<input type="file" name="file" class="col-sm-1" style="display: none;" disabled>
|
<input type="file" name="file" class="col-sm-1" style="display: none;" disabled>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% if board_info != None and root != None and scenario_item_values %}
|
{% if board_info != None and root != None and scenario_item_values %}
|
||||||
<div class="col-sm-1">
|
<div class="col-sm-1">
|
||||||
<button type="button" data-id="save" class="btn btn-primary" data-toggle="modal" data-target="#save_modal">
|
<button type="button" data-id="" class="btn btn-primary" data-toggle="modal" data-target="#save_modal"
|
||||||
Export
|
id="export_scenario_xml">Export XML
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
@ -63,8 +111,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="col-sm-1">
|
<div class="col-sm-1">
|
||||||
<button type="button" disabled class="btn btn-primary" data-toggle="modal" data-target="#save_modal">
|
<button type="button" disabled class="btn btn-primary" data-toggle="modal" data-target="#save_modal">Export XML
|
||||||
Export
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
@ -90,12 +137,23 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-1 control-label">HV </label>
|
<label class="col-sm-1 control-label">HV </label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<button type="button" class="btn" id="add_vm" data-id="-1" data-toggle="modal"
|
||||||
|
data-target="#add_vm_modal">Add a VM below</button>
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set vm_type = 'vm:id='+vm.attrib['id'] %}
|
{% set vm_type = 'vm:id='+vm.attrib['id'] %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-1 control-label">VM: </label>
|
<label class="col-sm-1 control-label">VM: </label>
|
||||||
<label class="col-sm-1 control-label" id="vm">{{vm.attrib['id']}}</label>
|
<label class="col-sm-1 control-label" id="vm">{{vm.attrib['id']}}</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<button type="button" class="btn" id="add_vm" data-id="{{vm.attrib['id']}}" data-toggle="modal"
|
||||||
|
data-target="#add_vm_modal">Add a VM below</button>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<button type="button" class="btn" id="remove_vm" data-id="{{vm.attrib['id']}}">
|
||||||
|
Remove this VM</button>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if 'desc' in vm.attrib or vm.attrib['desc'] == 'specific for Kata' %}
|
{% if 'desc' in vm.attrib or vm.attrib['desc'] == 'specific for Kata' %}
|
||||||
@ -133,6 +191,7 @@
|
|||||||
<select class="selectpicker" data-width="auto"
|
<select class="selectpicker" data-width="auto"
|
||||||
id="{{vm_type+','+elem.tag}}">
|
id="{{vm_type+','+elem.tag}}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<option disabled selected value> -- Select an option -- </option>
|
||||||
{% for item_value in scenario_item_values[','.join([vm.tag, elem.tag])] %}
|
{% for item_value in scenario_item_values[','.join([vm.tag, elem.tag])] %}
|
||||||
{% if item_value == elem_text %}
|
{% if item_value == elem_text %}
|
||||||
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
|
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
|
||||||
@ -167,7 +226,8 @@
|
|||||||
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
|
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
|
||||||
{{sub_elem.tag}}</label>
|
{{sub_elem.tag}}</label>
|
||||||
|
|
||||||
{% if ','.join([vm.tag, elem.tag, sub_elem.tag]) not in scenario_item_values and elem.tag != 'vcpu_affinity' %}
|
{% if ','.join([vm.tag, elem.tag, sub_elem.tag]) not in scenario_item_values
|
||||||
|
and elem.tag != 'vcpu_affinity' and elem.tag != 'pci_devs' %}
|
||||||
{% if sub_elem.tag in ['bootargs', 'kern_args'] %}
|
{% if sub_elem.tag in ['bootargs', 'kern_args'] %}
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
|
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
|
||||||
@ -193,8 +253,8 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set item_key = ','.join([vm.tag, elem.tag, sub_elem.tag]) if elem.tag != 'vcpu_affinity' else
|
{% set item_key = ','.join([vm.tag, elem.tag, sub_elem.tag]) if elem.tag != 'vcpu_affinity'
|
||||||
','.join([vm.tag, elem.tag])%}
|
and elem.tag != 'pci_devs' else ','.join([vm.tag, elem.tag]) %}
|
||||||
<div class="dropdown col-sm-6">
|
<div class="dropdown col-sm-6">
|
||||||
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
|
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
|
||||||
<select class="selectpicker" data-width="auto"
|
<select class="selectpicker" data-width="auto"
|
||||||
@ -203,6 +263,7 @@
|
|||||||
<select class="selectpicker" data-width="auto"
|
<select class="selectpicker" data-width="auto"
|
||||||
id="{{vm_type+','+elem.tag+','+sub_elem.tag}}">
|
id="{{vm_type+','+elem.tag+','+sub_elem.tag}}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<option disabled selected value> -- Select an option -- </option>
|
||||||
{% for item_value in scenario_item_values[item_key] %}
|
{% for item_value in scenario_item_values[item_key] %}
|
||||||
{% if item_value == sub_elem_text %}
|
{% if item_value == sub_elem_text %}
|
||||||
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
|
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
|
||||||
@ -219,6 +280,14 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<button type="button" class="btn" id="remove_vcpu_{{first_child|length}}">-</button>
|
<button type="button" class="btn" id="remove_vcpu_{{first_child|length}}">-</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% elif elem.tag == 'pci_devs' %}
|
||||||
|
<button type="button" class="btn" id="add_pci_dev_{{first_child|length}}">+</button>
|
||||||
|
{% if not first_child %}
|
||||||
|
<button type="button" disabled class="btn" id="remove_pci_dev_{{first_child|length}}">-</button>
|
||||||
|
{% else %}
|
||||||
|
<button type="button" class="btn" id="remove_pci_dev_{{first_child|length}}">-</button>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
{% endif%}
|
{% endif%}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -268,6 +337,7 @@
|
|||||||
{% set key = ('vm='+vm.attrib['id']+','+elem.tag+'='+elem.attrib['id']+','+sub_elem.tag)
|
{% set key = ('vm='+vm.attrib['id']+','+elem.tag+'='+elem.attrib['id']+','+sub_elem.tag)
|
||||||
if (elem.tag=='vuart' and sub_elem.tag=='base')
|
if (elem.tag=='vuart' and sub_elem.tag=='base')
|
||||||
else ','.join([vm.tag, elem.tag, sub_elem.tag]) %}
|
else ','.join([vm.tag, elem.tag, sub_elem.tag]) %}
|
||||||
|
<option disabled selected value> -- Select an option -- </option>
|
||||||
{% for item_value in scenario_item_values[key] %}
|
{% for item_value in scenario_item_values[key] %}
|
||||||
{% if item_value == sub_elem_text %}
|
{% if item_value == sub_elem_text %}
|
||||||
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
|
<option value="{{item_value}}" selected="selected">{{item_value}}</option>
|
||||||
|
@ -46,9 +46,11 @@ def scenarios():
|
|||||||
"""
|
"""
|
||||||
board_info, board_type, scenario_config, launch_config = get_xml_configs()
|
board_info, board_type, scenario_config, launch_config = get_xml_configs()
|
||||||
print(board_info, scenario_config, launch_config)
|
print(board_info, scenario_config, launch_config)
|
||||||
|
(bios_info, base_board_info) = get_board_info(board_info)
|
||||||
|
|
||||||
return render_template('scenario.html', board_info_list=get_board_list(),
|
return render_template('scenario.html', board_info_list=get_board_list(),
|
||||||
board_info=board_info, board_type=board_type,
|
board_info=board_info, board_type=board_type,
|
||||||
|
bios_info=bios_info, base_board_info=base_board_info,
|
||||||
scenarios=scenario_config.list_all(xml_type='scenario'),
|
scenarios=scenario_config.list_all(xml_type='scenario'),
|
||||||
launches=launch_config.list_all(xml_type='uos_launcher'),
|
launches=launch_config.list_all(xml_type='uos_launcher'),
|
||||||
scenario='', root=None)
|
scenario='', root=None)
|
||||||
@ -62,23 +64,18 @@ def scenario(scenario_name):
|
|||||||
:return: the render template of the specified scenario setting page
|
:return: the render template of the specified scenario setting page
|
||||||
"""
|
"""
|
||||||
|
|
||||||
board_info, board_type, scenario_config, launch_config = \
|
board_info, board_type, scenario_config, launch_config = get_xml_configs()
|
||||||
get_xml_configs(scenario_name.startswith('user_defined_'))
|
|
||||||
print(board_info, scenario_config, launch_config)
|
print(board_info, scenario_config, launch_config)
|
||||||
|
(bios_info, base_board_info) = get_board_info(board_info)
|
||||||
|
|
||||||
current_app.config.update(SCENARIO=scenario_name)
|
current_app.config.update(SCENARIO=scenario_name)
|
||||||
|
|
||||||
if scenario_name.startswith('user_defined_'):
|
scenario_config.set_curr(scenario_name)
|
||||||
scenario_config.set_curr(scenario_name[13:])
|
|
||||||
else:
|
|
||||||
scenario_config.set_curr(scenario_name)
|
|
||||||
|
|
||||||
scenario_item_values = {}
|
scenario_item_values = {}
|
||||||
if board_info is not None and board_type is not None:
|
if board_info is not None and board_type is not None:
|
||||||
scenario_file_path = os.path.join(current_app.config.get('CONFIG_PATH'),
|
scenario_file_path = os.path.join(current_app.config.get('CONFIG_PATH'), board_type,
|
||||||
board_type, scenario_name + '.xml')
|
'user_defined', scenario_name + '.xml')
|
||||||
if scenario_name.startswith('user_defined_'):
|
|
||||||
scenario_file_path = os.path.join(current_app.config.get('CONFIG_PATH'), board_type,
|
|
||||||
'user_defined', scenario_name[13:] + '.xml')
|
|
||||||
if os.path.isfile(scenario_file_path):
|
if os.path.isfile(scenario_file_path):
|
||||||
scenario_item_values = get_scenario_item_values(
|
scenario_item_values = get_scenario_item_values(
|
||||||
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res', board_info+'.xml'),
|
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res', board_info+'.xml'),
|
||||||
@ -88,6 +85,7 @@ def scenario(scenario_name):
|
|||||||
|
|
||||||
return render_template('scenario.html', board_info_list=get_board_list(),
|
return render_template('scenario.html', board_info_list=get_board_list(),
|
||||||
board_info=board_info, board_type=board_type,
|
board_info=board_info, board_type=board_type,
|
||||||
|
bios_info=bios_info, base_board_info=base_board_info,
|
||||||
scenarios=scenario_config.list_all(xml_type='scenario'),
|
scenarios=scenario_config.list_all(xml_type='scenario'),
|
||||||
launches=launch_config.list_all(xml_type='uos_launcher'),
|
launches=launch_config.list_all(xml_type='uos_launcher'),
|
||||||
scenario=scenario_name, root=scenario_config.get_curr_root(),
|
scenario=scenario_name, root=scenario_config.get_curr_root(),
|
||||||
@ -102,9 +100,11 @@ def launches():
|
|||||||
"""
|
"""
|
||||||
board_info, board_type, scenario_config, launch_config = get_xml_configs()
|
board_info, board_type, scenario_config, launch_config = get_xml_configs()
|
||||||
print(board_info, scenario_config, launch_config)
|
print(board_info, scenario_config, launch_config)
|
||||||
|
(bios_info, base_board_info) = get_board_info(board_info)
|
||||||
|
|
||||||
return render_template('launch.html', board_info_list=get_board_list(),
|
return render_template('launch.html', board_info_list=get_board_list(),
|
||||||
board_info=board_info, board_type=board_type,
|
board_info=board_info, board_type=board_type,
|
||||||
|
bios_info=bios_info, base_board_info=base_board_info,
|
||||||
scenarios=scenario_config.list_all(xml_type='scenario'),
|
scenarios=scenario_config.list_all(xml_type='scenario'),
|
||||||
launches=launch_config.list_all(xml_type='uos_launcher'),
|
launches=launch_config.list_all(xml_type='uos_launcher'),
|
||||||
launch='', root=None)
|
launch='', root=None)
|
||||||
@ -117,15 +117,11 @@ def launch(launch_name):
|
|||||||
:param launch_name: the launch type
|
:param launch_name: the launch type
|
||||||
:return: the render template of specified launch setting page
|
:return: the render template of specified launch setting page
|
||||||
"""
|
"""
|
||||||
print('launch: ', launch_name)
|
board_info, board_type, scenario_config, launch_config = get_xml_configs()
|
||||||
board_info, board_type, scenario_config, launch_config = \
|
|
||||||
get_xml_configs(launch_name.startswith('user_defined_'))
|
|
||||||
print(board_info, scenario_config, launch_config)
|
print(board_info, scenario_config, launch_config)
|
||||||
|
(bios_info, base_board_info) = get_board_info(board_info)
|
||||||
|
|
||||||
if launch_name.startswith('user_defined_'):
|
launch_config.set_curr(launch_name)
|
||||||
launch_config.set_curr(launch_name[13:])
|
|
||||||
else:
|
|
||||||
launch_config.set_curr(launch_name)
|
|
||||||
|
|
||||||
launch_item_values = {}
|
launch_item_values = {}
|
||||||
if board_info is not None:
|
if board_info is not None:
|
||||||
@ -136,6 +132,7 @@ def launch(launch_name):
|
|||||||
|
|
||||||
return render_template('launch.html', board_info_list=get_board_list(),
|
return render_template('launch.html', board_info_list=get_board_list(),
|
||||||
board_info=board_info, board_type=board_type,
|
board_info=board_info, board_type=board_type,
|
||||||
|
bios_info=bios_info, base_board_info=base_board_info,
|
||||||
scenarios=scenario_config.list_all(xml_type='scenario'),
|
scenarios=scenario_config.list_all(xml_type='scenario'),
|
||||||
launches=launch_config.list_all(xml_type='uos_launcher'),
|
launches=launch_config.list_all(xml_type='uos_launcher'),
|
||||||
launch=launch_name, root=launch_config.get_curr_root(),
|
launch=launch_name, root=launch_config.get_curr_root(),
|
||||||
@ -150,11 +147,8 @@ def save_scenario():
|
|||||||
:return: the error list for the edited scenario setting.
|
:return: the error list for the edited scenario setting.
|
||||||
"""
|
"""
|
||||||
scenario_config_data = request.json if request.method == "POST" else request.args
|
scenario_config_data = request.json if request.method == "POST" else request.args
|
||||||
print("save_scenario")
|
|
||||||
print(scenario_config_data)
|
|
||||||
|
|
||||||
xml_configs = \
|
xml_configs = get_xml_configs()
|
||||||
get_xml_configs(scenario_config_data['old_scenario_name'].startswith('user_defined_'))
|
|
||||||
board_type = xml_configs[1]
|
board_type = xml_configs[1]
|
||||||
scenario_config = xml_configs[3]
|
scenario_config = xml_configs[3]
|
||||||
|
|
||||||
@ -164,30 +158,63 @@ def save_scenario():
|
|||||||
|
|
||||||
scenario_path = os.path.join(current_app.config.get('CONFIG_PATH'), board_type)
|
scenario_path = os.path.join(current_app.config.get('CONFIG_PATH'), board_type)
|
||||||
old_scenario_name = scenario_config_data['old_scenario_name']
|
old_scenario_name = scenario_config_data['old_scenario_name']
|
||||||
if scenario_config_data['old_scenario_name'].startswith('user_defined_'):
|
|
||||||
old_scenario_name = scenario_config_data['old_scenario_name'][13:]
|
|
||||||
scenario_config.set_curr(old_scenario_name)
|
scenario_config.set_curr(old_scenario_name)
|
||||||
for key in scenario_config_data:
|
for key in scenario_config_data:
|
||||||
if key not in ['old_scenario_name', 'new_scenario_name', 'board_info_file',
|
if key not in ['old_scenario_name', 'new_scenario_name', 'generator', 'add_vm_type']:
|
||||||
'board_info_upload', 'generator']:
|
|
||||||
if isinstance(scenario_config_data[key], list):
|
if isinstance(scenario_config_data[key], list):
|
||||||
scenario_config.set_curr_list(scenario_config_data[key], *tuple(key.split(',')))
|
scenario_config.set_curr_list(scenario_config_data[key], *tuple(key.split(',')))
|
||||||
else:
|
else:
|
||||||
scenario_config.set_curr_value(scenario_config_data[key], *tuple(key.split(',')))
|
scenario_config.set_curr_value(scenario_config_data[key], *tuple(key.split(',')))
|
||||||
|
|
||||||
if scenario_config_data['generator'] == 'remove_vm_kata':
|
generator = scenario_config_data['generator']
|
||||||
scenario_config.delete_curr_key('vm:desc=specific for Kata')
|
if generator is not None:
|
||||||
elif scenario_config_data['generator'] == 'add_vm_kata':
|
if generator == 'remove_vm_kata':
|
||||||
# clone vm kata from generic config
|
scenario_config.delete_curr_key('vm:desc=specific for Kata')
|
||||||
generic_scenario_config = get_generic_scenario_config(scenario_config)
|
elif generator == 'add_vm_kata':
|
||||||
generic_scenario_config_root = generic_scenario_config.get_curr_root()
|
# clone vm kata from generic config
|
||||||
elem_kata = None
|
generic_scenario_config = get_generic_scenario_config(scenario_config)
|
||||||
for vm in generic_scenario_config_root.getchildren():
|
generic_scenario_config_root = generic_scenario_config.get_curr_root()
|
||||||
if 'desc' in vm.attrib and vm.attrib['desc'] == 'specific for Kata':
|
elem_kata = None
|
||||||
elem_kata = vm
|
for vm in generic_scenario_config_root.getchildren():
|
||||||
break
|
if 'desc' in vm.attrib and vm.attrib['desc'] == 'specific for Kata':
|
||||||
if elem_kata is not None:
|
elem_kata = vm
|
||||||
scenario_config.clone_curr_elem(elem_kata)
|
break
|
||||||
|
if elem_kata is not None:
|
||||||
|
scenario_config.clone_curr_elem(elem_kata)
|
||||||
|
elif generator.startswith('add_vm:'):
|
||||||
|
vm_list = []
|
||||||
|
for vm in scenario_config.get_curr_root().getchildren():
|
||||||
|
if vm.tag == 'vm':
|
||||||
|
vm_list.append(vm.attrib['id'])
|
||||||
|
if len(vm_list) >= 8:
|
||||||
|
return {'status': 'fail',
|
||||||
|
'error_list': {'error': 'Can not add a new VM. Max VM number is 8.'}}
|
||||||
|
curr_vm_id = generator.split(':')[1]
|
||||||
|
add_vm_type = scenario_config_data['add_vm_type']
|
||||||
|
generic_scenario_config = get_generic_scenario_config(scenario_config, add_vm_type)
|
||||||
|
generic_scenario_config_root = generic_scenario_config.get_curr_root()
|
||||||
|
vm_to_add = []
|
||||||
|
if str(curr_vm_id) == '-1':
|
||||||
|
curr_vm_index = 1
|
||||||
|
else:
|
||||||
|
curr_vm_index = len(vm_list) + 1
|
||||||
|
for i in range(len(vm_list)):
|
||||||
|
if curr_vm_id == vm_list[i]:
|
||||||
|
curr_vm_index = i + 2
|
||||||
|
break
|
||||||
|
for vm in generic_scenario_config_root.getchildren():
|
||||||
|
if vm.tag == 'vm':
|
||||||
|
for i in range(0, 7):
|
||||||
|
if str(i) not in vm_list:
|
||||||
|
break
|
||||||
|
vm.attrib['id'] = str(i)
|
||||||
|
vm_to_add.append(vm)
|
||||||
|
for vm in vm_to_add:
|
||||||
|
scenario_config.insert_curr_elem(curr_vm_index, vm)
|
||||||
|
curr_vm_index += 1
|
||||||
|
elif generator.startswith('remove_vm:'):
|
||||||
|
remove_vm_id = generator.split(':')[1]
|
||||||
|
scenario_config.delete_curr_key('vm:id='+remove_vm_id.strip())
|
||||||
|
|
||||||
tmp_scenario_file = os.path.join(scenario_path, 'user_defined',
|
tmp_scenario_file = os.path.join(scenario_path, 'user_defined',
|
||||||
'tmp_'+scenario_config_data['new_scenario_name']+'.xml')
|
'tmp_'+scenario_config_data['new_scenario_name']+'.xml')
|
||||||
@ -200,35 +227,21 @@ def save_scenario():
|
|||||||
new_scenario_name = scenario_config_data['new_scenario_name']
|
new_scenario_name = scenario_config_data['new_scenario_name']
|
||||||
rename = False
|
rename = False
|
||||||
try:
|
try:
|
||||||
(error_list, vm_info) = validate_scenario_setting(
|
if generator is None or not (generator.startswith('add_vm:') or generator.startswith('remove_vm:')):
|
||||||
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res', xml_configs[0]+'.xml'),
|
(error_list, vm_info) = validate_scenario_setting(
|
||||||
tmp_scenario_file)
|
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res', xml_configs[0]+'.xml'),
|
||||||
print('vm_info: ', vm_info)
|
tmp_scenario_file)
|
||||||
|
print('vm_info: ', vm_info)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
if os.path.isfile(tmp_scenario_file):
|
if os.path.isfile(tmp_scenario_file):
|
||||||
os.remove(tmp_scenario_file)
|
os.remove(tmp_scenario_file)
|
||||||
return {'status': 'fail', 'file_name': new_scenario_name,
|
return {'status': 'fail', 'file_name': new_scenario_name,
|
||||||
'rename': rename, 'error_list': {'error': str(error)}}
|
'rename': rename, 'error_list': {'error': str(error)}}
|
||||||
|
|
||||||
print('error_list: ', error_list)
|
|
||||||
|
|
||||||
if not error_list:
|
if not error_list:
|
||||||
old_scenario_path = os.path.join(scenario_path, old_scenario_name + '.xml')
|
|
||||||
if scenario_config_data['old_scenario_name'].startswith('user_defined_'):
|
|
||||||
old_scenario_path = os.path.join(scenario_path, 'user_defined',
|
|
||||||
old_scenario_name + '.xml')
|
|
||||||
|
|
||||||
# check name conflict
|
|
||||||
new_scenario_path = os.path.join(scenario_path, 'user_defined',
|
|
||||||
scenario_config_data['new_scenario_name']+'.xml')
|
|
||||||
if old_scenario_path != new_scenario_path and os.path.isfile(new_scenario_path):
|
|
||||||
new_scenario_name = new_scenario_name + '_' + datetime.now().strftime('%Y%m%d%H%M%S')
|
|
||||||
rename = True
|
|
||||||
|
|
||||||
if os.path.isfile(old_scenario_path) \
|
|
||||||
and scenario_config_data['old_scenario_name'].startswith('user_defined_'):
|
|
||||||
os.remove(old_scenario_path)
|
|
||||||
scenario_config.save(new_scenario_name)
|
scenario_config.save(new_scenario_name)
|
||||||
|
if old_scenario_name != new_scenario_name:
|
||||||
|
os.remove(os.path.join(scenario_path, 'user_defined', old_scenario_name + '.xml'))
|
||||||
|
|
||||||
if os.path.isfile(tmp_scenario_file):
|
if os.path.isfile(tmp_scenario_file):
|
||||||
os.remove(tmp_scenario_file)
|
os.remove(tmp_scenario_file)
|
||||||
@ -244,9 +257,8 @@ def save_launch():
|
|||||||
:return: the error list of the edited launch setting.
|
:return: the error list of the edited launch setting.
|
||||||
"""
|
"""
|
||||||
launch_config_data = request.json if request.method == "POST" else request.args
|
launch_config_data = request.json if request.method == "POST" else request.args
|
||||||
|
print(launch_config_data)
|
||||||
xml_configs = \
|
xml_configs = get_xml_configs()
|
||||||
get_xml_configs(launch_config_data['old_launch_name'].startswith('user_defined_'))
|
|
||||||
launch_config = xml_configs[3]
|
launch_config = xml_configs[3]
|
||||||
|
|
||||||
if xml_configs[1] is None or xml_configs[0] is None:
|
if xml_configs[1] is None or xml_configs[0] is None:
|
||||||
@ -254,30 +266,61 @@ def save_launch():
|
|||||||
'error_list': {'error': 'Please select the board info before this operation.'}}
|
'error_list': {'error': 'Please select the board info before this operation.'}}
|
||||||
|
|
||||||
old_launch_name = launch_config_data['old_launch_name']
|
old_launch_name = launch_config_data['old_launch_name']
|
||||||
old_launch_path = os.path.join(current_app.config.get('CONFIG_PATH'), xml_configs[1],
|
|
||||||
old_launch_name + '.xml')
|
|
||||||
if launch_config_data['old_launch_name'].startswith('user_defined_'):
|
|
||||||
old_launch_name = launch_config_data['old_launch_name'][13:]
|
|
||||||
old_launch_path = os.path.join(current_app.config.get('CONFIG_PATH'), xml_configs[1],
|
|
||||||
'user_defined', old_launch_name + '.xml')
|
|
||||||
launch_config.set_curr(old_launch_name)
|
launch_config.set_curr(old_launch_name)
|
||||||
|
|
||||||
for key in launch_config_data:
|
for key in launch_config_data:
|
||||||
if key not in ['old_launch_name', 'new_launch_name', 'board_info_file',
|
if key not in ['old_launch_name', 'new_launch_name', 'generator', 'add_launch_type', 'scenario_name']:
|
||||||
'board_info_upload', 'scenario_name']:
|
|
||||||
if isinstance(launch_config_data[key], list):
|
if isinstance(launch_config_data[key], list):
|
||||||
launch_config.set_curr_list(launch_config_data[key], *tuple(key.split(',')))
|
launch_config.set_curr_list(launch_config_data[key], *tuple(key.split(',')))
|
||||||
else:
|
else:
|
||||||
launch_config.set_curr_value(launch_config_data[key], *tuple(key.split(',')))
|
launch_config.set_curr_value(launch_config_data[key], *tuple(key.split(',')))
|
||||||
|
|
||||||
|
generator = launch_config_data['generator']
|
||||||
|
if generator is not None:
|
||||||
|
if generator.startswith('add_vm:'):
|
||||||
|
vm_list = []
|
||||||
|
for vm in launch_config.get_curr_root().getchildren():
|
||||||
|
if vm.tag == 'uos':
|
||||||
|
vm_list.append(vm.attrib['id'])
|
||||||
|
if len(vm_list) >= 8:
|
||||||
|
return {'status': 'fail',
|
||||||
|
'error_list': {'error': 'Can not add a new VM. Max VM number is 8.'}}
|
||||||
|
curr_vm_id = generator.split(':')[1].strip()
|
||||||
|
add_launch_type = launch_config_data['add_launch_type']
|
||||||
|
generic_scenario_config = get_generic_scenario_config(launch_config, add_launch_type)
|
||||||
|
generic_scenario_config_root = generic_scenario_config.get_curr_root()
|
||||||
|
vm_to_add = []
|
||||||
|
if str(curr_vm_id) == '-1':
|
||||||
|
curr_vm_index = len(vm_list)
|
||||||
|
else:
|
||||||
|
curr_vm_index = 0
|
||||||
|
for i in range(len(vm_list)):
|
||||||
|
if curr_vm_id == vm_list[i]:
|
||||||
|
curr_vm_index = i + 1
|
||||||
|
break
|
||||||
|
for vm in generic_scenario_config_root.getchildren():
|
||||||
|
if vm.tag == 'uos':
|
||||||
|
for i in range(1, 8):
|
||||||
|
if str(i) not in vm_list:
|
||||||
|
break
|
||||||
|
vm.attrib['id'] = str(i)
|
||||||
|
vm_to_add.append(vm)
|
||||||
|
# print('-'*100)
|
||||||
|
# print(generator)
|
||||||
|
# print(vm_list)
|
||||||
|
# print(curr_vm_id)
|
||||||
|
# print(curr_vm_index)
|
||||||
|
# print(i)
|
||||||
|
for vm in vm_to_add:
|
||||||
|
launch_config.insert_curr_elem(curr_vm_index, vm)
|
||||||
|
elif generator.startswith('remove_vm:'):
|
||||||
|
remove_vm_id = generator.split(':')[1]
|
||||||
|
launch_config.delete_curr_key('uos:id='+remove_vm_id.strip())
|
||||||
|
|
||||||
scenario_name = launch_config_data['scenario_name']
|
scenario_name = launch_config_data['scenario_name']
|
||||||
scenario_file_path = os.path.join(current_app.config.get('CONFIG_PATH'),
|
scenario_file_path = os.path.join(current_app.config.get('CONFIG_PATH'),
|
||||||
current_app.config.get('BOARD_TYPE'), scenario_name + '.xml')
|
current_app.config.get('BOARD_TYPE'),
|
||||||
if launch_config_data['scenario_name'].startswith('user_defined_'):
|
'user_defined', scenario_name + '.xml')
|
||||||
scenario_name = launch_config_data['scenario_name'][13:]
|
|
||||||
scenario_file_path = os.path.join(current_app.config.get('CONFIG_PATH'),
|
|
||||||
current_app.config.get('BOARD_TYPE'),
|
|
||||||
'user_defined', scenario_name + '.xml')
|
|
||||||
launch_config.set_curr_attr('scenario', scenario_name)
|
launch_config.set_curr_attr('scenario', scenario_name)
|
||||||
|
|
||||||
tmp_launch_file = os.path.join(current_app.config.get('CONFIG_PATH'), xml_configs[1],
|
tmp_launch_file = os.path.join(current_app.config.get('CONFIG_PATH'), xml_configs[1],
|
||||||
@ -288,35 +331,25 @@ def save_launch():
|
|||||||
launch_config.save('tmp_' + launch_config_data['new_launch_name'])
|
launch_config.save('tmp_' + launch_config_data['new_launch_name'])
|
||||||
|
|
||||||
# call validate function
|
# call validate function
|
||||||
|
error_list = {}
|
||||||
rename = False
|
rename = False
|
||||||
try:
|
try:
|
||||||
(error_list, pthru_sel, virtio, dm_value) = validate_launch_setting(
|
if generator is None or not (generator.startswith('add_vm:') or generator.startswith('remove_vm:')):
|
||||||
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res', xml_configs[0]+'.xml'),
|
(error_list, pthru_sel, virtio, dm_value) = validate_launch_setting(
|
||||||
scenario_file_path,
|
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res', xml_configs[0]+'.xml'),
|
||||||
tmp_launch_file)
|
scenario_file_path,
|
||||||
print(pthru_sel, virtio, dm_value)
|
tmp_launch_file)
|
||||||
|
print(pthru_sel, virtio, dm_value)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
if os.path.isfile(tmp_launch_file):
|
if os.path.isfile(tmp_launch_file):
|
||||||
os.remove(tmp_launch_file)
|
os.remove(tmp_launch_file)
|
||||||
return {'status': 'fail', 'file_name': launch_config_data['new_launch_name'],
|
return {'status': 'fail', 'file_name': launch_config_data['new_launch_name'],
|
||||||
'rename': rename, 'error_list': {'launch config error': str(error)}}
|
'rename': rename, 'error_list': {'launch config error': str(error)}}
|
||||||
|
|
||||||
print('error_list: ', error_list)
|
|
||||||
|
|
||||||
if not error_list:
|
if not error_list:
|
||||||
new_launch_path = os.path.join(current_app.config.get('CONFIG_PATH'),
|
|
||||||
xml_configs[1], 'user_defined',
|
|
||||||
launch_config_data['new_launch_name'] + '.xml')
|
|
||||||
# check name conflict
|
|
||||||
if old_launch_path != new_launch_path and os.path.isfile(new_launch_path):
|
|
||||||
launch_config_data['new_launch_name'] = launch_config_data['new_launch_name'] \
|
|
||||||
+ '_' + datetime.now().strftime('%Y%m%d%H%M%S')
|
|
||||||
rename = True
|
|
||||||
|
|
||||||
if os.path.isfile(old_launch_path) \
|
|
||||||
and launch_config_data['old_launch_name'].startswith('user_defined_'):
|
|
||||||
os.remove(old_launch_path)
|
|
||||||
launch_config.save(launch_config_data['new_launch_name'])
|
launch_config.save(launch_config_data['new_launch_name'])
|
||||||
|
if old_launch_name != launch_config_data['new_launch_name']:
|
||||||
|
os.remove(os.path.join(current_app.config.get('CONFIG_PATH'), xml_configs[1], old_launch_name + '.xml'))
|
||||||
|
|
||||||
if os.path.isfile(tmp_launch_file):
|
if os.path.isfile(tmp_launch_file):
|
||||||
os.remove(tmp_launch_file)
|
os.remove(tmp_launch_file)
|
||||||
@ -325,6 +358,101 @@ def save_launch():
|
|||||||
'rename': rename, 'error_list': error_list}
|
'rename': rename, 'error_list': error_list}
|
||||||
|
|
||||||
|
|
||||||
|
@CONFIG_APP.route('/check_setting_exist', methods=['POST'])
|
||||||
|
def check_setting_exist():
|
||||||
|
"""
|
||||||
|
check the setting exist or not.
|
||||||
|
:return: setting exist or not.
|
||||||
|
"""
|
||||||
|
config_data = request.json if request.method == "POST" else request.args
|
||||||
|
|
||||||
|
board_info = current_app.config.get('BOARD_TYPE')
|
||||||
|
setting_path = os.path.join(current_app.config.get('CONFIG_PATH'), board_info)
|
||||||
|
if 'old_scenario_name' in list(config_data.keys()) and 'new_scenario_name' in list(config_data.keys()):
|
||||||
|
if config_data['old_scenario_name'] != config_data['new_scenario_name'] and \
|
||||||
|
os.path.isfile(os.path.join(setting_path, 'user_defined', config_data['new_scenario_name'] + '.xml')):
|
||||||
|
return {'exist': 'yes'}
|
||||||
|
else:
|
||||||
|
return {'exist': 'no'}
|
||||||
|
elif 'old_launch_name' in list(config_data.keys()) and 'new_launch_name' in list(config_data.keys()):
|
||||||
|
if config_data['old_launch_name'] != config_data['new_launch_name'] and \
|
||||||
|
os.path.isfile(os.path.join(setting_path, 'user_defined', config_data['new_launch_name'] + '.xml')):
|
||||||
|
return {'exist': 'yes'}
|
||||||
|
else:
|
||||||
|
return {'exist': 'no'}
|
||||||
|
elif 'create_name' in list(config_data.keys()):
|
||||||
|
if os.path.isfile(os.path.join(setting_path, 'user_defined', config_data['create_name'] + '.xml')):
|
||||||
|
return {'exist': 'yes'}
|
||||||
|
else:
|
||||||
|
return {'exist': 'no'}
|
||||||
|
else:
|
||||||
|
return {'exist': 'no'}
|
||||||
|
|
||||||
|
|
||||||
|
@CONFIG_APP.route('/create_setting', methods=['POST'])
|
||||||
|
def create_setting():
|
||||||
|
"""
|
||||||
|
create a new scenario or launch setting.
|
||||||
|
:return: the status and error list of the created scenario or launch setting.
|
||||||
|
"""
|
||||||
|
create_config_data = request.json if request.method == "POST" else request.args
|
||||||
|
mode = create_config_data['mode']
|
||||||
|
default_name = create_config_data['default_name']
|
||||||
|
create_name = create_config_data['create_name']
|
||||||
|
|
||||||
|
xml_configs = get_xml_configs(True)
|
||||||
|
board_type = xml_configs[1]
|
||||||
|
scenario_config = xml_configs[2]
|
||||||
|
launch_config = xml_configs[3]
|
||||||
|
|
||||||
|
if board_type is None or xml_configs[0] is None:
|
||||||
|
return {'status': 'fail',
|
||||||
|
'error_list': {'error': 'Please select the board info before this operation.'}}
|
||||||
|
|
||||||
|
setting_path = os.path.join(current_app.config.get('CONFIG_PATH'), board_type, 'user_defined')
|
||||||
|
if not os.path.isdir(setting_path):
|
||||||
|
os.makedirs(setting_path)
|
||||||
|
|
||||||
|
if create_config_data['type'] == 'launch':
|
||||||
|
launch_file = os.path.join(setting_path, create_name + '.xml')
|
||||||
|
if os.path.isfile(launch_file):
|
||||||
|
os.remove(launch_file)
|
||||||
|
|
||||||
|
if mode == 'create':
|
||||||
|
template_file_name = 'LAUNCH_STANDARD_VM'
|
||||||
|
src_file_name = os.path.join(current_app.config.get('CONFIG_PATH'), 'template', template_file_name+'.xml')
|
||||||
|
else:
|
||||||
|
src_file_name = os.path.join(current_app.config.get('CONFIG_PATH'), board_type, default_name + '.xml')
|
||||||
|
copyfile(src_file_name,
|
||||||
|
os.path.join(current_app.config.get('CONFIG_PATH'), board_type, 'user_defined', create_name + '.xml'))
|
||||||
|
|
||||||
|
launch_config.set_curr(create_name)
|
||||||
|
if mode == 'create':
|
||||||
|
launch_config.delete_curr_key('uos:id=1')
|
||||||
|
launch_config.save(create_name)
|
||||||
|
return {'status': 'success', 'setting': create_name, 'error_list': {}}
|
||||||
|
|
||||||
|
elif create_config_data['type'] == 'scenario':
|
||||||
|
scenario_file = os.path.join(setting_path, create_name + '.xml')
|
||||||
|
if os.path.isfile(scenario_file):
|
||||||
|
os.remove(scenario_file)
|
||||||
|
|
||||||
|
if mode == 'create':
|
||||||
|
template_file_name = 'HV'
|
||||||
|
src_file_name = os.path.join(current_app.config.get('CONFIG_PATH'), 'template', template_file_name+'.xml')
|
||||||
|
else:
|
||||||
|
src_file_name = os.path.join(current_app.config.get('CONFIG_PATH'), board_type, default_name + '.xml')
|
||||||
|
copyfile(src_file_name,
|
||||||
|
os.path.join(current_app.config.get('CONFIG_PATH'), board_type, 'user_defined',
|
||||||
|
create_name + '.xml'))
|
||||||
|
|
||||||
|
scenario_config.save(create_name)
|
||||||
|
return {'status': 'success', 'setting': create_name, 'error_list': {}}
|
||||||
|
|
||||||
|
else:
|
||||||
|
return {'status': 'fail', 'error_list': {'name': 'Unsupported setting type. '}}
|
||||||
|
|
||||||
|
|
||||||
@CONFIG_APP.route('/remove_setting', methods=['POST'])
|
@CONFIG_APP.route('/remove_setting', methods=['POST'])
|
||||||
def remove_setting():
|
def remove_setting():
|
||||||
"""
|
"""
|
||||||
@ -332,23 +460,16 @@ def remove_setting():
|
|||||||
:return: the return message
|
:return: the return message
|
||||||
"""
|
"""
|
||||||
remove_config_data = request.json if request.method == "POST" else request.args
|
remove_config_data = request.json if request.method == "POST" else request.args
|
||||||
print("*"*100+"remove_setting")
|
|
||||||
print(remove_config_data)
|
|
||||||
|
|
||||||
old_setting_name = remove_config_data['old_setting_name']
|
old_setting_name = remove_config_data['old_setting_name']
|
||||||
|
|
||||||
if current_app.config.get('BOARD_TYPE') is None:
|
if current_app.config.get('BOARD_TYPE') is None:
|
||||||
return {'status': 'Board info not set before remove current setting'}
|
return {'status': 'Board info not set before remove current setting'}
|
||||||
|
|
||||||
print(current_app.config.get('CONFIG_PATH'), current_app.config.get('BOARD_TYPE'))
|
|
||||||
old_setting_path = os.path.join(current_app.config.get('CONFIG_PATH'),
|
old_setting_path = os.path.join(current_app.config.get('CONFIG_PATH'),
|
||||||
current_app.config.get('BOARD_TYPE'),
|
current_app.config.get('BOARD_TYPE'),
|
||||||
old_setting_name+'.xml')
|
'user_defined',
|
||||||
if old_setting_name.startswith('user_defined_'):
|
old_setting_name + '.xml')
|
||||||
old_setting_path = os.path.join(current_app.config.get('CONFIG_PATH'),
|
|
||||||
current_app.config.get('BOARD_TYPE'),
|
|
||||||
'user_defined',
|
|
||||||
old_setting_name[13:] + '.xml')
|
|
||||||
|
|
||||||
if os.path.isfile(old_setting_path):
|
if os.path.isfile(old_setting_path):
|
||||||
os.remove(old_setting_path)
|
os.remove(old_setting_path)
|
||||||
@ -362,8 +483,6 @@ def generate_src():
|
|||||||
:return: the error message
|
:return: the error message
|
||||||
"""
|
"""
|
||||||
generator_config_data = request.json if request.method == "POST" else request.args
|
generator_config_data = request.json if request.method == "POST" else request.args
|
||||||
print("generate_src")
|
|
||||||
print(generator_config_data)
|
|
||||||
|
|
||||||
src_type = generator_config_data['type']
|
src_type = generator_config_data['type']
|
||||||
board_info = generator_config_data['board_info']
|
board_info = generator_config_data['board_info']
|
||||||
@ -373,6 +492,8 @@ def generate_src():
|
|||||||
scenario_setting = generator_config_data['scenario_setting']
|
scenario_setting = generator_config_data['scenario_setting']
|
||||||
scenario_setting_xml = os.path.join(current_app.config.get('CONFIG_PATH'), board_type,
|
scenario_setting_xml = os.path.join(current_app.config.get('CONFIG_PATH'), board_type,
|
||||||
'user_defined', scenario_setting+'.xml')
|
'user_defined', scenario_setting+'.xml')
|
||||||
|
src_path = generator_config_data['src_path']
|
||||||
|
print(src_path)
|
||||||
launch_setting_xml = None
|
launch_setting_xml = None
|
||||||
if 'launch_setting' in generator_config_data:
|
if 'launch_setting' in generator_config_data:
|
||||||
launch_setting = generator_config_data['launch_setting']
|
launch_setting = generator_config_data['launch_setting']
|
||||||
@ -384,14 +505,14 @@ def generate_src():
|
|||||||
if src_type == 'generate_config_src':
|
if src_type == 'generate_config_src':
|
||||||
try:
|
try:
|
||||||
from board_config.board_cfg_gen import ui_entry_api
|
from board_config.board_cfg_gen import ui_entry_api
|
||||||
error_list = ui_entry_api(board_info_xml, scenario_setting_xml)
|
error_list = ui_entry_api(board_info_xml, scenario_setting_xml, src_path)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
status = 'fail'
|
status = 'fail'
|
||||||
error_list = {'board setting error': str(error)}
|
error_list = {'board setting error': str(error)}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from scenario_config.scenario_cfg_gen import ui_entry_api
|
from scenario_config.scenario_cfg_gen import ui_entry_api
|
||||||
error_list = ui_entry_api(board_info_xml, scenario_setting_xml)
|
error_list = ui_entry_api(board_info_xml, scenario_setting_xml, src_path)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
status = 'fail'
|
status = 'fail'
|
||||||
error_list = {'scenario setting error': str(error)}
|
error_list = {'scenario setting error': str(error)}
|
||||||
@ -406,15 +527,15 @@ def generate_src():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from launch_config.launch_cfg_gen import ui_entry_api
|
from launch_config.launch_cfg_gen import ui_entry_api
|
||||||
error_list = ui_entry_api(board_info_xml, scenario_setting_xml, launch_setting_xml)
|
error_list = ui_entry_api(board_info_xml, scenario_setting_xml, launch_setting_xml, src_path)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
status = 'fail'
|
status = 'fail'
|
||||||
error_list = {'launch setting error': str(error)}
|
error_list = {'launch setting error': str(error)}
|
||||||
else:
|
else:
|
||||||
status = 'fail'
|
status = 'fail'
|
||||||
error_list = {'error': 'generator type not specified'}
|
error_list = {'error': 'generator type not specified'}
|
||||||
|
|
||||||
msg = {'status': status, 'error_list': error_list}
|
msg = {'status': status, 'error_list': error_list}
|
||||||
print(msg)
|
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
||||||
@ -497,7 +618,7 @@ def select_board():
|
|||||||
board_info = data['board_info']
|
board_info = data['board_info']
|
||||||
current_app.config.update(BOARD_INFO=board_info)
|
current_app.config.update(BOARD_INFO=board_info)
|
||||||
|
|
||||||
board_type = get_board_info_type(board_info)
|
board_type = get_board_type(board_info)
|
||||||
current_app.config.update(BOARD_TYPE=board_type)
|
current_app.config.update(BOARD_TYPE=board_type)
|
||||||
if board_type:
|
if board_type:
|
||||||
return board_type
|
return board_type
|
||||||
@ -658,7 +779,7 @@ def get_board_list():
|
|||||||
return board_info_list
|
return board_info_list
|
||||||
|
|
||||||
|
|
||||||
def get_xml_configs(user_defined=False):
|
def get_xml_configs(user_defined=True):
|
||||||
"""
|
"""
|
||||||
get xml config related variables
|
get xml config related variables
|
||||||
:return: board_info, board_config, scenario_config, launch_config
|
:return: board_info, board_config, scenario_config, launch_config
|
||||||
@ -666,22 +787,26 @@ def get_xml_configs(user_defined=False):
|
|||||||
|
|
||||||
config_path = None
|
config_path = None
|
||||||
board_info = current_app.config.get('BOARD_INFO')
|
board_info = current_app.config.get('BOARD_INFO')
|
||||||
|
board_type = get_board_type(board_info)
|
||||||
board_type = get_board_info_type(board_info)
|
|
||||||
if board_type is not None:
|
if board_type is not None:
|
||||||
config_path = os.path.join(current_app.config.get('CONFIG_PATH'), board_type)
|
config_path = os.path.join(current_app.config.get('CONFIG_PATH'), board_type)
|
||||||
|
|
||||||
if user_defined:
|
scenario_config = XmlConfig(config_path, not user_defined)
|
||||||
scenario_config = XmlConfig(config_path, False)
|
launch_config = XmlConfig(config_path, not user_defined)
|
||||||
launch_config = XmlConfig(config_path, False)
|
|
||||||
else:
|
|
||||||
scenario_config = XmlConfig(config_path)
|
|
||||||
launch_config = XmlConfig(config_path)
|
|
||||||
|
|
||||||
return board_info, board_type, scenario_config, launch_config
|
return board_info, board_type, scenario_config, launch_config
|
||||||
|
|
||||||
|
|
||||||
def get_generic_scenario_config(scenario_config):
|
def get_generic_scenario_config(scenario_config, add_vm_type=None):
|
||||||
|
|
||||||
|
if add_vm_type is not None:
|
||||||
|
config_path = os.path.join(current_app.config.get('CONFIG_PATH'), 'template')
|
||||||
|
generic_scenario_config = XmlConfig(config_path)
|
||||||
|
if os.path.isfile(os.path.join(config_path, add_vm_type + '.xml')):
|
||||||
|
generic_scenario_config.set_curr(add_vm_type)
|
||||||
|
return generic_scenario_config
|
||||||
|
else:
|
||||||
|
return None
|
||||||
config_path = os.path.join(current_app.config.get('CONFIG_PATH'), 'generic')
|
config_path = os.path.join(current_app.config.get('CONFIG_PATH'), 'generic')
|
||||||
generic_scenario_config = XmlConfig(config_path)
|
generic_scenario_config = XmlConfig(config_path)
|
||||||
for file in os.listdir(config_path):
|
for file in os.listdir(config_path):
|
||||||
@ -698,19 +823,62 @@ def get_generic_scenario_config(scenario_config):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_board_info_type(board_info):
|
def get_board_config(board_info):
|
||||||
|
"""
|
||||||
|
get board config
|
||||||
|
:param board_info: the board info file
|
||||||
|
:return: the board type
|
||||||
|
"""
|
||||||
|
board_config = None
|
||||||
|
if board_info is not None:
|
||||||
|
board_config = XmlConfig(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res'))
|
||||||
|
board_config.set_curr(board_info)
|
||||||
|
|
||||||
|
return board_config
|
||||||
|
|
||||||
|
|
||||||
|
def get_board_type(board_info):
|
||||||
"""
|
"""
|
||||||
get board info type
|
get board info type
|
||||||
:param board_info: the board info file
|
:param board_info: the board info file
|
||||||
:return: the board type
|
:return: the board type
|
||||||
"""
|
"""
|
||||||
|
board_config = get_board_config(board_info)
|
||||||
board_type = None
|
board_type = None
|
||||||
if board_info is not None:
|
if board_config is not None:
|
||||||
board_info_config = XmlConfig(os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
board_info_root = board_config.get_curr_root()
|
||||||
'res'))
|
|
||||||
board_info_config.set_curr(board_info)
|
|
||||||
board_info_root = board_info_config.get_curr_root()
|
|
||||||
if board_info_root and 'board' in board_info_root.attrib:
|
if board_info_root and 'board' in board_info_root.attrib:
|
||||||
board_type = board_info_root.attrib['board']
|
board_type = board_info_root.attrib['board']
|
||||||
|
|
||||||
return board_type
|
return board_type
|
||||||
|
|
||||||
|
|
||||||
|
def get_board_info(board_info):
|
||||||
|
"""
|
||||||
|
get board info type
|
||||||
|
:param board_info: the board info file
|
||||||
|
:return: the board type
|
||||||
|
"""
|
||||||
|
board_config = get_board_config(board_info)
|
||||||
|
bios_info = None
|
||||||
|
base_board_info = None
|
||||||
|
if board_config is not None:
|
||||||
|
board_info_root = board_config.get_curr_root()
|
||||||
|
if board_info_root:
|
||||||
|
for item in board_info_root.getchildren():
|
||||||
|
if item.tag == 'BIOS_INFO':
|
||||||
|
for line in item.text.split('\n'):
|
||||||
|
if line.strip() != '':
|
||||||
|
if bios_info is None:
|
||||||
|
bios_info = line.strip()
|
||||||
|
else:
|
||||||
|
bios_info += ('\n' + line.strip())
|
||||||
|
elif item.tag == 'BASE_BOARD_INFO':
|
||||||
|
for line in item.text.split('\n'):
|
||||||
|
if line.strip() != '':
|
||||||
|
if base_board_info is None:
|
||||||
|
base_board_info = line.strip()
|
||||||
|
else:
|
||||||
|
base_board_info += ('\n' + line.strip())
|
||||||
|
|
||||||
|
return (bios_info, base_board_info)
|
Loading…
Reference in New Issue
Block a user