acrn-config: remove git check and avoid to generate patch for config files

Remove '--enable_commit' argument since acrn-config will not use git tool any
more.

Tracked-On: #3854
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
Wei Liu 2020-03-13 16:33:25 +08:00 committed by wenlingz
parent 48fdeb2572
commit 2eb8e0f7a4
11 changed files with 49 additions and 193 deletions

View File

@ -1,4 +1,4 @@
Please run board_cfg_gen.py to generate board related configuration patch, the patch would be applied on current acrn-hypervisor git tree automatically. Please run board_cfg_gen.py to generate board related configuration files.
usage: python3 board_cfg_gen.py [h] --board <board_info_file> --scenario <scenario_info_file> usage: python3 board_cfg_gen.py [h] --board <board_info_file> --scenario <scenario_info_file>
positional arguments: positional arguments:

View File

@ -37,15 +37,14 @@ def main(args):
:param args: it is a command line args for the script :param args: it is a command line args for the script
""" """
err_dic = {} err_dic = {}
config_srcs = []
config_dirs = [] config_dirs = []
(err_dic, board_info_file, scenario_info_file, enable_commit) = board_cfg_lib.get_param(args) (err_dic, board_info_file, scenario_info_file) = board_cfg_lib.get_param(args)
if err_dic: if err_dic:
return err_dic return err_dic
# check env # check env
err_dic = board_cfg_lib.prepare(enable_commit) err_dic = board_cfg_lib.prepare()
if err_dic: if err_dic:
return err_dic return err_dic
@ -77,12 +76,6 @@ def main(args):
config_misc_cfg = config_dirs[0] + '/' + GEN_FILE[3] config_misc_cfg = config_dirs[0] + '/' + GEN_FILE[3]
config_board_kconfig = ACRN_CONFIG + board + GEN_FILE[4] config_board_kconfig = ACRN_CONFIG + board + GEN_FILE[4]
config_srcs.append(config_pci)
config_srcs.append(config_board)
config_srcs.append(config_platform)
config_srcs.append(config_misc_cfg)
config_srcs.append(config_board_kconfig)
# generate board.c # generate board.c
with open(config_board, 'w+') as config: with open(config_board, 'w+') as config:
err_dic = board_c.generate_file(config) err_dic = board_c.generate_file(config)
@ -110,33 +103,21 @@ def main(args):
if err_dic: if err_dic:
return err_dic return err_dic
config_str = 'Config files'
gen_str = 'generated'
# move changes to patch, and apply to the source code
if enable_commit:
err_dic = board_cfg_lib.gen_patch(config_srcs, "board " + board)
config_str = 'Config patch'
gen_str = 'committed'
if board not in board_cfg_lib.BOARD_NAMES and not err_dic: if board not in board_cfg_lib.BOARD_NAMES and not err_dic:
print("{} for NEW board {} is {} successfully!".format(config_str, board, gen_str)) print("Config files for NEW board {} is generated successfully!".format(board ))
elif not err_dic: elif not err_dic:
print("{} for {} is {} successfully!".format(config_str, board, gen_str)) print("Config files for {} is generated successfully!".format(board))
else: else:
print("{} for {} is failed".format(config_str, board)) print("Config files for {} is failed".format(board))
return err_dic return err_dic
def ui_entry_api(board_info,scenario_info, enable_commit=False): def ui_entry_api(board_info, scenario_info):
git_env_check = False
arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info] arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info]
if enable_commit:
arg_list.append('--enable_commit')
git_env_check = True
err_dic = board_cfg_lib.prepare(git_env_check) err_dic = board_cfg_lib.prepare()
if err_dic: if err_dic:
return err_dic return err_dic

View File

@ -378,23 +378,20 @@ def generate_src():
launch_setting = generator_config_data['launch_setting'] launch_setting = generator_config_data['launch_setting']
launch_setting_xml = os.path.join(current_app.config.get('CONFIG_PATH'), launch_setting_xml = os.path.join(current_app.config.get('CONFIG_PATH'),
board_type, 'user_defined', launch_setting + '.xml') board_type, 'user_defined', launch_setting + '.xml')
commit = False
if 'commit' in generator_config_data and generator_config_data['commit'] == 'yes':
commit = True
msg = {} msg = {}
error_list = {} error_list = {}
status = 'success' status = 'success'
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, commit) error_list = ui_entry_api(board_info_xml, scenario_setting_xml)
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, commit) error_list = ui_entry_api(board_info_xml, scenario_setting_xml)
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)}
@ -409,7 +406,7 @@ 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, commit) error_list = ui_entry_api(board_info_xml, scenario_setting_xml, launch_setting_xml)
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)}

