Skip to content
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

[sonic-host-service] Move to sonic-host-services package #6273

Merged
merged 11 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ SONIC_BUILD_INSTRUCTION := make \
EXTRA_DOCKER_TARGETS=$(EXTRA_DOCKER_TARGETS) \
BUILD_LOG_TIMESTAMP=$(BUILD_LOG_TIMESTAMP) \
SONIC_ENABLE_IMAGE_SIGNATURE=$(ENABLE_IMAGE_SIGNATURE) \
ENABLE_HOST_SERVICE_ON_START=$(ENABLE_HOST_SERVICE_ON_START) \
SLAVE_DIR=$(SLAVE_DIR) \
$(SONIC_OVERRIDE_BUILD_VARS)

Expand Down
4 changes: 3 additions & 1 deletion build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ else
sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install docker-ce=${DOCKER_VERSION}
fi

sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y remove software-properties-common gnupg2
# Uninstall 'python3-gi' installed as part of 'software-properties-common' to remove debian version of 'PyGObject'
# pip version of 'PyGObject' will be installed during installation of 'sonic-host-services'
sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y remove software-properties-common gnupg2 python3-gi

if [ "$INCLUDE_KUBERNETES" == "y" ]
then
Expand Down
14 changes: 8 additions & 6 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,13 @@ sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/sonic-utilities-data_*.deb || \
# in bash.bashrc, so we copy a version of the file with it enabled here.
sudo cp -f $IMAGE_CONFIGS/bash/bash.bashrc $FILESYSTEM_ROOT/etc/

# Install prerequisites needed for installing the dependent Python packages of sonic-host-services
# These packages can be uninstalled after installation
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install libcairo2-dev libdbus-1-dev libgirepository1.0-dev libsystemd-dev pkg-config
jleveque marked this conversation as resolved.
Show resolved Hide resolved

# Manually install runtime dependencies to avoid them being auto-removed while uninstalling build dependencies
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install gir1.2-glib-2.0 libdbus-1-3 libgirepository-1.0-1 libsystemd0

# Install SONiC host services package
SONIC_HOST_SERVICES_PY3_WHEEL_NAME=$(basename {{sonic_host_services_py3_wheel_path}})
sudo cp {{sonic_host_services_py3_wheel_path}} $FILESYSTEM_ROOT/$SONIC_HOST_SERVICES_PY3_WHEEL_NAME
Expand All @@ -262,12 +269,6 @@ sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/sonic-ztp_*.deb || \
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
{% endif %}

{% if include_host_service == "y" %}
# Install SONiC Host Service (and its dependencies via 'apt-get -y install -f')
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/sonic-host-service_*.deb || \
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
{% endif %}

# Install SONiC Device Data (and its dependencies via 'apt-get -y install -f')
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/sonic-device-data_*.deb || \
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
Expand Down Expand Up @@ -676,6 +677,7 @@ echo "mgmt-framework.timer" | sudo tee -a $GENERATED_SERVICE_FILE

sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y python-dev python3-dev
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y build-essential libssl-dev swig
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y libcairo2-dev libdbus-1-dev libgirepository1.0-dev libsystemd-dev pkg-config
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get clean -y
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get autoremove -y

Expand Down
16 changes: 15 additions & 1 deletion platform/vs/docker-sonic-vs/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,20 @@ RUN apt-get install -y net-tools \
libssl-dev \
swig \
# For using Python m2crypto package
openssl
openssl \
# For installing dependent Python packages of sonic-host-services
# (these can be uninstalled after installation)
libcairo2-dev \
libdbus-1-dev \
libgirepository1.0-dev \
libsystemd-dev \
pkg-config \
# For installing dependent Python packages of sonic-host-services
# these packages are needed at runtime
gir1.2-glib-2.0 \
libdbus-1-3 \
libgirepository-1.0-1 \
libsystemd0

