def set_sal_env(): print("Setting environment for SAL.") if not set_sde_env(): return False exit() #os.environ['TCMALLOC_LARGE_ALLOC_REPORT_THRESHOLD'] = '64077925800531312640' set_env_var(constants.sal_home_env_var_name, get_sal_home_absolute()) set_env_var(constants.pythonpath_env_var_name, get_sal_home_absolute()) set_env_var(constants.sde_include_env_var_name, get_env_var(constants.sde_install_env_var_name) + '/include') set_env_var(constants.gb_src_home_env_var_name, get_gb_src_home_absolute()) set_env_var(constants.gb_lib_home_env_var_name, get_gb_lib_home_absolute()) print('SAL_HOME: {0} \ \n PYTHONPATH: {1} \ \n SDE: {2} \ \n SDE_INSTALL: {3} \ \n SDE_INCLUDE: {4} \ \n GB_SRC_HOME: {5} \ \n GB_LIB_HOME: {6} '.format( get_env_var(constants.sal_home_env_var_name), get_env_var(constants.pythonpath_env_var_name), get_env_var(constants.sde_env_var_name), get_env_var(constants.sde_install_env_var_name), get_env_var(constants.sde_include_env_var_name), get_env_var(constants.gb_src_home_env_var_name), get_env_var(constants.gb_lib_home_env_var_name))) return True
def set_sal_env(): print("Setting environment for SAL.") if not set_sde_env_n_load_drivers(): return False rc = set_env_var(constants.sal_home_env_var_name, get_sal_repo_absolute()) print('SAL_HOME: {}'.format(get_env_var(constants.sal_home_env_var_name))) rc &= set_env_var(constants.pythonpath_env_var_name, get_env_var(constants.sal_home_env_var_name)) rc &= set_env_var( constants.sde_include_env_var_name, get_env_var(constants.sde_install_env_var_name) + '/include') rc &= set_env_var(constants.gb_src_home_env_var_name, get_gb_src_home_absolute()) rc &= set_env_var(constants.gb_lib_home_env_var_name, get_gb_lib_home_absolute()) rc &= set_env_var(constants.tp_install_env_var_name, get_tp_install_path_absolute()) print('SAL_HOME: {0} \ \n PYTHONPATH: {1} \ \n SDE: {2} \ \n SDE_INSTALL: {3} \ \n SDE_INCLUDE: {4} \ \n GB_SRC_HOME: {5} \ \n GB_LIB_HOME: {6} \ \n TP_INSTALL: {7}'.format(get_env_var(constants.sal_home_env_var_name), get_env_var(constants.pythonpath_env_var_name), get_env_var(constants.sde_env_var_name), get_env_var(constants.sde_install_env_var_name), get_env_var(constants.sde_include_env_var_name), get_env_var(constants.gb_src_home_env_var_name), get_env_var(constants.gb_lib_home_env_var_name), get_env_var(constants.tp_install_env_var_name))) return rc
def set_sal_env(): print("Setting environment for SAL.") if not set_sde_env_n_load_drivers(): return False rc = set_env_var(constants.sal_home_env_var_name, get_sal_home_absolute()) rc &= set_env_var(constants.pythonpath_env_var_name, get_sal_home_absolute()) rc &= set_env_var( constants.sde_include_env_var_name, get_env_var(constants.sde_install_env_var_name) + '/include') rc &= set_env_var(constants.gb_src_home_env_var_name, get_gb_src_home_absolute()) rc &= set_env_var(constants.gb_lib_home_env_var_name, get_gb_lib_home_absolute()) # rc &= set_env_var(constants.sal_install_env_var_name, # get_sal_home_absolute() + '/install/') if get_from_advance_setting_dict(constants.sal_sw_attr_node, constants.build_third_party_node): if get_from_advance_setting_dict(constants.sal_sw_attr_node, constants.tp_install_node_name) \ is None: rc &= set_env_var(constants.tp_install_env_var_name, get_sal_home_absolute() + '/install/') else: rc &= set_env_var(constants.tp_install_env_var_name, get_tp_install_path_absolute()) print('TP_INSTALL set to {}'.format( get_env_var(constants.tp_install_env_var_name))) else: rc &= set_env_var(constants.tp_install_env_var_name, get_env_var(constants.sde_install_env_var_name)) print('SAL_HOME: {0} \ \n PYTHONPATH: {1} \ \n SDE: {2} \ \n SDE_INSTALL: {3} \ \n SDE_INCLUDE: {4} \ \n GB_SRC_HOME: {5} \ \n GB_LIB_HOME: {6} \ \n TP_INSTALL: {7}'.format(get_env_var(constants.sal_home_env_var_name), get_env_var(constants.pythonpath_env_var_name), get_env_var(constants.sde_env_var_name), get_env_var(constants.sde_install_env_var_name), get_env_var(constants.sde_include_env_var_name), get_env_var(constants.gb_src_home_env_var_name), get_env_var(constants.gb_lib_home_env_var_name), get_env_var(constants.tp_install_env_var_name))) return rc
def start_stratum(): print("Starting Stratum....") stratum_start_cmd_bsp_less = 'sudo {0}/bazel-bin/stratum/hal/bin/barefoot/stratum_bf \ --external_stratum_urls=0.0.0.0:28000 \ --grpc_max_recv_msg_size=256 \ --bf_sde_install={1} \ --persistent_config_dir={2} \ --forwarding_pipeline_configs_file={2}/p4_pipeline.pb.txt \ --chassis_config_file={2}/chassis_config.pb.txt \ --write_req_log_file={2}/p4_writes.pb.txt \ --bf_switchd_cfg={0}/stratum/hal/bin/barefoot/tofino_skip_p4_no_bsp.conf'.format( get_env_var(constants.stratum_home_env_var_name), get_env_var(constants.bf_sde_install_env_var_name), get_env_var(constants.stratum_config_env_var_name) ) append_to_env_var(constants.ld_lib_path_env_var_name, common.get_gb_lib_home_absolute()) stratum_start_cmd_bsp = 'export PLATFORM=x86-64-stordis-bf2556x-1t-r0 && \ sudo -E start-stratum.sh --bf_sim ' if get_switch_model() == constants.bf6064x_t: stratum_start_cmd_bsp = 'export PLATFORM=x86-64-stordis-bf6064x-t-r0 && \ sudo -E start-stratum.sh --bf_sim ' # Following call is made from bf_sde.py, following call will not be made if user does nothing for BF SDE. if not load_and_verify_kernel_modules(): print("ERROR:Some kernel modules are not loaded.") exit(0) os.chdir(get_env_var(constants.stratum_home_env_var_name)) print('Current dir: {}'.format(os.getcwd())) if get_stratum_mode() == 'bsp-less': print("Starting Stratum in bsp-less mode...") print("Executing command {}".format(stratum_start_cmd_bsp_less)) shutil.copyfile(get_env_var( constants.stratum_home_env_var_name) + '/stratum/hal/config/x86-64-stordis-bf2556x-1t-r0/port_map.json', get_env_var( constants.bf_sde_install_env_var_name) + '/share/port_map.json') os.system(stratum_start_cmd_bsp_less) else: print("Starting Stratum in bsp mode...") print("Executing command {}".format(stratum_start_cmd_bsp)) os.system(stratum_start_cmd_bsp) return True
def set_sal_env(): print("Setting environment for SAL.") if not set_sde_env_n_load_drivers(): return False exit() #os.environ['TCMALLOC_LARGE_ALLOC_REPORT_THRESHOLD'] = '64077925800531312640' set_env_var(constants.sal_home_env_var_name, get_sal_home_absolute()) set_env_var(constants.pythonpath_env_var_name, get_sal_home_absolute()) set_env_var(constants.sde_include_env_var_name, get_env_var(constants.sde_install_env_var_name) + '/include') set_env_var(constants.gb_src_home_env_var_name, get_gb_src_home_absolute()) set_env_var(constants.gb_lib_home_env_var_name, get_gb_lib_home_absolute()) set_env_var(constants.sal_install_env_var_name, get_sal_home_absolute() + '/install/') if get_from_setting_dict(constants.sal_sw_attr_node, constants.build_third_party_node): set_env_var(constants.tp_install_env_var_name, get_env_var(constants.sal_install_env_var_name)) else: set_env_var(constants.tp_install_env_var_name, get_env_var(constants.sde_install_env_var_name)) print('SAL_HOME: {0} \ \n PYTHONPATH: {1} \ \n SDE: {2} \ \n SDE_INSTALL: {3} \ \n SDE_INCLUDE: {4} \ \n GB_SRC_HOME: {5} \ \n GB_LIB_HOME: {6} \ \n TP_INSTALL: {7}'.format(get_env_var(constants.sal_home_env_var_name), get_env_var(constants.pythonpath_env_var_name), get_env_var(constants.sde_env_var_name), get_env_var(constants.sde_install_env_var_name), get_env_var(constants.sde_include_env_var_name), get_env_var(constants.gb_src_home_env_var_name), get_env_var(constants.gb_lib_home_env_var_name), get_env_var(constants.tp_install_env_var_name))) return True