View File

@ -1,4 +1,4 @@
Please run launch_cfg_gen.py to generate board related configuration patch, the patch would be applied on current acrn-hypervisor git tree automatically. Please run launch_cfg_gen.py to generate board related configuration files.
usage: python3 launch_cfg_gen.py [h] --board <board_info_file> --scenario <scenario_info_file> --launch <launch_info_file> usage: python3 launch_cfg_gen.py [h] --board <board_info_file> --scenario <scenario_info_file> --launch <launch_info_file>
positional arguments: positional arguments:

View File

@ -85,17 +85,12 @@ def validate_launch_setting(board_info, scenario_info, launch_info):
return (launch_cfg_lib.ERR_LIST, pt_sel, virtio, dm) return (launch_cfg_lib.ERR_LIST, pt_sel, virtio, dm)
def ui_entry_api(board_info, scenario_info, launch_info, enable_commit=False): def ui_entry_api(board_info, scenario_info, launch_info):
err_dic = {} err_dic = {}
git_env_check = False
arg_list = ['launch_cfg_gen.py', '--board', board_info, '--scenario', scenario_info, '--launch', launch_info, '--uosid', '0'] arg_list = ['launch_cfg_gen.py', '--board', board_info, '--scenario', scenario_info, '--launch', launch_info, '--uosid', '0']
if enable_commit: err_dic = launch_cfg_lib.prepare()
arg_list.append('--enable_commit')
git_env_check = True
err_dic = launch_cfg_lib.prepare(git_env_check)
if err_dic: if err_dic:
return err_dic return err_dic
@ -147,15 +142,14 @@ def main(args):
This is main function to start generate launch script This is main function to start generate launch script
:param args: it is a command line args for the script :param args: it is a command line args for the script
""" """
config_srcs = []
# get parameters # get parameters
(err_dic, board_info_file, scenario_info_file, launch_info_file, vm_th, enable_commit) = launch_cfg_lib.get_param(args) (err_dic, board_info_file, scenario_info_file, launch_info_file, vm_th) = launch_cfg_lib.get_param(args)
if err_dic: if err_dic:
return err_dic return err_dic
# check env # check env
err_dic = launch_cfg_lib.prepare(enable_commit) err_dic = launch_cfg_lib.prepare()
if err_dic: if err_dic:
return err_dic return err_dic
@ -210,9 +204,7 @@ def main(args):
# generate launch script # generate launch script
if vm_th: if vm_th:
script_name = "launch_uos_id{}.sh".format(vm_th) script_name = "launch_uos_id{}.sh".format(vm_th)
commit_msg = script_name
launch_script_file = output + script_name launch_script_file = output + script_name
config_srcs.append(launch_script_file)
with open(launch_script_file, mode = 'w', newline=None, encoding='utf-8') as config: with open(launch_script_file, mode = 'w', newline=None, encoding='utf-8') as config:
err_dic = generate_script_file(names, pt_sel, virt_io.dev, dm.args, vm_th, config) err_dic = generate_script_file(names, pt_sel, virt_io.dev, dm.args, vm_th, config)
if err_dic: if err_dic:
@ -221,26 +213,15 @@ def main(args):
for post_vm_i in post_num_list: for post_vm_i in post_num_list:
script_name = "launch_uos_id{}.sh".format(post_vm_i) script_name = "launch_uos_id{}.sh".format(post_vm_i)
launch_script_file = output + script_name launch_script_file = output + script_name
config_srcs.append(launch_script_file)
with open(launch_script_file, mode = 'w', newline='\n', encoding='utf-8') as config: with open(launch_script_file, mode = 'w', newline='\n', encoding='utf-8') as config:
err_dic = generate_script_file(names, pt_sel, virt_io.dev, dm.args, post_vm_i, config) err_dic = generate_script_file(names, pt_sel, virt_io.dev, dm.args, post_vm_i, config)
if err_dic: if err_dic:
return err_dic return err_dic
commit_msg = "launch_uos_id{}.sh".format(launch_vm_count)
config_str = 'Config files'
gen_str = 'generated'
# move changes to patch, and apply to the source code
if enable_commit:
err_dic = launch_cfg_lib.gen_patch(config_srcs, commit_msg)
config_str = 'Config patch'
gen_str = 'committed'
if not err_dic: if not err_dic:
print("{} for {} is {} successfully!".format(config_str, commit_msg, gen_str)) print("Launch files in {} is generated successfully!".format(output))
else: else:
print("{} for {} is failed".format(config_str, commit_msg)) print("Launch files generate failed".format(output))
return err_dic return err_dic

