Skip to content

Commit 8d829cc

Browse files
Addressing review comments
1 parent 5c98c46 commit 8d829cc

File tree

4 files changed

+38
-16
lines changed

4 files changed

+38
-16
lines changed

data/debian/sonic-host-services-data.gnoi-shutdown.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ After=network-online.target database.service
66

77
[Service]
88
Type=simple
9-
ExecStartPre=/usr/local/bin/check_platform.sh
9+
ExecStartPre=/usr/local/bin/check_platform.py
1010
ExecStartPre=/usr/local/bin/wait-for-sonic-core.sh
1111
ExecStart=/usr/local/bin/gnoi-shutdown-daemon
1212
Restart=always

scripts/check_platform.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Check if the current platform is a SmartSwitch NPU (not DPU).
4+
Exit 0 if SmartSwitch NPU, exit 1 otherwise.
5+
"""
6+
import sys
7+
import subprocess
8+
9+
def main():
10+
try:
11+
# Get subtype from config
12+
result = subprocess.run(
13+
['sonic-cfggen', '-d', '-v', 'DEVICE_METADATA.localhost.subtype'],
14+
capture_output=True,
15+
text=True,
16+
timeout=5
17+
)
18+
subtype = result.stdout.strip()
19+
20+
# Check if DPU
21+
try:
22+
from utilities_common.chassis import is_dpu
23+
is_dpu_platform = is_dpu()
24+
except Exception:
25+
is_dpu_platform = False
26+
27+
# Check if SmartSwitch NPU (not DPU)
28+
if subtype == "SmartSwitch" and not is_dpu_platform:
29+
sys.exit(0)
30+
else:
31+
sys.exit(1)
32+
except Exception:
33+
sys.exit(1)
34+
35+
if __name__ == "__main__":
36+
main()

scripts/check_platform.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
'scripts/procdockerstatsd',
4343
'scripts/determine-reboot-cause',
4444
'scripts/process-reboot-cause',
45-
'scripts/check_platform.sh',
45+
'scripts/check_platform.py',
4646
'scripts/wait-for-sonic-core.sh',
4747
'scripts/sonic-host-server',
4848
'scripts/ldap.py'

0 commit comments

Comments
 (0)