Skip to content

Commit

Permalink
Build pensando-sw artifacts for sonic (sonic-net#3)
Browse files Browse the repository at this point in the history
Signed-off-by: Rishikesh Naik <rishikesh@pensando.io>
  • Loading branch information
rishi-pen authored Sep 29, 2021
1 parent 441edf3 commit 5ff8b49
Show file tree
Hide file tree
Showing 19 changed files with 335 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,7 @@
[submodule "platform/broadcom/sonic-platform-modules-nokia"]
path = platform/broadcom/sonic-platform-modules-nokia
url = https://github.com/nokia/sonic-platform.git
[submodule "src/pensando/sw"]
path = src/pensando/sw
url = git@github.com:pensando/sw.git
branch = sonic-t
63 changes: 63 additions & 0 deletions dockers/docker-pensando-sw/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM docker-config-engine-buster

ARG docker_container_name
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

RUN apt-get update && \
apt-get install -y g++ python3-dev libxml2 libcurl3-gnutls libcjson-dev libltdl-dev

RUN pip3 install connexion==2.7.0 \
setuptools==21.0.0 \
grpcio-tools==1.20.0 \
certifi==2017.4.17 \
python-dateutil==2.6.0 \
six==1.11.0 \
urllib3==1.21.1

COPY \
{% for deb in docker_pensando_sw_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor -%}
debs/

RUN dpkg -i \
{% for deb in docker_pensando_sw_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor %}


COPY template_nmd.json /tmp/

COPY template_fru.json /tmp/


COPY netagentcfg.sh /usr/bin/
COPY netagenthal.sh /usr/bin/
COPY nmd.sh /usr/bin/

COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]

RUN mkdir -p /pensando/hostdir &&\
rm -rf /nic/tools
env NAPLES_PIPELINE apollo
env PDS_HOST 0.0.0.0
env HOST_NAME vnaples1
env CONTROLLER 0.0.0.0
env MAC_ADDR 00:00:00:00:00:00
env SERIAL_NUM REPLACE_ME
env SONIC_MODE 1
env EVENTS_DIR /pensando/events

RUN apt-get remove -y g++ python3-dev
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs

## TODO: symbolic links will be removed when AAA improvements get merged
RUN ln -sf /host_etc/passwd /etc/passwd
RUN ln -sf /host_etc/group /etc/group


ENTRYPOINT ["/usr/local/bin/supervisord"]
11 changes: 11 additions & 0 deletions dockers/docker-pensando-sw/netagentcfg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

echo "starting NetAgent cfg"

export SONIC_MODE=1

echo $PDS_HOST
echo $SONIC_MODE

exec /usr/bin/netagentcfg > /tmp/netagentcfg_out.log 2> /tmp/netagentcfg_err.log

10 changes: 10 additions & 0 deletions dockers/docker-pensando-sw/netagenthal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

echo "starting NetAgent HAL"
export SONIC_MODE=1

echo $PDS_HOST
echo $SONIC_MODE

exec /usr/bin/netagenthal > /tmp/netagenthal_out.log 2> /tmp/netagenthal_err.log

23 changes: 23 additions & 0 deletions dockers/docker-pensando-sw/nmd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

echo CONTROLLER: $CONTROLLER
echo SERIAL_NUM: $SERIAL_NUM
echo MAC_ADDR: $MAC_ADDR

sed -i s/CONTROLLER/${CONTROLLER}/ /tmp/template_nmd.json
sed -i s/MAC_ADDR/${MAC_ADDR}/ /tmp/template_nmd.json
sed -i s/HOST_NAME/${HOST_NAME}/ /tmp/template_nmd.json
mv /tmp/template_nmd.json /tmp/nmd.json

sed -i s/SERIAL_NUM/${SERIAL_NUM}/ /tmp/template_fru.json
sed -i s/MAC_ADDR/${MAC_ADDR}/ /tmp/template_fru.json
mv /tmp/template_fru.json /tmp/fru.json

echo "Starting NMD"
NAPLES_PIPELINE=apollo SONIC_MODE=1 /usr/bin/nmd > /tmp/nmd_out.log 2> /tmp/nmd_err.log &
sleep 30
curl -X POST -H "Content-Type: application/json" -k -d @/tmp/nmd.json https://localhost:8888/api/v1/naples/
sleep 20
curl 127.0.0.1:9007/api/mode/

while :; do sleep 1; done
55 changes: 55 additions & 0 deletions dockers/docker-pensando-sw/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[supervisord]
logfile_maxbytes=1MB
logfile_backups=2
nodaemon=true

[eventlistener:dependent-startup]
command=python3 -m supervisord_dependent_startup
autostart=true
autorestart=unexpected
startretries=0
exitcodes=0,3
events=PROCESS_STATE
buffer_size=1024

[program:rsyslogd]
command=/usr/sbin/rsyslogd -n -iNONE
priority=1
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true

[program:netagent-cfg]
command=/usr/bin/netagentcfg.sh
priority=2
autostart=true
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running

