mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-10 05:09:01 +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:
@@ -10,7 +10,6 @@ $().ready(function(){
|
||||
formFile.append("name", file_name);
|
||||
formFile.append("file", fileObj);
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: "../upload_board_info",
|
||||
data: formFile,
|
||||
@@ -77,7 +76,7 @@ $().ready(function(){
|
||||
alert('Scenario setting import successfully with name: '+file_name);
|
||||
}
|
||||
window.location = 'http://'
|
||||
+ window.location.host+"/scenario/user_defined_" + file_name;
|
||||
+ window.location.host+"/scenario/" + file_name;
|
||||
},
|
||||
error: function(e){
|
||||
console.log(e.status);
|
||||
@@ -123,7 +122,7 @@ $().ready(function(){
|
||||
alert('Launch setting import successfully with name: '+file_name);
|
||||
}
|
||||
window.location = 'http://'
|
||||
+ window.location.host+"/launch/user_defined_" + file_name;
|
||||
+ window.location.host+"/launch/" + file_name;
|
||||
},
|
||||
error: function(e){
|
||||
console.log(e.status);
|
||||
@@ -177,10 +176,6 @@ $().ready(function(){
|
||||
|
||||
$('#remove_scenario').on('click', function() {
|
||||
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();
|
||||
if (board_info==null || board_info=='') {
|
||||
@@ -230,10 +225,6 @@ $().ready(function(){
|
||||
|
||||
$('#remove_launch').on('click', function() {
|
||||
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();
|
||||
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() {
|
||||
var dataId = $(this).data('id');
|
||||
$("#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() {
|
||||
var dataId = $(this).data('id');
|
||||
$("#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(){
|
||||
|
||||
var id = $(this).attr('id');
|
||||
var value = $(this).val();
|
||||
show_com_target(id, value);
|
||||
@@ -292,21 +374,23 @@ $().ready(function(){
|
||||
var id = $(item).attr('id');
|
||||
var value = $(item).val();
|
||||
show_com_target(id, value);
|
||||
})
|
||||
});
|
||||
|
||||
$(document).on('click', "button:contains('+')", function() {
|
||||
if($(this).text() != '+')
|
||||
return;
|
||||
var add_vcpu_id = $(this).attr('id');
|
||||
var id = add_vcpu_id.replace('add_vcpu_', '');
|
||||
var curr_item_id = $(this).attr('id');
|
||||
var curr_id = curr_item_id.substr(curr_item_id.lastIndexOf('_')+1);
|
||||
var config_item = $(this).parent().parent();
|
||||
var config_item_added = config_item.clone();
|
||||
var id_added = (parseInt(id)+1).toString();
|
||||
config_item_added.find("button:contains('+')").attr('id', 'add_vcpu_'+id_added);
|
||||
config_item_added.find("button:contains('-')").attr('id', 'remove_vcpu_'+id_added);
|
||||
var id_added = (parseInt(curr_id)+1).toString();
|
||||
var id_pre_added = curr_item_id.substr(0, curr_item_id.lastIndexOf('_'));
|
||||
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("label:first").text("");
|
||||
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.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){
|
||||
var board_info = $("text#board_type").text();
|
||||
@@ -367,39 +525,44 @@ function save_scenario(generator=null){
|
||||
}
|
||||
|
||||
scenario_config = {
|
||||
old_scenario_name: $("#old_scenario_name").text(),
|
||||
new_scenario_name: $("#new_scenario_name").val(),
|
||||
generator: generator
|
||||
}
|
||||
old_scenario_name: $("#old_scenario_name").text(),
|
||||
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(){
|
||||
var id = $(this).attr('id');
|
||||
var value = $(this).val();
|
||||
if(id!='new_scenario_name' && id!='board_info_file'
|
||||
&& id!='board_info_upload' && id!="scenario_file") {
|
||||
var value = $(this).val();
|
||||
if(id!='new_scenario_name' && id!='new_scenario_name2' && id!='board_info_file' && id!='board_info_upload'
|
||||
&& id!='scenario_file' && id!='create_name' && id!='load_scenario_name2' && id!='load_launch_name2'
|
||||
&& id!='src_path') {
|
||||
scenario_config[id] = value;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$("textarea").each(function(){
|
||||
var id = $(this).attr('id');
|
||||
var value = $(this).val();
|
||||
if(id!='new_scenario_name' && id!='board_info_file'
|
||||
&& id!='board_info_upload' && id!="scenario_file") {
|
||||
scenario_config[id] = value;
|
||||
}
|
||||
var value = $(this).val();
|
||||
scenario_config[id] = value;
|
||||
})
|
||||
|
||||
$("select").each(function(){
|
||||
var id = $(this).attr('id');
|
||||
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) {
|
||||
scenario_config[id].push(value);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
})
|
||||
@@ -407,67 +570,111 @@ function save_scenario(generator=null){
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
contentType: "application/json;charset=UTF-8",
|
||||
url : "../save_scenario",
|
||||
url : "../check_setting_exist",
|
||||
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") {
|
||||
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;
|
||||
exist = result.exist
|
||||
create_flag = true
|
||||
if(exist == "yes") {
|
||||
overwirte_confirm_message = 'Setting name: ' + scenario_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
|
||||
}
|
||||
}
|
||||
else if(status != 'success') {
|
||||
alert(JSON.stringify(error_list));
|
||||
if(create_flag == true) {
|
||||
$.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){
|
||||
@@ -487,14 +694,22 @@ function save_launch(generator=null) {
|
||||
}
|
||||
|
||||
launch_config = {
|
||||
old_launch_name: $("#old_launch_name").text(),
|
||||
new_launch_name: $("#new_launch_name").val(),
|
||||
scenario_name: scenario_name
|
||||
}
|
||||
old_launch_name: $("#old_launch_name").text(),
|
||||
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(){
|
||||
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
|
||||
|| id.indexOf('virtio_devices,input')>=0) {
|
||||
@@ -503,98 +718,145 @@ function save_launch(generator=null) {
|
||||
} else {
|
||||
launch_config[id] = [value];
|
||||
}
|
||||
} else if(id!='new_launch_name' && id!='board_info_file'
|
||||
&& id!='board_info_upload' && id!='scenario_name'
|
||||
&& id!="launch_file") {
|
||||
} else if(id!='new_launch_name' && id!='new_launch_name2' && id!='board_info_file' && id!='board_info_upload'
|
||||
&& id!="launch_file" && id!='create_name' && id!='load_scenario_name2' && id!='load_launch_name2'
|
||||
&& id!='src_path') {
|
||||
launch_config[id] = value;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$("select").each(function(){
|
||||
var id = $(this).attr('id');
|
||||
var value = $(this).val();
|
||||
if(id!='board_info') {
|
||||
var value = $(this).val();
|
||||
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;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$("textarea").each(function(){
|
||||
var id = $(this).attr('id');
|
||||
var value = $(this).val();
|
||||
if(id!='new_scenario_name' && id!='board_info_file'
|
||||
&& id!='board_info_upload' && id!="scenario_file") {
|
||||
launch_config[id] = value;
|
||||
}
|
||||
var value = $(this).val();
|
||||
launch_config[id] = value;
|
||||
})
|
||||
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
contentType: "application/json;charset=UTF-8",
|
||||
url : "../save_launch",
|
||||
url : "../check_setting_exist",
|
||||
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 != 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;
|
||||
exist = result.exist
|
||||
create_flag = true
|
||||
if(exist == "yes") {
|
||||
overwirte_confirm_message = 'Setting name: ' + launch_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
|
||||
}
|
||||
}
|
||||
else if(status != 'success') {
|
||||
alert(JSON.stringify(error_list));
|
||||
if(create_flag == true) {
|
||||
$.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){
|
||||
|
Reference in New Issue
Block a user