Pure SONiC 是 SONiC 的版本,它消除了对供应商的依赖。社区开发、公开可用和 100% 开源使您能够构建与所需社区分支同步的纯 SONiC 映像。这意味着 SONiC 的每一行代码和 SAI ( switch abstraction interface )的 NVIDIA 实现只需点击一下 主映像 。

NVIDIA 当您选择 Pure SONiC 时,我们将致力于您的成功。为了确保 Pure SONiC 得到强化和限定, NVIDIA 建议使用特定的公共哈希来构建映像,这是一种在特定时间点对 Git 存储库进行快照的机制。通过广泛的 QA ,在所有 NVIDIA 平台上验证传递给用户的每个公共散列。此外, NVIDIA 承认需要有价值的文件。发行说明和用户手册与特定的公共哈希绑定。
建立一个纯粹的声波图像
下面是我如何建立我的纯声波图像,包括 ZTP ,运行在我的 NVIDIA Mellanox Spectrum 开放式以太网交换机上。我的解决方案受到了关于 GitHub 的 构建 SONiC 交换机映像 教程的启发。默认情况下,在回购的 生成配置文件 中禁用 ZTP 。
Spectrum 交换机预装了 ONIE ( open network install environment ),这是一个引导加载程序,提供了在裸机交换机系统上安装任何网络操作系统的环境。 ONIE 允许最终用户自动安装网络操作系统,作为数据中心配置的一部分,类似于 ONIE 交换机管理 Linux 服务器的方式。
我的构建服务器由 24 核 CPU 、 250 GB 构建存储和 64 GB RAM 组成,运行在 Ubuntu16 . 04 上, Docker 版本 18 . 03 . 0-ce 、 Python 和 jinja2 。我发现我的构建配置至少需要 100 GB 的可用磁盘空间。最终的构建目录消耗了大约 30gb 。在构建时间对业务至关重要的情况下,我建议升级 CPU 和 RAM 以允许更多的内核并行工作,从而缩短构建时间。
出于自动化和代码重用的目的,我将代码分为三个短文件:
- build.cfg :初始化公共环境变量并由其他文件进行源处理。
- gitsonic.sh :获取公共 git 存储库源代码。
- build.sh :执行生成。
运行脚本执行构建过程。
第一步:创建 build.cfg
# An example to hash that was qualified by NVIDIA
SONICBRANCH=201911
COMMITHASH="bea968b"
BLDBRANCH="${SONICBRANCH}"
BUILD_NUMBER="00005"
let BLDNUM="${BUILD_NUMBER}"
#ZTP is disabled by default per community decision. I found it useful to enable in my build, more
#options are available in the file ./rules/config
ENABLE_ZTP="y"
SONIC_IMAGE_VERSION="SONIC.${SONICBRANCH}.${BLDNUM}-${COMMITHASH}_Internal"
SONIC_OVERRIDE_BUILD_VARS='
SONICIMAGE_VERSION=SONIC.${SONICBRANCH}.${BLDNUM}-${COMMITHASH}_Internal
BUILD_NUMBER=${BLDNUM} ENABLE_ZTP=y'
BLDDIR="./sonic-buildimage_${BLDBRANCH}_${BUILD_NUMBER}_${COMMITHASH}_ZTP" 第二步:创建 sonicgit.sh
#!/bin/bash
source ./build.cfg
if [ -d "${BLDDIR}" ];then
echo "directory sonic-buildimage already exists, aborting git"
exit 1
fi
# git clone the top-level
# source code from the public repository, SONICBRANCH=201911
git clone -b ${SONICBRANCH} https://github.com/Azure/sonic-buildimage.git
# move the cloned source to a build-specific named directory
# avoid overwriting earlier versions that you may need.
mv ./sonic-buildimage "${BLDDIR}"
# If you are making any changes to the latest checked in branch, you must make
# changes to the configuration.
# Because you are making changes, create a build branch based on the specific commit hash
#this git branch information shows up in the build image,
#when you run command $show version from the switch command line.
cd "${BLDDIR}"
git checkout -b "${BLDBRANCH}" ${COMMITHASH}
# the git clone step only pulls the top-level module.
# the underlying submodules must be recursively
# init-ed and updated.
git submodule update --init --recursive
#display the status
echo "${BLDDIR}"
git status | grep branch 第 3 步:创建 build.sh
#!/bin/bash
source ./build.cfg
#Helper functions start###
function checkErrors()
{
X=`grep -i -c "${1}" "${2}"`
if [ "${X}" != "0" ];then
grep -i -n "${1}" "${2}"
fi
}
function doSetup()
{
CONFIGZTP="ENABLE_ZTP=${ENABLE_ZTP}"
CONFIGSONIC="{$CONFIGZTP}"
}
function doMakeConfig()
{
#Execute make configure once to configure ASIC
#make configure PLATFORM=[ASIC_VENDOR]
make configure PLATFORM=mellanox
}
# Build SONiC image
function doMake()
{
LOGFILE="../logs/${BLDDIR}.log"
echo "time make
SONIC_BUILD_JOBS=24 ${SONIC_OVERRIDE_BUILD_VARS}
target/sonic-mellanox.bin" > "${LOGFILE}"
time make SONIC_BUILD_JOBS=24 ${SONIC_OVERRIDE_BUILD_VARS} target/sonic-mellanox.bin | tee "${LOGFILE}"
checkErrors "fail" "${LOGFILE}"
checkErrors "warning" "${LOGFILE}"
checkErrors "error" "${LOGFILE}"
}
#Helper functions end###
cd "${BLDDIR}"
doSetup
doMakeConfig
doMake 概括
步骤 1-3 中描述的构建过程将生成启用 ZTP 的纯声波图像。一些人会认为,这张图片展示了开放网络的最佳状态:构建一个开源操作系统,消除对供应商的依赖。
考虑在 2021 年部署 SONiC ?欢迎在评论中联系我。我很想讨论一下,听听你的反馈。