# Install redis-server
{% if CONFIGURED_ARCH == "armhf" %}
Expand Down Expand Up @@ -129,6 +142,7 @@ RUN pip{% if 'py3' in whl %}3{% else %}2{% endif %} install python-wheels/{{ whl
# Clean up
RUN apt-get purge -y build-essential libssl-dev swig
RUN apt-get purge -y python-dev python3-dev
RUN apt-get purge -y libcairo2-dev libdbus-1-dev libgirepository1.0-dev libsystemd-dev pkg-config
RUN apt-get clean -y
RUN apt-get autoclean -y
RUN apt-get autoremove -y
Expand Down
6 changes: 3 additions & 3 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ INCLUDE_SFLOW = y
# INCLUDE_MGMT_FRAMEWORK - build docker-sonic-mgmt-framework for CLI and REST server support
INCLUDE_MGMT_FRAMEWORK = y

# INCLUDE_HOST_SERVICE - build sonic-host-services for mgmt-framework and/or
# telemetry containers to access host functionality
INCLUDE_HOST_SERVICE = n
# ENABLE_HOST_SERVICE_ON_START - enable sonic-host-server for mgmt-framework and/or
# telemetry containers to access host functionality by default
ENABLE_HOST_SERVICE_ON_START = n

# INCLUDE_RESTAPI - build docker-sonic-restapi for configuring the switch using REST APIs
INCLUDE_RESTAPI = n
Expand Down
12 changes: 0 additions & 12 deletions rules/sonic-host-service.dep

This file was deleted.

9 changes: 0 additions & 9 deletions rules/sonic-host-service.mk

This file was deleted.

4 changes: 1 addition & 3 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ $(info "VS_PREPARE_MEM" : "$(VS_PREPARE_MEM)")
$(info "INCLUDE_MGMT_FRAMEWORK" : "$(INCLUDE_MGMT_FRAMEWORK)")
$(info "INCLUDE_ICCPD" : "$(INCLUDE_ICCPD)")
$(info "INCLUDE_SYSTEM_TELEMETRY" : "$(INCLUDE_SYSTEM_TELEMETRY)")
$(info "INCLUDE_HOST_SERVICE" : "$(INCLUDE_HOST_SERVICE)")
$(info "ENABLE_HOST_SERVICE_ON_START" : "$(ENABLE_HOST_SERVICE_ON_START)")
$(info "INCLUDE_RESTAPI" : "$(INCLUDE_RESTAPI)")
$(info "INCLUDE_SFLOW" : "$(INCLUDE_SFLOW)")
$(info "INCLUDE_NAT" : "$(INCLUDE_NAT)")
Expand Down Expand Up @@ -857,7 +857,6 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
$$(addprefix $(TARGET_PATH)/,$$($$*_DOCKERS)) \
$$(addprefix $(FILES_PATH)/,$$($$*_FILES)) \
$(if $(findstring y,$(ENABLE_ZTP)),$(addprefix $(IMAGE_DISTRO_DEBS_PATH)/,$(SONIC_ZTP))) \
$(if $(findstring y,$(INCLUDE_HOST_SERVICE)),$(addprefix $(IMAGE_DISTRO_DEBS_PATH)/,$(SONIC_HOST_SERVICE))) \
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_UTILITIES_PY3)) \
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PY_COMMON_PY2)) \
$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PY_COMMON_PY3)) \
Expand Down Expand Up @@ -892,7 +891,6 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \
export enable_ztp="$(ENABLE_ZTP)"
export include_system_telemetry="$(INCLUDE_SYSTEM_TELEMETRY)"
export include_restapi="$(INCLUDE_RESTAPI)"
export include_host_service="$(INCLUDE_HOST_SERVICE)"
export include_nat="$(INCLUDE_NAT)"
export include_sflow="$(INCLUDE_SFLOW)"
export include_mgmt_framework="$(INCLUDE_MGMT_FRAMEWORK)"
Expand Down
10 changes: 8 additions & 2 deletions sonic-slave-buster/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,13 @@ RUN apt-get update && apt-get install -y \
libboost-regex1.71-dev \
googletest \
libgtest-dev \
libgcc-8-dev
libgcc-8-dev \
# For sonic-host-services build
libcairo2-dev \
libdbus-1-dev \
libgirepository1.0-dev \
libsystemd-dev \
pkg-config

