-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial commit for introducing the SONiC Platform Development Environ… #3778
Changes from 4 commits
85689ed
8f6e9f4
c20f3d5
275c4f1
2bef819
512b276
e193cd0
c4c7ebf
f8ee054
a622606
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
# * BUILD_NUMBER: Desired version-number to pass to the building-system. | ||
# * ENABLE_DHCP_GRAPH_SERVICE: Enables get-graph service to fetch minigraph files | ||
# through http. | ||
# * ENABLE_PDE: Enables platform development environment. | ||
# * ENABLE_ZTP: Enables zero touch provisioning. | ||
# * SHUTDOWN_BGP_ON_START: Sets admin-down state for all bgp peerings after restart. | ||
# * ENABLE_PFCWD_ON_START: Enable PFC Watchdog (PFCWD) on server-facing ports | ||
|
@@ -167,6 +168,7 @@ SONIC_BUILD_INSTRUCTION := make \ | |
BUILD_NUMBER=$(BUILD_NUMBER) \ | ||
BUILD_TIMESTAMP=$(BUILD_TIMESTAMP) \ | ||
ENABLE_DHCP_GRAPH_SERVICE=$(ENABLE_DHCP_GRAPH_SERVICE) \ | ||
ENABLE_PDE=$(ENABLE_PDE) \ | ||
ENABLE_ZTP=$(ENABLE_ZTP) \ | ||
SHUTDOWN_BGP_ON_START=$(SHUTDOWN_BGP_ON_START) \ | ||
SONIC_ENABLE_PFCWD_ON_START=$(ENABLE_PFCWD_ON_START) \ | ||
|
@@ -185,7 +187,18 @@ SONIC_BUILD_INSTRUCTION := make \ | |
EXTRA_JESSIE_TARGETS=$(EXTRA_JESSIE_TARGETS) \ | ||
$(SONIC_OVERRIDE_BUILD_VARS) | ||
|
||
.PHONY: sonic-slave-build sonic-slave-bash init reset | ||
PDESUBMODULES = src/sonic-linux-kernel \ | ||
src/sonic-utilities \ | ||
src/sonic-platform-common \ | ||
src/sonic-swss-common \ | ||
src/sonic-py-swsssdk \ | ||
src/redis-dump-load \ | ||
src/sonic-sairedis \ | ||
src/sonic-platform-daemons \ | ||
src/sonic-platform-pde \ | ||
src/sonic-ztp | ||
|
||
.PHONY: sonic-slave-build sonic-slave-bash init initpde reset | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. get rid of initpde There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to be able to build a minimal subset of SONiC with the PDE docker enabled. We can either handle this as part of make init (or in this case make initpde), or we would have to modify slave.mk to ignore NON-PDE required build targets. In this case, we think its easier to maintain a list of essential submodules for the PDE and make it part of the "make initpde" step for doing a build. Can we leave this change as it is or do yo have an alternative suggestion? We automate the PDE build internally by doing the following. make initpde There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@lguohan, @jleveque - I never heard back. Should I setup a call to discuss? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to run this "make initpde" to differentiate the Full SONIC image build. Actually, ODM will not run this step, since the step is done by BRCM internally to generate the light weight PDE repo for ODM. Another reason for this is to protect the BRCM SONIC changes with just platform related common change exposing to ODM when working with ODM on ODM HWQ projects. For PDE, we also have another option which is to run PDE as a docker in Full SONIC image. In the FULL sonic image runtime, we can launch PDE by pde.sh script. The script will disable most dockers in SONIC image and just reserve the necessary dockers with a lightweight environment for ODM platform testing. By default, the PDE docker will not be triggered in Full SONIC image. Geans make initpde make configure PLATFORM=broadcom make target/sonic-broadcom-pde.bin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
.DEFAULT_GOAL := all | ||
|
||
|
@@ -233,6 +246,12 @@ showtag: | |
@echo $(SLAVE_IMAGE):$(SLAVE_TAG) | ||
@echo $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) | ||
|
||
initpde: | ||
@for submodule in $(PDESUBMODULES) ; do \ | ||
git submodule update --init --recursive $$submodule ; \ | ||
done | ||
@git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' | ||
|
||
init : | ||
@git submodule update --init --recursive | ||
@git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
FROM docker-config-engine-stretch | ||
lguohan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
ARG docker_container_name | ||
ENV PYTHONPATH=/usr/share/sonic/platform | ||
|
||
RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf | ||
|
||
# Make apt-get non-interactive | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Update apt's cache of available packages | ||
RUN apt-get update && apt-get install -y ipmitool telnet busybox kmod | ||
|
||
RUN pip install pytest pexpect | ||
|
||
# Copy locally-built Debian package dependencies | ||
COPY \ | ||
debs/libsaibcm_3.5.3.1m-25_amd64.deb debs/sonic-platform-pde_1.0_amd64.deb /debs/ | ||
|
||
# Install locally-built Debian packages and implicitly install their dependencies | ||
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; \ | ||
dpkg_apt /debs/libsaibcm_3.5.3.1m-25_amd64.deb; \ | ||
dpkg_apt /debs/sonic-platform-pde_1.0_amd64.deb | ||
|
||
# Copy locally-built Debian package dependencies | ||
COPY \ | ||
python-debs/python-sonic-utilities_1.2-1_all.deb /debs/ | ||
|
||
# Install locally-built Debian packages and implicitly install their dependencies | ||
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /debs/python-sonic-utilities_1.2-1_all.deb | ||
|
||
# Copy locally-built Python wheel dependencies | ||
COPY \ | ||
python-wheels/sonic_platform_common-1.0-py2-none-any.whl /python-wheels/ | ||
|
||
# Install locally-built Python wheel dependencies | ||
RUN pip install \ | ||
/python-wheels/sonic_platform_common-1.0-py2-none-any.whl | ||
|
||
|
||
|
||
# Clean up | ||
RUN apt-get clean -y; \ | ||
apt-get autoclean -y; \ | ||
apt-get autoremove -y | ||
RUN rm -rf /debs ~/.cache | ||
|
||
RUN mkdir -p /home/pde | ||
|
||
COPY ["base_image_files/port_breakout.py", "/usr/local/bin/"] | ||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] | ||
COPY ["docker_init.sh", "/usr/bin/"] | ||
ENTRYPOINT ["/usr/bin/docker_init.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} | ||
FROM docker-config-engine-stretch | ||
|
||
ARG docker_container_name | ||
ENV PYTHONPATH=/usr/share/sonic/platform | ||
|
||
RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf | ||
|
||
# Make apt-get non-interactive | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Update apt's cache of available packages | ||
RUN apt-get update && apt-get install -y ipmitool telnet busybox kmod | ||
|
||
RUN pip install pytest pexpect | ||
|
||
{% if docker_pde_debs.strip() -%} | ||
# Copy locally-built Debian package dependencies | ||
COPY \ | ||
{% for deb in docker_pde_debs.split(' ') -%} | ||
debs/{{ deb }}{{' '}} | ||
{%- endfor -%} | ||
/debs/ | ||
|
||
# Install locally-built Debian packages and implicitly install their dependencies | ||
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }{%- for deb in docker_pde_debs.split(' ') %}; \ | ||
dpkg_apt /debs/{{ deb }} | ||
{%- endfor %} | ||
{%- endif %} | ||
|
||
{% if docker_pde_pydebs.strip() -%} | ||
# Copy locally-built Debian package dependencies | ||
COPY \ | ||
{% for deb in docker_pde_pydebs.split(' ') -%} | ||
python-debs/{{ deb }}{{' '}} | ||
{%- endfor -%} | ||
/debs/ | ||
|
||
# Install locally-built Debian packages and implicitly install their dependencies | ||
{%- for deb in docker_pde_pydebs.split(' ') %} | ||
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /debs/{{ deb }} | ||
{%- endfor %} | ||
{%- endif %} | ||
|
||
{% if docker_pde_whls.strip() -%} | ||
# Copy locally-built Python wheel dependencies | ||
COPY \ | ||
{% for whl in docker_pde_whls.split(' ') -%} | ||
python-wheels/{{ whl }}{{' '}} | ||
{%- endfor -%} | ||
/python-wheels/ | ||
|
||
# Install locally-built Python wheel dependencies | ||
RUN pip install \ | ||
{% for whl in docker_pde_whls.split(' ') -%} | ||
/python-wheels/{{ whl }}{{' '}} | ||
{%- endfor %} | ||
{% endif %} | ||
|
||
|
||
# Clean up | ||
RUN apt-get clean -y; \ | ||
apt-get autoclean -y; \ | ||
apt-get autoremove -y | ||
RUN rm -rf /debs ~/.cache | ||
|
||
RUN mkdir -p /home/pde | ||
|
||
COPY ["base_image_files/port_breakout.py", "/usr/local/bin/"] | ||
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] | ||
COPY ["docker_init.sh", "/usr/bin/"] | ||
ENTRYPOINT ["/usr/bin/docker_init.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
|
||
usage() | ||
{ | ||
echo "usage: $0 <help/list/commands>" | ||
exit 1 | ||
} | ||
|
||
if [ $# -lt 1 ] | ||
then | ||
usage | ||
fi | ||
|
||
case $1 in | ||
-h | help) | ||
usage | ||
;; | ||
-l | ls | list) | ||
docker exec -it -w /usr/local/sonic_pde_tests pde ls | ||
exit 0 | ||
;; | ||
*) | ||
;; | ||
esac | ||
|
||
# Make sure only root can run our script | ||
if [ "$(id -u)" != "0" ]; then | ||
echo "This script must be run as root" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
# Stop swss/syncd service to ensure there is only 1 SAI instance at a time | ||
systemctl stop swss | ||
|
||
if [ $(grep -c 'platform:ro' $(which pde.sh)) -gt 0 ]; then | ||
systemctl stop pde | ||
sleep 1 | ||
docker rename pde pde.orig | ||
sed -i 's#platform:ro#platform#g' $(which pde.sh) | ||
sed -i 's#hwsku:ro#hwsku#g' $(which pde.sh) | ||
systemctl start pde | ||
fi | ||
|
||
# Allow 5 seconds for the docker-pde to be online | ||
err=1 | ||
for t in $(seq 5); do | ||
if [ $(docker ps | grep -c pde) -gt 0 ]; then | ||
err=0 | ||
break | ||
fi | ||
sleep 1 | ||
done | ||
if [ ${err} -ne 0 ]; then | ||
echo "docker-pde is not alive, existing ..." | ||
exit 1 | ||
fi | ||
|
||
# Now launch the PDE pytest | ||
docker exec -it -w /usr/local/sonic_pde_tests pde pytest $* | ||
|
||
# Restart the swss service | ||
systemctl start swss | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i do not think this is needed.