View File

@ -45,9 +45,9 @@ SIZE_2G = common.SIZE_2G
SIZE_4G = common.SIZE_4G SIZE_4G = common.SIZE_4G
def prepare(check_git): def prepare():
""" check environment """ """ check environment """
return common.check_env(check_git) return common.check_env()
def print_yel(msg, warn=False): def print_yel(msg, warn=False):
@ -177,16 +177,6 @@ def get_sub_leaf_tag(config_file, branch_tag, tag_str):
return common.get_leaf_tag_val(config_file, branch_tag, tag_str) return common.get_leaf_tag_val(config_file, branch_tag, tag_str)
def gen_patch(srcs_list, board_name):
"""
Generate patch and apply to local source code
:param srcs_list: it is a list what contains source files
:param board_name: board name
"""
err_dic = common.add_to_patch(srcs_list, board_name)
return err_dic
def is_hpa_size(hpa_size_list): def is_hpa_size(hpa_size_list):
""" """
This is identify if the host physical size list is correct format This is identify if the host physical size list is correct format

View File

@ -81,10 +81,9 @@ def print_if_red(msg, err=False):
def usage(file_name): def usage(file_name):
""" This is usage for how to use this tool """ """ This is usage for how to use this tool """
print("usage= {} [h] ".format(file_name), end="") print("usage= {} [h] ".format(file_name), end="")
print("--board <board_info_file> --scenario <scenario_info_file> [--enable_commit]") print("--board <board_info_file> --scenario <scenario_info_file>")
print('board_info_file : file name of the board info') print('board_info_file : file name of the board info')
print('scenario_info_file : file name of the scenario info') print('scenario_info_file : file name of the scenario info')
print('enable_commit: enable the flag that git add/commit the generate files to the code base. without --enable_commit will not commit this source code')
def get_param(args): def get_param(args):
@ -95,51 +94,41 @@ def get_param(args):
err_dic = {} err_dic = {}
board_info_file = False board_info_file = False
scenario_info_file = False scenario_info_file = False
enable_commit = False
if '--board' not in args or '--scenario' not in args: if '--board' not in args or '--scenario' not in args:
usage(args[0]) usage(args[0])
err_dic['common error: get wrong parameter'] = "wrong usage" err_dic['common error: get wrong parameter'] = "wrong usage"
return (err_dic, board_info_file, scenario_info_file, enable_commit) return (err_dic, board_info_file, scenario_info_file)
args_list = args[1:] args_list = args[1:]
(optlist, args_list) = getopt.getopt(args_list, '', ['board=', 'scenario=', 'enable_commit']) (optlist, args_list) = getopt.getopt(args_list, '', ['board=', 'scenario='])
for arg_k, arg_v in optlist: for arg_k, arg_v in optlist:
if arg_k == '--board': if arg_k == '--board':
board_info_file = arg_v board_info_file = arg_v
if arg_k == '--scenario': if arg_k == '--scenario':
scenario_info_file = arg_v scenario_info_file = arg_v
if arg_k == '--enable_commit':
enable_commit = True
if not board_info_file or not scenario_info_file: if not board_info_file or not scenario_info_file:
usage(args[0]) usage(args[0])
err_dic['common error: get wrong parameter'] = "wrong usage" err_dic['common error: get wrong parameter'] = "wrong usage"
return (err_dic, board_info_file, scenario_info_file, enable_commit) return (err_dic, board_info_file, scenario_info_file)
if not os.path.exists(board_info_file): if not os.path.exists(board_info_file):
err_dic['common error: get wrong parameter'] = "{} is not exist!".format(board_info_file) err_dic['common error: get wrong parameter'] = "{} is not exist!".format(board_info_file)
return (err_dic, board_info_file, scenario_info_file, enable_commit) return (err_dic, board_info_file, scenario_info_file)
if not os.path.exists(scenario_info_file): if not os.path.exists(scenario_info_file):
err_dic['common error: get wrong parameter'] = "{} is not exist!".format(scenario_info_file) err_dic['common error: get wrong parameter'] = "{} is not exist!".format(scenario_info_file)
return (err_dic, board_info_file, scenario_info_file, enable_commit) return (err_dic, board_info_file, scenario_info_file)
return (err_dic, board_info_file, scenario_info_file, enable_commit) return (err_dic, board_info_file, scenario_info_file)
def check_env(check_git=False): def check_env():
""" Prepare to check the environment """ """ Prepare to check the environment """
err_dic = {} err_dic = {}
bin_list = [] bin_list = []
if check_git:
bin_list.append('git')
usr_dir = os.environ['HOME']
if not os.path.isfile("{}/.gitconfig".format(usr_dir)):
err_dic['commn error: check env failed'] = "git not configured!"
for excute in bin_list: for excute in bin_list:
res = subprocess.Popen("which {}".format(excute), shell=True, stdout=subprocess.PIPE, res = subprocess.Popen("which {}".format(excute), shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True) stderr=subprocess.PIPE, close_fds=True)
@ -149,14 +138,6 @@ def check_env(check_git=False):
if not line: if not line:
err_dic['commn error: check env failed'] = "'{}' not found, please install it!".format(excute) err_dic['commn error: check env failed'] = "'{}' not found, please install it!".format(excute)
if excute == "git":
res = subprocess.Popen("git tag -l", shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True)
line = res.stdout.readline().decode("ascii")
if "acrn" not in line:
err_dic['commn error: check env failed'] = "Run this tool in acrn-hypervisor mainline source code!"
for py_cache in PY_CACHES: for py_cache in PY_CACHES:
if os.path.exists(py_cache): if os.path.exists(py_cache):
shutil.rmtree(py_cache) shutil.rmtree(py_cache)
@ -524,35 +505,6 @@ def get_load_order_by_vmid(config_file, vm_count, idx):
return (err_dic, order_id_dic[idx]) return (err_dic, order_id_dic[idx])
def add_to_patch(srcs_list, commit_name):
"""
Generate patch and apply to local source code
:param srcs_list: it is a list what contains source files
:param commit_name: distinguish the key commit message for the patch
"""
err_dic = {}
changes = ' '.join(srcs_list)
git_add = "git add {}".format(changes)
ret = subprocess.call(git_add, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True)
if ret:
err_dic['add patch: failue'] = "Add patch failue"
return err_dic
# commit this changes
git_commit = 'git commit -sm "acrn-config: config patch for {}"'.format(commit_name)
try:
ret = subprocess.call(git_commit, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True)
if ret < 0:
err_dic['commit patch: commit patch failue'] = "Commit patch failue"
except (OSError, subprocess.CalledProcessError) as e:
err_dic['commit patch: commit patch failue'] = "Commit patch failue"
return err_dic
def vm_pre_launch_cnt(config_file): def vm_pre_launch_cnt(config_file):
""" """
Calculate the pre launched vm number Calculate the pre launched vm number

