Skip to content

Commit

Permalink
Move sonic-host-services-data from sonic-buildimage into this repo
Browse files Browse the repository at this point in the history
This repo's tests depends on files that are in
src/sonic-host-services-data in sonic-buildimage. Due to PR check
requirements, this creates a cyclical dependency when needing to update
the templates and the sample output files.

To fix that cyclical dependency, move that directory into this repo.
That way, both the templates and the sample output files can be updated
in a single commit.

Signed-off-by: Saikrishna Arcot <[email protected]>
  • Loading branch information
saiarcot895 committed Oct 27, 2023
1 parent 86d528d commit bd6baa7
Show file tree
Hide file tree
Showing 35 changed files with 574 additions and 34 deletions.
29 changes: 4 additions & 25 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ trigger:
- master
- 202???

resources:
repositories:
- repository: sonic-buildimage
type: github
name: sonic-net/sonic-buildimage
endpoint: build

variables:
- name: BUILD_BRANCH
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
Expand All @@ -30,7 +23,6 @@ stages:
variables:
DIFF_COVER_CHECK_THRESHOLD: 80
DIFF_COVER_ENABLE: 'true'
DIFF_COVER_WORKING_DIRECTORY: $(System.DefaultWorkingDirectory)/sonic-host-services
pool:
vmImage: ubuntu-20.04

Expand All @@ -42,16 +34,6 @@ stages:
clean: true
submodules: recursive
displayName: 'Checkout code'

- checkout: sonic-buildimage
clean: true
displayName: 'Checkout code'

- task: CopyFiles@2
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)/sonic-buildimage/src/sonic-host-services-data/'
contents: '**'
targetFolder: $(System.DefaultWorkingDirectory)/sonic-host-services-data/

- task: DownloadPipelineArtifact@2
inputs:
Expand Down Expand Up @@ -102,14 +84,12 @@ stages:
displayName: "Install .NET CORE"
- script: |
pushd sonic-host-services
python3 setup.py test
displayName: 'Test Python 3'
- task: PublishTestResults@2
inputs:
testResultsFiles: '$(System.DefaultWorkingDirectory)/sonic-host-services/test-results.xml'
testResultsFiles: '$(System.DefaultWorkingDirectory)/test-results.xml'
testRunTitle: Python 3
failTaskOnFailedTests: true
condition: succeededOrFailed()
Expand All @@ -118,17 +98,16 @@ stages:
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/sonic-host-services/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/sonic-host-services/htmlcov/'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/htmlcov/'
displayName: 'Publish Python 3 test coverage'

- script: |
set -e
pushd sonic-host-services
python3 setup.py bdist_wheel
displayName: 'Build Python 3 wheel'
- publish: '$(System.DefaultWorkingDirectory)/sonic-host-services/dist/'
- publish: '$(System.DefaultWorkingDirectory)/dist/'
artifact: wheels
displayName: "Publish Python wheels"

