From b9a7cf3b24c0679f1dead3ec529f37f4f244c9df Mon Sep 17 00:00:00 2001 From: Shuang Zheng Date: Tue, 21 Apr 2020 18:43:34 +0800 Subject: [PATCH] acrn-config: assign VM IDs for dynamic scenario and launch setting When dynamically creating or adding or deleting VMs, acrn config app will assign VM IDs for the VMs with the orders of prelaunched VMs and SOS VM and postlaunched VMs to be consistent with the VM order of vm_configs in vm configuration. When dynamically creating launch scripts, acrn config app will let users to specify the VM ID before launch setting. Tracked-On: #4641 Signed-off-by: Shuang Zheng Acked-by: Terry Zou --- misc/acrn-config/config_app/controller.py | 2 +- misc/acrn-config/config_app/static/main.js | 32 +++- .../config_app/templates/launch.html | 23 ++- misc/acrn-config/config_app/views.py | 172 ++++++++++++++---- ...{LAUNCH_RTVM.xml => LAUNCH_POST_RT_VM.xml} | 2 +- ...STANDARD_VM.xml => LAUNCH_POST_STD_VM.xml} | 0 6 files changed, 185 insertions(+), 46 deletions(-) rename misc/acrn-config/xmls/config-xmls/template/{LAUNCH_RTVM.xml => LAUNCH_POST_RT_VM.xml} (97%) rename misc/acrn-config/xmls/config-xmls/template/{LAUNCH_STANDARD_VM.xml => LAUNCH_POST_STD_VM.xml} (100%) diff --git a/misc/acrn-config/config_app/controller.py b/misc/acrn-config/config_app/controller.py index dd7baacdf..d5aee2aad 100644 --- a/misc/acrn-config/config_app/controller.py +++ b/misc/acrn-config/config_app/controller.py @@ -84,7 +84,7 @@ class XmlConfig: :return: None. :raises: ValueError, OSError, SyntaxError. """ - if self._xml_path is None: + if self._xml_path is None or xml is None: return try: self._curr_xml = xml diff --git a/misc/acrn-config/config_app/static/main.js b/misc/acrn-config/config_app/static/main.js index 1c9723b6c..eb235ef70 100644 --- a/misc/acrn-config/config_app/static/main.js +++ b/misc/acrn-config/config_app/static/main.js @@ -348,7 +348,7 @@ $().ready(function(){ $(document).on('click', "#add_launch_submit", function() { var curr_vm_id = $(this).data('id'); - save_launch('add_vm:'+curr_vm_id) + save_launch('add_vm:'+curr_vm_id); }); $('#add_launch_script').on('click', function() { @@ -364,6 +364,31 @@ $().ready(function(){ } }); + $(document).on('change', "select#scenario_name", function() { + data = {scenario_name: $(this).val(), + launch_name: $('text#old_launch_name').text()}; + $.ajax({ + type : "POST", + contentType: "application/json;charset=UTF-8", + url : "../get_post_launch_vms", + data : JSON.stringify(data), + success : function(result) { + console.log(result); + vm_list = result.vm_list + $('select#add_launch_type').empty().selectpicker('refresh'); + for(i in vm_list) { + var option = vm_list[i][1]+' ( ID : '+vm_list[i][0]+' )' + $('select#add_launch_type').append( + '').selectpicker('refresh'); + } + }, + error : function(e){ + console.log(e.status); + console.log(e.responseText); + } + }); + }); + $("select[ID$='vuart:id=1,base']").change(function(){ var id = $(this).attr('id'); var value = $(this).val(); @@ -416,6 +441,11 @@ $().ready(function(){ }) +$(window).load(function () { +  $("select#scenario_name").change(); +}); + + function show_com_target(id, value) { if(id==null || id=='undefined') { diff --git a/misc/acrn-config/config_app/templates/launch.html b/misc/acrn-config/config_app/templates/launch.html index 6e236be86..1ddf101d9 100644 --- a/misc/acrn-config/config_app/templates/launch.html +++ b/misc/acrn-config/config_app/templates/launch.html @@ -43,20 +43,18 @@ the launch scripts will be generated into misc/acrn-config/xmls/config-xmls/[boa