View File

@ -60,9 +60,9 @@ PM_CHANNEL_DIC = {
MOUNT_FLAG_DIC = {} MOUNT_FLAG_DIC = {}
def prepare(check_git): def prepare():
""" Check environment """ """ Check environment """
return common.check_env(check_git) return common.check_env()
def print_yel(msg, warn=False): def print_yel(msg, warn=False):
@ -86,12 +86,11 @@ def print_red(msg, err=False):
def usage(file_name): def usage(file_name):
""" This is usage for how to use this tool """ """ This is usage for how to use this tool """
print("usage= {} [h]".format(file_name), end="") print("usage= {} [h]".format(file_name), end="")
print("--board <board_info_file> --scenario <scenario_info_file> --launch <launch_info_file> --uosid <uosid id> [--enable_commit]") print("--board <board_info_file> --scenario <scenario_info_file> --launch <launch_info_file> --uosid <uosid id>")
print('board_info_file : file name of the board info') print('board_info_file : file name of the board info')
print('scenario_info_file : file name of the scenario info') print('scenario_info_file : file name of the scenario info')
print('launch_info_file : file name of the launch info') print('launch_info_file : file name of the launch info')
print('uosid : this is the relateive id for post launch vm in scenario info XML:[1..max post launch vm]') print('uosid : this is the relateive id for post launch vm in scenario info XML:[1..max post launch vm]')
print('enable_commit: enable the flag that git add/commit the generate files to the code base. without --enable_commit will not commit this source code')
def get_param(args): def get_param(args):
@ -104,24 +103,18 @@ def get_param(args):
board_info_file = False board_info_file = False
scenario_info_file = False scenario_info_file = False
launch_info_file = False launch_info_file = False
enable_commit = False param_list = ['--board', '--scenario', '--launch', '--uosid']
param_list = ['--board', '--scenario', '--launch', '--uosid', '--enable_commit']
for arg_str in param_list: for arg_str in param_list:
if arg_str == '--enable_commit':
continue
if arg_str not in args: if arg_str not in args:
usage(args[0]) usage(args[0])
err_dic['common error: get wrong parameter'] = "wrong usage" err_dic['common error: get wrong parameter'] = "wrong usage"
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), enable_commit) return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
args_list = args[1:] args_list = args[1:]
(optlist, args_list) = getopt.getopt(args_list, '', ['board=', 'scenario=', 'launch=', 'uosid=', 'enable_commit']) (optlist, args_list) = getopt.getopt(args_list, '', ['board=', 'scenario=', 'launch=', 'uosid='])
for arg_k, arg_v in optlist: for arg_k, arg_v in optlist:
if arg_k == '--enable_commit':
enable_commit = True
if arg_k == '--board': if arg_k == '--board':
board_info_file = arg_v board_info_file = arg_v
if arg_k == '--scenario': if arg_k == '--scenario':
@ -133,26 +126,26 @@ def get_param(args):
vm_th = arg_v vm_th = arg_v
if not vm_th.isnumeric(): if not vm_th.isnumeric():
err_dic['common error: get wrong parameter'] = "--uosid should be a number" err_dic['common error: get wrong parameter'] = "--uosid should be a number"
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), enable_commit) return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
if not board_info_file or not scenario_info_file or not launch_info_file: if not board_info_file or not scenario_info_file or not launch_info_file:
usage(args[0]) usage(args[0])
err_dic['common error: get wrong parameter'] = "wrong usage" err_dic['common error: get wrong parameter'] = "wrong usage"
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), enable_commit) return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
if not os.path.exists(board_info_file): if not os.path.exists(board_info_file):
err_dic['common error: get wrong parameter'] = "{} is not exist!".format(board_info_file) err_dic['common error: get wrong parameter'] = "{} is not exist!".format(board_info_file)
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), enable_commit) return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
if not os.path.exists(scenario_info_file): if not os.path.exists(scenario_info_file):
err_dic['common error: get wrong parameter'] = "{} is not exist!".format(scenario_info_file) err_dic['common error: get wrong parameter'] = "{} is not exist!".format(scenario_info_file)
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), enable_commit) return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
if not os.path.exists(launch_info_file): if not os.path.exists(launch_info_file):
err_dic['common error: get wrong parameter'] = "{} is not exist!".format(launch_info_file) err_dic['common error: get wrong parameter'] = "{} is not exist!".format(launch_info_file)
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), enable_commit) return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), enable_commit) return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th))
def get_post_num_list(): def get_post_num_list():
@ -371,16 +364,6 @@ def get_vpid_from_bdf(bdf_vpid_map, bdf_list):
return vpid_list return vpid_list
def gen_patch(srcs_list, launch_name):
"""
Generate patch and apply to local source code
:param srcs_list: it is a list what contains source files
:param scenario_name: scenario name
"""
err_dic = common.add_to_patch(srcs_list, launch_name)
return err_dic
def get_uos_type(): def get_uos_type():
""" """
Get uos name from launch.xml at fist line Get uos name from launch.xml at fist line

