示例#1
0
def install_sal_thirdparty_deps():
    print('Installing SAL 3rdparty dependencies.')

    if not os.path.exists(sal_3rdparty_build_path):
        os.makedirs(sal_3rdparty_build_path)

    i = input('Install boost y/[n] ?')
    if not i or i not in ['y', 'n']:
        i = 'n'
    if i == 'y' and not install_boost():
        return False

    i = input('Install protobuf y/[n] ?')
    if not i or i not in ['y', 'n']:
        i = 'n'
    if i == 'y' and not install_protobuf():
        return False

    append_to_env_var(constants.path_env_var_name,
                      sal_3rdparty_build_path + '/bin/')
    print(get_env_var(path_env_var_name))

    i = input('Install gRPC y/[n] ?')
    if not i or i not in ['y', 'n']:
        i = 'n'
    if i == 'y' and not install_grpc():
        return False
    return True
示例#2
0
def set_stratum_env():
    if not set_sal_env():
        exit(0)
    print('Setting environment for stratum.')
    append_to_env_var(
        constants.ld_lib_path_env_var_name,
        "/{0}/lib:/lib/x86_64-linux-gnu".format(
            get_env_var(constants.sde_install_env_var_name)))
    set_env_var(constants.pi_install_env_var_name,
                get_sde_install_dir_absolute())
    set_env_var(constants.stratum_config_env_var_name,
                get_stratum_config_dir_absolute())
    set_env_var(constants.stratum_home_env_var_name,
                get_stratum_home_absolute())
    # set_env_relative_to_user_home('ONLP_INSTALL', "/onlp-dev_1.0.1_amd64" )
    # required to compile stratum
    set_env_var(constants.bf_sde_install_env_var_name,
                get_sde_install_dir_absolute())

    print('Env for starting Stratum :\n{0}\n{1}\n{2}\n{3}\n{4}\n{5}'.format(
        '{} {}'.format(constants.bf_sde_install_env_var_name,
                       get_env_var(constants.bf_sde_install_env_var_name)),
        '{} {}'.format(constants.ld_lib_path_env_var_name,
                       get_env_var(constants.ld_lib_path_env_var_name)),
        '{} {}'.format(constants.pi_install_env_var_name,
                       get_env_var(constants.pi_install_env_var_name)),
        '{} {}'.format(constants.stratum_config_env_var_name,
                       get_env_var(constants.stratum_config_env_var_name)),
        '{} {}'.format(constants.stratum_home_env_var_name,
                       get_env_var(constants.stratum_home_env_var_name)),
        '{} {}'.format(constants.sal_home_env_var_name,
                       get_env_var(constants.sal_home_env_var_name))))
示例#3
0
def set_sal_test_env():
    set_env_var(constants.sal_home_env_var_name, get_sal_home_absolute())
    append_to_env_var(pythonpath_env_var_name,
                      get_env_var(constants.sal_home_env_var_name))
    append_to_env_var(pythonpath_env_var_name,
                      get_env_var(constants.sal_home_env_var_name) + "/test")
    print("%s = %s" %
          (pythonpath_env_var_name, get_env_var(pythonpath_env_var_name)))
示例#4
0
def install_sal_thirdparty_deps():
    print('Installing SAL 3rdparty dependencies.')

    if not os.path.exists(sal_3rdparty_build_path):
        os.makedirs(sal_3rdparty_build_path)

    res = installProtobuf()
    append_to_env_var(constants.path_env_var_name,
                      sal_3rdparty_build_path + '/bin/')
    res &= installgRPC()
    return res
示例#5
0
def install_sal_thirdparty_deps():
    print('Installing SAL thirdparty dependencies.')
    global sal_thirdparty_path
    sal_thirdparty_path = get_sal_home_absolute() + '/install/thirdparty/'

    if not os.path.exists(sal_thirdparty_path):
        os.makedirs(sal_thirdparty_path)

    res = installProtobuf()
    append_to_env_var(constants.path_env_var_name,
                      get_sal_home_absolute() + '/install/bin/')
    res &= installgRPC()
    return res
示例#6
0
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_home_absolute() + '/compilation_root')

    stratum_start_cmd_bsp = 'sudo LD_LIBRARY_PATH={3} {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_sim'.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),
                         get_env_var(constants.ld_lib_path_env_var_name))

    if not load_and_verify_kernel_modules():
        print("ERROR:Some kernel modules are not loaded.")
        exit(0)

    shutil.copyfile(
        get_env_var(constants.stratum_home_env_var_name) +
        '/stratum/hal/bin/barefoot/platforms/x86-64-stordis-bf2556x-1t-r0.json',
        get_env_var(constants.bf_sde_install_env_var_name) +
        '/share/port_map.json')
    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))
        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)
示例#7
0
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
示例#8
0
def set_sde_env():
    print("Setting environment for BF_SDE.")
    sde_home_absolute = get_sde_home_absolute()
    if validate_path_existence(sde_home_absolute, 'SDE'):
        set_env_var(constants.sde_env_var_name, sde_home_absolute)
        set_env_var(constants.sde_install_env_var_name,
                    get_env_var(constants.sde_env_var_name) + '/install/')
        append_to_env_var(
            constants.path_env_var_name,
            get_env_var(constants.sde_install_env_var_name) + '/bin/')
        print(
            'Environment variables set: \n SDE: {0} \n SDE_INSTALL: {1} \n PATH: {2}'
            .format(get_env_var(constants.sde_env_var_name),
                    get_env_var(constants.sde_install_env_var_name),
                    get_env_var(constants.path_env_var_name)))
        return True
    else:
        print('ERROR: SDE directory couldnt be found, exiting .')
        exit(0)