[program:netagent-hal]
command=/usr/bin/netagenthal.sh
priority=3
autostart=true
autorestart=false
startsecs=0
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running


[program:nmd]
command=/usr/bin/nmd.sh
priority=4
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=rsyslogd:running
12 changes: 12 additions & 0 deletions dockers/docker-pensando-sw/template_fru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"manufacturing-date": "1568246400",
"manufacturer": "PENSANDO SYSTEMS INC.",
"product-name": "NAPLES 25",
"serial-number": "SERIAL_NUM",
"part-number": "SMART_SERVICE_SKU",
"frufileid": "",
"board-id": "2",
"engineering-change-level": "0",
"num-mac-address": "24",
"mac-address": "MAC_ADDR"
}
20 changes: 20 additions & 0 deletions dockers/docker-pensando-sw/template_nmd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"TypeMeta": {
"Kind": "DistributedServiceCard"
},
"ObjectMeta": {
"Name": "DistributedServiceCardConfig",
"tenant": "default"
},
"spec": {
"primary-mac": "MAC_ADDR",
"id": "HOST_NAME",
"mode": "NETWORK",
"network-mode": "OOB",
"dsc-profile": "FEATURE_PROFILE_BASE",
"controllers": [
"CONTROLLER"
]
}
}

1 change: 1 addition & 0 deletions files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{%- if sonic_asic_platform == "vs" %}{% do features.append(("gbsyncd", "enabled", false, "enabled")) %}{% endif %}
{%- if include_iccpd == "y" %}{% do features.append(("iccpd", "disabled", false, "enabled")) %}{% endif %}
{%- if include_mgmt_framework == "y" %}{% do features.append(("mgmt-framework", "enabled", true, "enabled")) %}{% endif %}
{% do features.append(("pensando-sw", "enabled", true, "enabled")) %}
{%- if include_nat == "y" %}{% do features.append(("nat", "disabled", false, "enabled")) %}{% endif %}
{%- if include_restapi == "y" %}{% do features.append(("restapi", "enabled", false, "enabled")) %}{% endif %}
{%- if include_sflow == "y" %}{% do features.append(("sflow", "disabled", false, "enabled")) %}{% endif %}
Expand Down
13 changes: 13 additions & 0 deletions files/build_templates/pensando-sw.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Pensando SW container
Requires=database.service
After=database.service swss.service syncd.service
BindsTo=sonic.target
After=sonic.target
Before=ntp-config.service

[Service]
User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{docker_container_name}}.sh start
ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
11 changes: 11 additions & 0 deletions files/build_templates/pensando-sw.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Delays pensando sw container until SONiC has started
PartOf=pensando-sw.service

[Timer]
OnUnitActiveSec=0 sec
OnBootSec=3min 30 sec
Unit=pensando-sw.service

[Install]
WantedBy=timers.target sonic.target sonic-delayed.target
3 changes: 3 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,9 @@ sudo cp $BUILD_TEMPLATES/mgmt-framework.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_S
echo "mgmt-framework.timer" | sudo tee -a $GENERATED_SERVICE_FILE
{% endif %}

sudo cp $BUILD_TEMPLATES/pensando-sw.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
echo "pensando-sw.timer" | sudo tee -a $GENERATED_SERVICE_FILE

sudo cp $BUILD_TEMPLATES/sonic.target $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable sonic.target

Expand Down
11 changes: 11 additions & 0 deletions rules/docker-pensando-sw.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

DPATH := $($(DOCKER_PENSANDO_SW)_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-pensando-sw.mk rules/docker-pensando-sw.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
DEP_FILES += $(shell git ls-files $(DPATH))

$(DOCKER_PENSANDO_SW)_CACHE_MODE := GIT_CONTENT_SHA
$(DOCKER_PENSANDO_SW)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
$(DOCKER_PENSANDO_SW)_DEP_FILES := $(DEP_FILES)

#$(eval $(call add_dbg_docker,$(DOCKER_PENSANDO_SW),$(DOCKER_PENSANDO_SW_DBG)))
37 changes: 37 additions & 0 deletions rules/docker-pensando-sw.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# docker image for pensando-sw

DOCKER_PENSANDO_SW_STEM = docker-pensando-sw
DOCKER_PENSANDO_SW = $(DOCKER_PENSANDO_SW_STEM).gz
#DOCKER_PENSANDO_SW_DBG = $(DOCKER_PENSANDO_SW_STEM)-$(DBG_IMAGE_MARK).gz

$(DOCKER_PENSANDO_SW)_PATH = $(DOCKERS_PATH)/$(DOCKER_PENSANDO_SW_STEM)

$(DOCKER_PENSANDO_SW)_DEPENDS += $(PENSANDO_SW)
#$(DOCKER_PENSANDO_SW)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS)
#$(DOCKER_PENSANDO_SW)_DBG_DEPENDS += $(PENSANDO_SW_DBG)

SONIC_DOCKER_IMAGES += $(DOCKER_PENSANDO_SW)
$(DOCKER_PENSANDO_SW)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER)