View File

@ -52,9 +52,9 @@ LEGACY_TTYS = {
'ttyS3':'0x2E8', 'ttyS3':'0x2E8',
} }
def prepare(check_git): def prepare():
""" Check environment """ """ Check environment """
return common.check_env(check_git) return common.check_env()
def print_yel(msg, warn=False): def print_yel(msg, warn=False):
@ -669,16 +669,6 @@ def cpus_assignment(cpus_per_vm, index):
return vm_cpu_bmp return vm_cpu_bmp
def gen_patch(srcs_list, scenario_name):
"""
Generate patch and apply to local source code
:param srcs_list: it is a list what contains source files
:param scenario_name: scenario name
"""
err_dic = common.add_to_patch(srcs_list, scenario_name)
return err_dic
def get_vuart_info_id(config_file, idx): def get_vuart_info_id(config_file, idx):
""" """
Get vuart information by vuart id indexx Get vuart information by vuart id indexx

View File

@ -1,4 +1,4 @@
Please run scenario_cfg_gen.py to generate board related configuration patch, the patch would be applied on current acrn-hypervisor git tree automatically. Please run scenario_cfg_gen.py to generate board related configuration files.
usage: python3 scenario_cfg_gen.py [h] --board <board_info_file> --scenario <scenario_info_file> usage: python3 scenario_cfg_gen.py [h] --board <board_info_file> --scenario <scenario_info_file>
positional arguments: positional arguments:

