@@ -169,12 +169,26 @@ def save_scenario():
169
169
scenario_config .set_curr (old_scenario_name )
170
170
for key in scenario_config_data :
171
171
if key not in ['old_scenario_name' , 'new_scenario_name' , 'board_info_file' ,
172
- 'board_info_upload' ]:
172
+ 'board_info_upload' , 'generator' ]:
173
173
if isinstance (scenario_config_data [key ], list ):
174
174
scenario_config .set_curr_list (scenario_config_data [key ], * tuple (key .split (',' )))
175
175
else :
176
176
scenario_config .set_curr_value (scenario_config_data [key ], * tuple (key .split (',' )))
177
177
178
+ if scenario_config_data ['generator' ] == 'remove_vm_kata' :
179
+ scenario_config .delete_curr_key ('vm:desc=specific for Kata' )
180
+ elif scenario_config_data ['generator' ] == 'add_vm_kata' :
181
+ # clone vm kata from generic config
182
+ generic_scenario_config = get_generic_scenario_config (scenario_config )
183
+ generic_scenario_config_root = generic_scenario_config .get_curr_root ()
184
+ elem_kata = None
185
+ for vm in generic_scenario_config_root .getchildren ():
186
+ if 'desc' in vm .attrib and vm .attrib ['desc' ] == 'specific for Kata' :
187
+ elem_kata = vm
188
+ break
189
+ if elem_kata is not None :
190
+ scenario_config .clone_curr_elem (elem_kata )
191
+
178
192
tmp_scenario_file = os .path .join (scenario_path , 'user_defined' ,
179
193
'tmp_' + scenario_config_data ['new_scenario_name' ]+ '.xml' )
180
194
# if os.path.isfile(tmp_scenario_file):
@@ -191,6 +205,8 @@ def save_scenario():
191
205
tmp_scenario_file )
192
206
print ('vm_info: ' , vm_info )
193
207
except Exception as error :
208
+ if os .path .isfile (tmp_scenario_file ):
209
+ os .remove (tmp_scenario_file )
194
210
return {'status' : 'fail' , 'file_name' : new_scenario_name ,
195
211
'rename' : rename , 'error_list' : {'error' : str (error )}}
196
212
@@ -280,6 +296,8 @@ def save_launch():
280
296
tmp_launch_file )
281
297
print (pthru_sel , dm_value )
282
298
except Exception as error :
299
+ if os .path .isfile (tmp_launch_file ):
300
+ os .remove (tmp_launch_file )
283
301
return {'status' : 'fail' , 'file_name' : launch_config_data ['new_launch_name' ],
284
302
'rename' : rename , 'error_list' : {'launch config error' : str (error )}}
285
303
@@ -663,6 +681,23 @@ def get_xml_configs(user_defined=False):
663
681
return board_info , board_type , scenario_config , launch_config
664
682
665
683
684
+ def get_generic_scenario_config (scenario_config ):
685
+ config_path = os .path .join (current_app .config .get ('CONFIG_PATH' ), 'generic' )
686
+ generic_scenario_config = XmlConfig (config_path )
687
+ for file in os .listdir (config_path ):
688
+ if os .path .isfile (os .path .join (config_path , file )) and \
689
+ os .path .splitext (file )[1 ] == '.xml' :
690
+ generic_scenario_config .set_curr (os .path .splitext (file )[0 ])
691
+ generic_scenario_config_root = generic_scenario_config .get_curr_root ()
692
+ if 'scenario' in generic_scenario_config_root .attrib \
693
+ and 'uos_launcher' not in generic_scenario_config_root .attrib \
694
+ and generic_scenario_config_root .attrib ['scenario' ] == \
695
+ scenario_config .get_curr_root ().attrib ['scenario' ]:
696
+ return generic_scenario_config
697
+
698
+ return None
699
+
700
+
666
701
def get_board_info_type (board_info ):
667
702
"""
668
703
get board info type
0 commit comments