$(DOCKER_PENSANDO_SW)_VERSION = 1.0.0
$(DOCKER_PENSANDO_SW)_PACKAGE_NAME = pensando-sw

#$(DOCKER_PENSANDO_SW)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES)

#ifeq ($(INCLUDE_MGMT_FRAMEWORK), y)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_PENSANDO_SW)
#endif

#SONIC_DOCKER_DBG_IMAGES += $(DOCKER_PENSANDO_SW_DBG)
#ifeq ($(INCLUDE_MGMT_FRAMEWORK), y)
#SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_PENSANDO_SW_DBG)
#endif

$(DOCKER_PENSANDO_SW)_CONTAINER_NAME = pensando-sw
$(DOCKER_PENSANDO_SW)_RUN_OPT += --privileged -t
$(DOCKER_PENSANDO_SW)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
$(DOCKER_PENSANDO_SW)_RUN_OPT += -v /etc:/host_etc:ro
$(DOCKER_PENSANDO_SW)_RUN_OPT += -v /var/run/dbus:/var/run/dbus:rw
$(DOCKER_PENSANDO_SW)_RUN_OPT += --mount type=bind,source="/var/platform/",target="/mnt/platform/"

#$(DOCKER_PENSANDO_SW)_BASE_IMAGE_FILES += sonic-cli:/usr/bin/sonic-cli
12 changes: 12 additions & 0 deletions rules/pensando-sw.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

SPATH := $($(PENSANDO_SW)_SRC_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/pensando-sw.mk rules/pensando-sw.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files))

$(PENSANDO_SW)_CACHE_MODE := GIT_CONTENT_SHA
$(PENSANDO_SW)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
$(PENSANDO_SW)_DEP_FILES := $(DEP_FILES)
$(PENSANDO_SW)_SMDEP_FILES := $(SMDEP_FILES)
$(PENSANDO_SW)_SMDEP_PATHS := $(SPATH)

15 changes: 15 additions & 0 deletions rules/pensando-sw.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# pensando sw package

PENSANDO_SW = pensando-sw_1.0.0-1_$(CONFIGURED_ARCH).deb
$(PENSANDO_SW)_SRC_PATH = $(SRC_PATH)/pensando
#$(PENSANDO_SW)_DEPENDS =
#$(PENSANDO_SW)_RDEPENDS =
SONIC_MAKE_DEBS += $(PENSANDO_SW)

#PENSANDO_SW_DBG = pensando-sw-dbgsym_1.0.0-1_$(CONFIGURED_ARCH).deb
#$(PENSANDO_SW_DBG)_DEPENDS += $(PENSANDO_SW)
#$(PENSANDO_SW_DBG)_RDEPENDS += $(PENSANDO_SW)
#$(eval $(call add_extra_package,$(PENSANDO_SW),$(PENSANDO_SW_DBG)))

export PENSANDO_SW
#export PENSANDO_SW_DBG
14 changes: 13 additions & 1 deletion sonic-slave-buster/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,12 @@ RUN apt-get update && apt-get install -y \
libdbus-1-dev \
libgirepository1.0-dev \
libsystemd-dev \
pkg-config
pkg-config \
# For pensando-sw build
libgrpc-dev \
libgrpc++-dev \
protobuf-compiler-grpc


RUN apt-get -y build-dep openssh

Expand Down Expand Up @@ -400,6 +405,10 @@ RUN export VERSION=1.14.2 \
&& echo 'export PATH=$PATH:$GOROOT/bin' >> /etc/bash.bashrc \
&& rm go$VERSION.linux-*.tar.gz

#For pensando-sw build
ENV GOROOT /usr/local/go
ENV PATH $PATH:$GOROOT/bin

RUN pip3 install --upgrade pip
RUN pip2 install --upgrade 'pip<21'
RUN apt-get purge -y python-pip python3-pip python3-yaml
Expand Down Expand Up @@ -466,6 +475,9 @@ RUN pip3 install pyang==2.4.0
RUN pip2 install mmh3==2.5.1
RUN pip3 install mmh3==2.5.1
# For pensando-sw build
RUN pip2 install ply==3.9
RUN apt-get install -y xsltproc
# Install dependencies for isc-dhcp-relay build
Expand Down
20 changes: 20 additions & 0 deletions src/pensando/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.ONESHELL:
SHELL = /bin/bash
.SHELLFLAGS += -e

$(info executing pensando makefile [${DEST}]...)
MAIN_TARGET = $(PENSANDO_SW)
#DERIVED_TARGET = $(PENSANDO_SW_DBG)

#unexport DEST

$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
pushd sw
# Build package
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR)

popd
mv $* $(DEST)/
#mv $(DERIVED_TARGET) $* $(DEST)/

#$(addprefix $(DEST)/, $(DERIVED_TARGET)): $(DEST)/% : $(DEST)/$(MAIN_TARGET)
1 change: 1 addition & 0 deletions src/pensando/sw
Submodule sw added at d6848d

0 comments on commit 5ff8b49

Please sign in to comment.