# Build fix for ARMHF buster libsairedis
{%- if CONFIGURED_ARCH == "armhf" %}
Expand Down Expand Up @@ -390,7 +396,7 @@ RUN export VERSION=1.14.2 \

RUN pip3 install --upgrade pip
RUN pip2 install --upgrade 'pip<21'
RUN apt-get purge -y python-pip python3-pip
RUN apt-get purge -y python-pip python3-pip python3-yaml

# For building Python packages
RUN pip2 install setuptools==40.8.0
Expand Down
41 changes: 0 additions & 41 deletions src/sonic-host-service/Makefile

This file was deleted.

4 changes: 0 additions & 4 deletions src/sonic-host-service/debian/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions src/sonic-host-service/debian/changelog

This file was deleted.

1 change: 0 additions & 1 deletion src/sonic-host-service/debian/compat

This file was deleted.

15 changes: 0 additions & 15 deletions src/sonic-host-service/debian/control

This file was deleted.

9 changes: 0 additions & 9 deletions src/sonic-host-service/debian/rules

This file was deleted.

1 change: 1 addition & 0 deletions src/sonic-host-services-data/debian/install
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
templates/*.j2 /usr/share/sonic/templates/
org.sonic.hostservice.conf /etc/dbus-1/system.d
8 changes: 8 additions & 0 deletions src/sonic-host-services-data/debian/rules
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/usr/bin/make -f

ifeq (${ENABLE_HOST_SERVICE_ON_START}, y)
HOST_SERVICE_OPTS := --no-start
else
HOST_SERVICE_OPTS := --no-start --no-enable
endif


build:

%:
Expand All @@ -11,4 +18,5 @@ override_dh_installsystemd:
dh_installsystemd --no-start --name=procdockerstatsd
dh_installsystemd --no-start --name=determine-reboot-cause
dh_installsystemd --no-start --name=process-reboot-cause
dh_installsystemd $(HOST_SERVICE_OPTS) --name=sonic-hostservice

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description=SONiC Host Service
Type=dbus
BusName=org.SONiC.HostService

ExecStart=/usr/bin/python3 -u /usr/lib/sonic_host_service/sonic_host_server.py
ExecStart=/usr/bin/python3 -u /usr/local/bin/sonic-host-server

Restart=on-failure
RestartSec=10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def register_modules():
"""Register all host modules"""
mod_path = os.path.join(os.path.dirname(__file__), 'host_modules')
mod_path = '/usr/local/lib/python3.7/dist-packages/host_modules'
sys.path.append(mod_path)
for mod_file in glob.glob(os.path.join(mod_path, '*.py')):
if os.path.isfile(mod_file) and not mod_file.endswith('__init__.py'):
Expand Down
7 changes: 7 additions & 0 deletions src/sonic-host-services/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,24 @@
url = 'https://github.com/Azure/sonic-buildimage',
maintainer = 'Joe LeVeque',
maintainer_email = 'jolevequ@microsoft.com',
packages = [
'host_modules'
],
scripts = [
'scripts/caclmgrd',
'scripts/hostcfgd',
'scripts/procdockerstatsd',
'scripts/determine-reboot-cause',
'scripts/process-reboot-cause',
'scripts/sonic-host-server'
],
install_requires = [
'dbus-python',
'Jinja2>=2.10',
'PyGObject',
'sonic-py-common',
'swsssdk>=2.0.1',
'systemd-python',
],
setup_requires = [
'pytest-runner',
Expand Down