6 changes: 6 additions & 0 deletions data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
debian/*.debhelper
debian/debhelper-build-stamp
debian/sonic-host-services-data/
sonic-host-services-data_*.buildinfo
sonic-host-services-data_*.changes
sonic-host-services-data_*.deb
7 changes: 7 additions & 0 deletions data/MAINTAINERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file describes the maintainers for sonic-host-services-data
# See the SONiC project governance document for more information

Name = "Joe LeVeque"
Email = "[email protected]"
Github = jleveque
Mailinglist = [email protected]
19 changes: 19 additions & 0 deletions data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# sonic-host-services-data
Data files required for SONiC host services


## To build

```
dpkg-buildpackage -rfakeroot -b -us -uc
```

## To clean

```
dpkg-buildpackage -rfakeroot -Tclean
```

---

See the [SONiC Website](https://sonic-net.github.io/SONiC/) for more information about the SONiC project.
5 changes: 5 additions & 0 deletions data/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sonic-host-services-data (1.0-1) UNRELEASED; urgency=low

* Initial release

-- Joe LeVeque <[email protected]> Tue, 20 Oct 2020 02:35:43 +0000
1 change: 1 addition & 0 deletions data/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11
11 changes: 11 additions & 0 deletions data/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Source: sonic-host-services-data
Maintainer: Joe LeVeque <[email protected]>
Section: misc
Priority: optional
Standards-Version: 0.1
Build-Depends: debhelper (>=11)

Package: sonic-host-services-data
Architecture: all
Depends: ${misc:Depends}
Description: Data files required for SONiC host services
Empty file added data/debian/copyright
Empty file.
2 changes: 2 additions & 0 deletions data/debian/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
templates/*.j2 /usr/share/sonic/templates/
org.sonic.hostservice.conf /etc/dbus-1/system.d
24 changes: 24 additions & 0 deletions data/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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:

%:
dh $@

override_dh_installsystemd:
dh_installsystemd --no-start --name=caclmgrd
dh_installsystemd --no-start --name=hostcfgd
dh_installsystemd --no-start --name=featured
dh_installsystemd --no-start --name=aaastatsd
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

14 changes: 14 additions & 0 deletions data/debian/sonic-host-services-data.aaastatsd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=AAA Statistics Collection daemon
Requires=hostcfgd.service
After=hostcfgd.service updategraph.service
BindsTo=sonic.target
After=sonic.target

[Service]
Type=simple
ExecStart=/usr/local/bin/aaastatsd
Restart=on-failure
RestartSec=10
TimeoutStopSec=3

12 changes: 12 additions & 0 deletions data/debian/sonic-host-services-data.aaastatsd.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Delays aaastatsd daemon until SONiC has started
PartOf=aaastatsd.service

[Timer]
OnUnitActiveSec=0 sec
OnBootSec=1min 30 sec
Unit=aaastatsd.service

[Install]
WantedBy=timers.target sonic.target

15 changes: 15 additions & 0 deletions data/debian/sonic-host-services-data.caclmgrd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Control Plane ACL configuration daemon
Requires=updategraph.service
After=updategraph.service
BindsTo=sonic.target
After=sonic.target

[Service]
Type=simple
ExecStart=/usr/local/bin/caclmgrd
Restart=always
RestartSec=30

[Install]
WantedBy=sonic.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Reboot cause determination service
Requires=rc-local.service database.service
After=rc-local.service database.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/determine-reboot-cause

[Install]
WantedBy=multi-user.target
10 changes: 10 additions & 0 deletions data/debian/sonic-host-services-data.featured.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Feature configuration daemon
Requires=updategraph.service
After=updategraph.service
BindsTo=sonic.target
After=sonic.target

[Service]
Type=simple
ExecStart=/usr/local/bin/featured
12 changes: 12 additions & 0 deletions data/debian/sonic-host-services-data.featured.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Delays feature daemon until SONiC has started
PartOf=featured.service

[Timer]
OnUnitActiveSec=0 sec
OnBootSec=1min 30 sec
Unit=featured.service

[Install]
WantedBy=timers.target sonic.target

11 changes: 11 additions & 0 deletions data/debian/sonic-host-services-data.hostcfgd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Host config enforcer daemon
Requires=updategraph.service
After=updategraph.service
BindsTo=sonic.target
After=sonic.target

[Service]
Type=simple
ExecStart=/usr/local/bin/hostcfgd

12 changes: 12 additions & 0 deletions data/debian/sonic-host-services-data.hostcfgd.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Delays hostcfgd daemon until SONiC has started
PartOf=hostcfgd.service

[Timer]
OnUnitActiveSec=0 sec
OnBootSec=1min 30 sec
Unit=hostcfgd.service

[Install]
WantedBy=timers.target sonic.target

14 changes: 14 additions & 0 deletions data/debian/sonic-host-services-data.procdockerstatsd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Process and docker CPU/memory utilization data export daemon
Requires=database.service updategraph.service
After=database.service updategraph.service
BindsTo=sonic.target
After=sonic.target

[Service]
Type=simple
ExecStart=/usr/local/bin/procdockerstatsd
Restart=always

[Install]
WantedBy=sonic.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Retrieve the reboot cause from the history files and save them to StateDB
Requires=database.service determine-reboot-cause.service
After=database.service determine-reboot-cause.service

[Service]
Type=simple
ExecStart=/usr/local/bin/process-reboot-cause
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Delays process-reboot-cause until network is stably connected

[Timer]
OnBootSec=1min 30 sec
Unit=process-reboot-cause.service

[Install]
WantedBy=timers.target
16 changes: 16 additions & 0 deletions data/debian/sonic-host-services-data.sonic-hostservice.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=SONiC Host Service

[Service]
Type=dbus
BusName=org.SONiC.HostService

ExecStart=/usr/bin/python3 -u /usr/local/bin/sonic-host-server

Restart=on-failure
RestartSec=10
TimeoutStopSec=3

[Install]
WantedBy=mgmt-framework.service telemetry.service

18 changes: 18 additions & 0 deletions data/org.sonic.hostservice.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

<!-- Only root can own the bus -->

<policy user="root">
<allow own_prefix="org.SONiC.HostService"/>
</policy>

<!-- Allow user "root" to invoke methods on the bus -->
<policy user="root">
<allow send_destination="org.SONiC.HostService"/>
<allow receive_sender="org.SONiC.HostService"/>
</policy>

</busconfig>
Loading

0 comments on commit bd6baa7

Please sign in to comment.