View File

@ -77,14 +77,13 @@ def main(args):
:param args: it is a command line args for the script :param args: it is a command line args for the script
""" """
err_dic = {} err_dic = {}
config_srcs = []
(err_dic, board_info_file, scenario_info_file, enable_commit) = scenario_cfg_lib.get_param(args) (err_dic, board_info_file, scenario_info_file) = scenario_cfg_lib.get_param(args)
if err_dic: if err_dic:
return err_dic return err_dic
# check env # check env
err_dic = scenario_cfg_lib.prepare(enable_commit) err_dic = scenario_cfg_lib.prepare()
if err_dic: if err_dic:
return err_dic return err_dic
@ -106,11 +105,6 @@ def main(args):
vm_config_c = SCENARIO_PATH + '/' + scenario + '/' + GEN_FILE[1] vm_config_c = SCENARIO_PATH + '/' + scenario + '/' + GEN_FILE[1]
pci_config_c = SCENARIO_PATH + '/' + scenario + '/' + GEN_FILE[2] pci_config_c = SCENARIO_PATH + '/' + scenario + '/' + GEN_FILE[2]
config_srcs.append(vm_config_h)
config_srcs.append(vm_config_c)
if scenario == "logical_partition":
config_srcs.append(pci_config_c)
# parse the scenario.xml # parse the scenario.xml
get_scenario_item_values(board_info_file, scenario_info_file) get_scenario_item_values(board_info_file, scenario_info_file)
(err_dic, vm_info) = validate_scenario_setting(board_info_file, scenario_info_file) (err_dic, vm_info) = validate_scenario_setting(board_info_file, scenario_info_file)
@ -140,31 +134,19 @@ def main(args):
with open(pci_config_c, 'w') as config: with open(pci_config_c, 'w') as config:
pci_dev_c.generate_file(config) pci_dev_c.generate_file(config)
config_str = 'Config files'
gen_str = 'generated'
# move changes to patch, and apply to the source code
if enable_commit:
err_dic = scenario_cfg_lib.gen_patch(config_srcs, "scenario " + scenario)
config_str = 'Config patch'
gen_str = 'committed'
if not err_dic: if not err_dic:
print("{} for {} is {} successfully!".format(config_str, scenario, gen_str)) print("Config files for {} is generated successfully!".format(scenario))
else: else:
print("{} for {} is failed".format(config_str, scenario)) print("Config files for {} is failed".format(scenario))
return err_dic return err_dic
def ui_entry_api(board_info, scenario_info, enable_commit=False): def ui_entry_api(board_info, scenario_info):
git_env_check = False
arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info] arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info]
if enable_commit:
arg_list.append('--enable_commit')
git_env_check = True
err_dic = scenario_cfg_lib.prepare(git_env_check) err_dic = scenario_cfg_lib.prepare()
if err_dic: if err_dic:
return err_dic return err_dic